本文整理汇总了Java中edu.uw.easysrl.syntax.grammar.SyntaxTreeNode.getCategory方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxTreeNode.getCategory方法的具体用法?Java SyntaxTreeNode.getCategory怎么用?Java SyntaxTreeNode.getCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.syntax.grammar.SyntaxTreeNode
的用法示例。
在下文中一共展示了SyntaxTreeNode.getCategory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
@Override
public void visit(final SyntaxTreeNodeBinary node) {
node.getChild(0).accept(this);
final SyntaxTreeNode left = stack.pop();
node.getChild(1).accept(this);
final SyntaxTreeNode right = stack.pop();
final Collection<RuleProduction> rules = Combinator.getRules(left.getCategory(), right.getCategory(),
Combinator.STANDARD_COMBINATORS);
for (final RuleProduction rule : rules) {
if (rule.getCategory().equals(node.getCategory())) {
final List<UnlabelledDependency> resolvedDeps = new ArrayList<>();
final DependencyStructure newDeps = rule.getCombinator().apply(left.getDependencyStructure(),
right.getDependencyStructure(), resolvedDeps);
final SyntaxTreeNode result = new SyntaxTreeNodeBinary(node.getCategory(), left, right,
rule.getRuleType(), rule.isHeadIsLeft(), newDeps, resolvedDeps);
deps.addAll(resolvedDeps);
stack.push(result);
return;
}
}
throw new IllegalStateException("Didn't find matching binary rule: " + left.getCategory() + " + "
+ right.getCategory() + " --> " + node.getCategory());
}
示例2: parsesEqual
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
public static boolean parsesEqual(final SyntaxTreeNode parse1, final SyntaxTreeNode parse2) {
return parse1.getStartIndex() == parse2.getStartIndex()
&& parse1.getEndIndex() == parse2.getEndIndex()
&& parse1.getCategory() == parse2.getCategory()
&& parse1.getRuleType().ordinal() == parse2.getRuleType().ordinal()
&& parse1.getChildren().size() == parse2.getChildren().size()
&& CollectionUtil.zip(parse1.getChildren().stream(), parse2.getChildren().stream(), SyntaxUtil::parsesEqual).allMatch(Boolean::booleanValue);
}
示例3: parsesEqual
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
public static boolean parsesEqual(final SyntaxTreeNode parse1, final SyntaxTreeNode parse2) {
return parse1.getStartIndex() == parse2.getStartIndex()
&& parse1.getEndIndex() == parse2.getEndIndex()
&& parse1.getCategory() == parse2.getCategory()
&& parse1.getRuleType().ordinal() == parse2.getRuleType().ordinal()
&& parse1.getChildren().size() == parse2.getChildren().size()
&& Util.zip(parse1.getChildren().stream(), parse2.getChildren().stream(), SyntaxUtil::parsesEqual)
.allMatch(Boolean::booleanValue);
}
示例4: isMultiWordExpression
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
@Override
public boolean isMultiWordExpression(final SyntaxTreeNode node) {
if (node.getLeaves().stream().allMatch(x -> x.getPos().startsWith("NNP"))) {
// Analyze "Barack Obama" as barack_obama, not #x.barack(x)&obama(x)
return true;
} else if (node.getCategory() == Category.CONJ && node.getRuleType() != RuleType.LP
&& node.getRuleType() != RuleType.RP) {
// Don't bother trying to do multi-word conjunctions compositionally (e.g. "as well as").
return true;
}
return false;
}
示例5: isMultiWordExpression
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
@Override
public boolean isMultiWordExpression(final SyntaxTreeNode node) {
return node.getCategory() == Category.ADJECTIVE
&& node.getLeaves().stream().allMatch(x -> x.getPos().startsWith("CD"));
}