@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t1, root) <= Trees.leftEdge(t2, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.leftEdge(t1, root) == Trees.rightEdge(t2, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.leftEdge(t2, root) == Trees.rightEdge(t1, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t2, root) <= Trees.leftEdge(t1, root); }
/** * Returns the positional index of the right edge of a tree * <i>t</i> within a given root, as defined by the size of the yield * of all material preceding <i>t</i> plus all the material * contained in <i>t</i>. */ public static int rightEdge(Tree t, Tree root) { MutableInteger i = new MutableInteger(root.yield().size()); if (rightEdge(t, root, i)) { return i.intValue(); } else { throw new RuntimeException("Tree is not a descendant of root."); // return root.yield().size() + 1; } }
@Override public boolean test(Tree obj) { if (obj.dominates(firstToKeep)) return true; Tree leftmostDescendant = getLeftmostDescendant(obj); return Trees.rightEdge(leftmostDescendant, root) > Trees.leftEdge(firstToKeep, root); }
public static Collection commonWordTagTypeBrackets(Tree root1, Tree root2) { root1 = ext.transformTree(root1); root2 = ext.transformTree(root2); List<Tree> firstPreTerms = new ArrayList<>(); for (Tree tree : root1) { if (tree.isPrePreTerminal()) { firstPreTerms.add(tree); } } List<WordCatConstituent> brackets = new ArrayList<>(); for (Tree preTerm : firstPreTerms) { for (Tree tree : root2) { if (!tree.isPrePreTerminal()) { continue; } if (Trees.leftEdge(tree, root2) == Trees.leftEdge(preTerm, root1) && Trees.rightEdge(tree, root2) == Trees.rightEdge(preTerm, root1)) { brackets.add(new WordCatConstituent(preTerm, root1, WordCatConstituent.goodWordTagType)); break; } } } return brackets; }
/** * Returns the positional index of the right edge of a tree * <i>t</i> within a given root, as defined by the size of the yield * of all material preceding <i>t</i> plus all the material * contained in <i>t</i>. * This method returns root.yield().size() + 1 if no path is found, rather than exceptioning. * * @see Trees#rightEdge(Tree, Tree) */ public static int rightEdgeUnsafe(Tree t, Tree root) { MutableInteger i = new MutableInteger(root.yield().size()); if (rightEdge(t, root, i)) { return i.intValue(); } else { return root.yield().size() + 1; } }
@Override public boolean test(Tree obj) { if (obj == reference || obj.dominates(reference) || reference.dominates(obj)) return true; Tree rightmostDescendant = getRightmostDescendant(obj); return Trees.rightEdge(rightmostDescendant, root) <= Trees.leftEdge(reference, root); }
static boolean rightEdge(Tree t, Tree t1, MutableInteger i) { if (t == t1) { return true; } else if (t1.isLeaf()) { int j = t1.yield().size(); // so that empties don't add size i.set(i.intValue() - j); return false; } else { Tree[] kids = t1.children(); for (int j = kids.length - 1; j >= 0; j--) { if (rightEdge(t, kids[j], i)) { return true; } } return false; } }
public WordCatConstituent(Tree subTree, Tree root, String type) { setStart(Trees.leftEdge(subTree, root)); setEnd(Trees.rightEdge(subTree, root)); setFromString(subTree.value()); this.type = type; }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t1, root) <= Trees.leftEdge(t2, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.leftEdge(t2, root) == Trees.rightEdge(t1, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t1, root) <= Trees.leftEdge(t2, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t2, root) <= Trees.leftEdge(t1, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.leftEdge(t2, root) == Trees.rightEdge(t1, root); }
@Override boolean satisfies(Tree t1, Tree t2, Tree root, final TregexMatcher matcher) { return Trees.rightEdge(t2, root) <= Trees.leftEdge(t1, root); }
@Override public boolean test(Tree obj) { if (obj.dominates(firstToKeep)) return true; Tree leftmostDescendant = getLeftmostDescendant(obj); return Trees.rightEdge(leftmostDescendant, root) > Trees.leftEdge(firstToKeep, root); }
@Override public boolean test(Tree obj) { if (obj == reference || obj.dominates(reference) || reference.dominates(obj)) return true; Tree rightmostDescendant = getRightmostDescendant(obj); return Trees.rightEdge(rightmostDescendant, root) <= Trees.leftEdge(reference, root); }
public WordCatConstituent(Tree subTree, Tree root, String type) { setStart(Trees.leftEdge(subTree, root)); setEnd(Trees.rightEdge(subTree, root)); setFromString(subTree.value()); this.type = type; }