本文整理汇总了Java中edu.stanford.nlp.trees.Trees.rightEdge方法的典型用法代码示例。如果您正苦于以下问题:Java Trees.rightEdge方法的具体用法?Java Trees.rightEdge怎么用?Java Trees.rightEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.trees.Trees
的用法示例。
在下文中一共展示了Trees.rightEdge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotatePhraseStructureRecursively
import edu.stanford.nlp.trees.Trees; //导入方法依赖的package包/类
/**
* Generate a SyntaxTreeNode Annotation corresponding to this Tree. Work
* recursively so that the annotations are actually generated from the bottom
* up, in order to build the consists list of annotation IDs.
*
* @param tree
* the current subtree
* @param rootTree
* the whole sentence, used to find the span of the current subtree
* @return a GATE Annotation of type "SyntaxTreeNode"
*/
protected Annotation annotatePhraseStructureRecursively(
AnnotationSet annotationSet, StanfordSentence stanfordSentence,
Tree tree, Tree rootTree) {
Annotation annotation = null;
Annotation child;
String label = tree.value();
List<Tree> children = tree.getChildrenAsList();
if(children.size() == 0) { return null; }
/* implied else */
/*
* following line generates ClassCastException IntPair span =
* tree.getSpan(); edu.stanford.nlp.ling.CategoryWordTag at
* edu.stanford.nlp.trees.Tree.getSpan(Tree.java:393) but I think it's a bug
* in the parser, so I'm hacking around it as follows.
*/
int startPos = Trees.leftEdge(tree, rootTree);
int endPos = Trees.rightEdge(tree, rootTree);
Long startNode = stanfordSentence.startPos2offset(startPos);
Long endNode = stanfordSentence.endPos2offset(endPos);
List<Integer> consists = new ArrayList<Integer>();
Iterator<Tree> childIter = children.iterator();
while(childIter.hasNext()) {
child =
annotatePhraseStructureRecursively(annotationSet, stanfordSentence,
childIter.next(), rootTree);
if((child != null) && (!child.getType().equals(inputTokenType))) {
consists.add(child.getId());
}
}
annotation =
annotatePhraseStructureConstituent(annotationSet, startNode, endNode,
label, consists, tree.depth());
return annotation;
}
示例2: annotatePhraseStructureRecursively
import edu.stanford.nlp.trees.Trees; //导入方法依赖的package包/类
/**
* Generate a SyntaxTreeNode Annotation corresponding to this Tree. Work
* recursively so that the annotations are actually generated from the
* bottom up, in order to build the consists list of annotation IDs.
*
* @param tree the current subtree
* @param rootTree the whole sentence, used to find the span of the current subtree
* @return a GATE Annotation of type "SyntaxTreeNode"
*/
protected Annotation annotatePhraseStructureRecursively(AnnotationSet annotationSet, StanfordSentence stanfordSentence, Tree tree, Tree rootTree) {
Annotation annotation = null;
Annotation child;
String label = tree.value();
List<Tree> children = tree.getChildrenAsList();
if (children.size() == 0) {
return null;
}
/* implied else */
/* following line generates ClassCastException
* IntPair span = tree.getSpan();
* edu.stanford.nlp.ling.CategoryWordTag
* at edu.stanford.nlp.trees.Tree.getSpan(Tree.java:393)
* but I think it's a bug in the parser, so I'm hacking
* around it as follows. */
int startPos = Trees.leftEdge(tree, rootTree);
int endPos = Trees.rightEdge(tree, rootTree);
Long startNode = stanfordSentence.startPos2offset(startPos);
Long endNode = stanfordSentence.endPos2offset(endPos);
List<Integer> consists = new ArrayList<Integer>();
Iterator<Tree> childIter = children.iterator();
while (childIter.hasNext()) {
child = annotatePhraseStructureRecursively(annotationSet, stanfordSentence, childIter.next(), rootTree);
if ( (child != null) &&
(! child.getType().equals(inputTokenType) )) {
consists.add(child.getId());
}
}
annotation = annotatePhraseStructureConstituent(annotationSet, startNode, endNode, label, consists, tree.depth());
return annotation;
}
示例3: satisfies
import edu.stanford.nlp.trees.Trees; //导入方法依赖的package包/类
@Override
boolean satisfies(Tree t1, Tree t2, Tree root) {
return Trees.rightEdge(t1, root) <= Trees.leftEdge(t2, root);
}