private static void connect(List<Integer> parentPointers, Tree[] subtrees, boolean[] connected, int index) { if (connected[index]) { return; } if (parentPointers.get(index) < 0) { return; } subtrees[parentPointers.get(index)].addChild(subtrees[index]); connected[index] = true; connect(parentPointers, subtrees, connected, parentPointers.get(index)); }
/** * Adds the tree t at the last index position among the daughters. * * @param t the new daughter */ public void addChild(Tree t) { addChild(children().length, t); }
left.addChild(ccSiblings[i]); tree.addChild(0, left); if (VERBOSE) ccSiblings[j].pennPrint(); t.removeChild(0); tree.addChild(k, ccSiblings[j]); k++; t.addChild(0, tree); } else { t.addChild(0, left); Tree sib = t.getChild(start); t.removeChild(start); rightTree.addChild(sib); t.addChild(rightTree); } else { t.addChild(0, left); child.addChild(ccSiblings[i]); t.addChild(1, child); child.addChild(ccSiblings[i]); child.addChild(0, ccSiblings[i]); // add the comma child.addChild(0, ccSiblings[i - 1]); // add the word before the comma
Tree leaf = new LabeledScoredTreeNode(word); subtrees[i] = new LabeledScoredTreeNode(new CoreLabel()); subtrees[i].addChild(leaf);
static Tree createNode(Tree top, String label, Tree ... children) { CoreLabel headLabel = (CoreLabel) top.label(); CoreLabel production = new CoreLabel(); production.setValue(label); production.set(TreeCoreAnnotations.HeadWordLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordLabelAnnotation.class)); production.set(TreeCoreAnnotations.HeadTagLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagLabelAnnotation.class)); Tree newTop = new LabeledScoredTreeNode(production); for (Tree child : children) { newTop.addChild(child); } return newTop; }
@Override public Tree evaluate(Tree tree, TregexMatcher tregex) { Tree topNode = childMatcher[0].evaluate(tree, tregex); Tree bottomNode = childMatcher[1].evaluate(tree, tregex); if(Tsurgeon.verbose) { log.info("Excising...original tree:"); tree.pennPrint(System.err); log.info("top: " + topNode + "\nbottom:" + bottomNode); } if (topNode == tree) { if (bottomNode.children().length == 1) { return bottomNode.children()[0]; } else { return null; } } Tree parent = topNode.parent(tree); if(Tsurgeon.verbose) log.info("Parent: " + parent); int i = Trees.objectEqualityIndexOf(parent,topNode); parent.removeChild(i); for(Tree child : bottomNode.children()) { parent.addChild(i,child); i++; } if(Tsurgeon.verbose) tree.pennPrint(System.err); return tree; } }
/** * Adds the tree t at the last index position among the daughters. * * @param t the new daughter */ public void addChild(Tree t) { addChild(children().length, t); }
/** * Adds the tree t at the last index position among the daughters. * * @param t the new daughter */ public void addChild(Tree t) { addChild(children().length, t); }
private static void connect(List<Integer> parentPointers, Tree[] subtrees, boolean[] connected, int index) { if (connected[index]) { return; } if (parentPointers.get(index) < 0) { return; } subtrees[parentPointers.get(index)].addChild(subtrees[index]); connected[index] = true; connect(parentPointers, subtrees, connected, parentPointers.get(index)); }
/** * Adds the tree t at the last index position among the daughters. * * @param t the new daughter */ public void addChild(Tree t) { addChild(children().length, t); }
private static void connect(List<Integer> parentPointers, Tree[] subtrees, boolean[] connected, int index) { if (connected[index]) { return; } if (parentPointers.get(index) < 0) { return; } subtrees[parentPointers.get(index)].addChild(subtrees[index]); connected[index] = true; connect(parentPointers, subtrees, connected, parentPointers.get(index)); }
/** * Adds the tree t at the last index position among the daughters. * * @param t the new daughter */ public void addChild(Tree t) { addChild(children().length, t); }
private static void transformQP(Tree t) { List<Tree> children = t.getChildrenAsList(); TreeFactory tf = t.treeFactory(); LabelFactory lf = t.label().labelFactory(); //create the new XS having the first two children of the QP Tree left = tf.newTreeNode(lf.newLabel("XS"), null); for (int i = 0; i < 2; i++) { left.addChild(children.get(i)); } // remove all the two first children of t before for (int i = 0; i < 2; i++) { t.removeChild(0); } // add XS as the first child t.addChild(0, left); }
private static void transformQP(Tree t) { List<Tree> children = t.getChildrenAsList(); TreeFactory tf = t.treeFactory(); LabelFactory lf = t.label().labelFactory(); //create the new XS having the first two children of the QP Tree left = tf.newTreeNode(lf.newLabel("XS"), null); for (int i = 0; i < 2; i++) { left.addChild(children.get(i)); } // remove all the two first children of t before for (int i = 0; i < 2; i++) { t.removeChild(0); } // add XS as the first child t.addChild(0, left); }
@Override public Tree evaluate(Tree t, TregexMatcher m) { Tree topNode = children[0].evaluate(t,m); Tree bottomNode = children[1].evaluate(t,m); if(Tsurgeon.verbose) { System.err.println("Excising...original tree:"); t.pennPrint(System.err); System.err.println("top: " + topNode + "\nbottom:" + bottomNode); } if(topNode==t) return null; Tree parent = topNode.parent(t); if(Tsurgeon.verbose) System.err.println("Parent: " + parent); int i = Trees.objectEqualityIndexOf(parent,topNode); parent.removeChild(i); for(Tree child : bottomNode.children()) { parent.addChild(i,child); i++; } if(Tsurgeon.verbose) t.pennPrint(System.err); return t; } }
static Tree createNode(Tree top, String label, Tree ... children) { CoreLabel headLabel = (CoreLabel) top.label(); CoreLabel production = new CoreLabel(); production.setValue(label); production.set(TreeCoreAnnotations.HeadWordAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordAnnotation.class)); production.set(TreeCoreAnnotations.HeadTagAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagAnnotation.class)); Tree newTop = new LabeledScoredTreeNode(production); for (Tree child : children) { newTop.addChild(child); } return newTop; }
static Tree createNode(Tree top, String label, Tree ... children) { CoreLabel headLabel = (CoreLabel) top.label(); CoreLabel production = new CoreLabel(); production.setValue(label); production.set(TreeCoreAnnotations.HeadWordLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordLabelAnnotation.class)); production.set(TreeCoreAnnotations.HeadTagLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagLabelAnnotation.class)); Tree newTop = new LabeledScoredTreeNode(production); for (Tree child : children) { newTop.addChild(child); } return newTop; }
static Tree createNode(Tree top, String label, Tree ... children) { CoreLabel headLabel = (CoreLabel) top.label(); CoreLabel production = new CoreLabel(); production.setValue(label); production.set(TreeCoreAnnotations.HeadWordLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadWordLabelAnnotation.class)); production.set(TreeCoreAnnotations.HeadTagLabelAnnotation.class, headLabel.get(TreeCoreAnnotations.HeadTagLabelAnnotation.class)); Tree newTop = new LabeledScoredTreeNode(production); for (Tree child : children) { newTop.addChild(child); } return newTop; }