private static <L> void appendPreTerminalYield(Tree<L> tree, List<L> yield) { if (tree.isPreTerminal()) { yield.add(tree.getLabel()); return; } for (Tree<L> child : tree.getChildren()) { appendPreTerminalYield(child, yield); } }
/* Returns a list of the preterminals gotten by traversing from left * to right. This is effectively an POS tagging for the words that * tree represents. */ public List<L> getPreTerminalYield() { List<L> yield = new ArrayList<L>(); appendPreTerminalYield(this, yield); return yield; }