本文整理汇总了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;
}
示例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;
}
示例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;
}