public boolean hasEdgeLabels() { if (this.parent == null) { return this.parent.childrenEdgeLabels != null; } else { return !this.isLeaf() && this.childrenEdgeLabels != null; } }
public boolean hasEdgeLabels() { if (this.parent == null) { return this.parent.childrenEdgeLabels != null; } else { return !this.isLeaf() && this.childrenEdgeLabels != null; } }
void addMatch(Tree<T> match) { if (dfs[currentPosition].isLeaf()) patternLeafMatches.add(match); matches.add(match); currentPosition++; }
void addMatch(Tree<T> match) { if (dfs[currentPosition].isLeaf()) patternLeafMatches.add(match); matches.add(match); currentPosition++; }
@Override public String toString() { String s = toString(true, 0); if (this.isLeaf()) s = "(" + s + ")"; return s; }
private void computeYield() { yield = new ArrayList<>(); if (this.isLeaf()) yield.add(this); else for (Tree<T> t : children) yield.addAll(t.getYield()); }
@Override public String toString() { String s = toString(true, 0); if (this.isLeaf()) s = "(" + s + ")"; return s; }
private void computeYield() { yield = new ArrayList<>(); if (this.isLeaf()) yield.add(this); else for (Tree<T> t : children) yield.addAll(t.getYield()); }
public static boolean isPreTerminal(Tree t) { List<Tree> kids = t.getChildren(); return (kids.size() == 1) && (kids.get(0).isLeaf()); }
public static boolean isPreTerminal(Tree t) { List<Tree> kids = t.getChildren(); return (kids.size() == 1) && (kids.get(0).isLeaf()); }
@Override public String transform(Tree<String> input) { if (input.isLeaf()) return input.getLabel(); else return stripFunctionTags(input.getLabel()); } });
@Override public String transform(Tree<String> input) { if (input.isLeaf()) return input.getLabel(); String label = input.getLabel(); return stripIndexReferences(label); } });
@Override public String transform(Tree<String> input) { if (input.isLeaf()) return input.getLabel(); else return stripFunctionTags(input.getLabel()); } });
@Override public String transform(Tree<String> input) { if (input.isLeaf()) return input.getLabel(); String label = input.getLabel(); return stripIndexReferences(label); } });
private Tree<Constituent> getConstituentSubTree(Tree<Pair<String, IntPair>> parseTree) { Pair<String, IntPair> rootLabel = parseTree.getLabel(); Constituent root = createConstituent(rootLabel); Tree<Constituent> constituentTree = new Tree<>(root); for (Tree<Pair<String, IntPair>> child : parseTree.getChildren()) { if (child.isLeaf()) continue; constituentTree.addSubtree(getConstituentSubTree(child)); } return constituentTree; }
private Tree<Constituent> getConstituentSubTree(Tree<Pair<String, IntPair>> parseTree) { Pair<String, IntPair> rootLabel = parseTree.getLabel(); Constituent root = createConstituent(rootLabel); Tree<Constituent> constituentTree = new Tree<>(root); for (Tree<Pair<String, IntPair>> child : parseTree.getChildren()) { if (child.isLeaf()) continue; constituentTree.addSubtree(getConstituentSubTree(child)); } return constituentTree; }
private static boolean createSnippedTree(Tree<String> original, Tree<String> newTree) { assert original.getLabel().equals(newTree.getLabel()); if (original.isLeaf()) return true; boolean addedChild = false; for (Tree<String> child : original.getChildren()) { String label = child.getLabel(); if (ParseTreeProperties.isNullLabel(label)) continue; Tree<String> newChild = new Tree<>(label); if (!createSnippedTree(child, newChild)) continue; newTree.addSubtree(newChild); addedChild = true; } return addedChild; }
private static boolean createSnippedTree(Tree<String> original, Tree<String> newTree) { assert original.getLabel().equals(newTree.getLabel()); if (original.isLeaf()) return true; boolean addedChild = false; for (Tree<String> child : original.getChildren()) { String label = child.getLabel(); if (ParseTreeProperties.isNullLabel(label)) continue; Tree<String> newChild = new Tree<>(label); if (!createSnippedTree(child, newChild)) continue; newTree.addSubtree(newChild); addedChild = true; } return addedChild; }