当前位置: 首页>>代码示例>>Java>>正文


Java Trees.rightEdge方法代码示例

本文整理汇总了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;
}
 
开发者ID:GateNLP,项目名称:gateplugin-Stanford_CoreNLP,代码行数:46,代码来源:Parser.java

示例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;
}
 
开发者ID:vita-us,项目名称:ViTA,代码行数:48,代码来源:Parser.java

示例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);
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:5,代码来源:Relation.java


注:本文中的edu.stanford.nlp.trees.Trees.rightEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。