當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。