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


Java Tree.dominates方法代码示例

本文整理汇总了Java中edu.stanford.nlp.trees.Tree.dominates方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.dominates方法的具体用法?Java Tree.dominates怎么用?Java Tree.dominates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.trees.Tree的用法示例。


在下文中一共展示了Tree.dominates方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eventRelationship

import edu.stanford.nlp.trees.Tree; //导入方法依赖的package包/类
/**
 * Checks if one event syntactically dominates the other.
 * @param tree The root of the parse tree
 * @param e1 The first event's word
 * @param e2 The second event's word
 * @returns 1 if no dominance, 2 if e1 dominates, or 3 if e2 dominates
 */
public static int eventRelationship(Tree tree, Tree tree1, Tree tree2) {
  if( tree1 != null && tree2 != null ) {
    // Find grandparent of event1, check dominance
    Tree p = tree1.parent(tree); // parent is POS tag
    Tree gp = p.parent(tree); // gp is actual parent
    if( gp.dominates(tree2) ) return Features.DOMINATES;

    // Find grandparent of event2, check dominance
    p = tree2.parent(tree);
    gp = p.parent(tree);
    if( gp.dominates(tree1) ) return Features.DOMINATED;
  }
  //	else System.out.println("WARNING: no tree1 or no tree2 (" + e1 + "," + e2 + ")");
  else System.out.println("WARNING: no tree1 or no tree2");

  return 1;
}
 
开发者ID:nchambers,项目名称:schemas,代码行数:25,代码来源:EventParser.java

示例2: eventRelationship

import edu.stanford.nlp.trees.Tree; //导入方法依赖的package包/类
/**
 * Checks if one event syntactically dominates the other.
 * @param tree The root of the parse tree
 * @param e1 The first event's word
 * @param e2 The second event's word
 * @returns 1 if no dominance, 2 if e1 dominates, or 3 if e2 dominates
 */
public int eventRelationship(Tree tree, Tree tree1, Tree tree2) {
  //	System.out.println("rel? " + e1 + " " + e2);
  //	Tree tree1 = (Tree)findEventInTree(tree, e1);
  //	Tree tree2 = (Tree)findEventInTree(tree, e2);

  if( tree1 != null && tree2 != null ) {
    // Find grandparent of event1, check dominance
    Tree p = tree1.parent(tree); // parent is POS tag
    Tree gp = p.parent(tree); // gp is actual parent
    if( gp.dominates(tree2) ) return Features.DOMINATES;

    // Find grandparent of event2, check dominance
    p = tree2.parent(tree);
    gp = p.parent(tree);
    if( gp.dominates(tree1) ) return Features.DOMINATED;
  }
  //	else System.out.println("WARNING: no tree1 or no tree2 (" + e1 + "," + e2 + ")");
  else System.out.println("WARNING: no tree1 or no tree2");

  return 1;
}
 
开发者ID:nchambers,项目名称:schemas,代码行数:29,代码来源:GigaEventParser.java

示例3: treeDominates

import edu.stanford.nlp.trees.Tree; //导入方法依赖的package包/类
/**
 * Checks if the first tree1 syntactically dominates the second tree2.
 * @param tree1 A subtree.
 * @param tree2 A subtree.
 * @param tree The full sentence's parse tree.
 * @returns True if the first tree dominates the second, false otherwise.
 */
private boolean treeDominates(Tree tree1, Tree tree2, Tree tree) {
  if( tree1 != null && tree2 != null ) {
    // Find parent tree of event1, check dominance
    Tree p = tree1.parent(tree); // parent is POS tag
    if( p.dominates(tree2) ) 
      return true;
  }
  else 
    System.out.println("WARNING: no tree1 or no tree2");
  return false;
}
 
开发者ID:nchambers,项目名称:schemas,代码行数:19,代码来源:TLinkFeaturizer.java


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