本文整理汇总了Java中edu.uw.easysrl.syntax.grammar.SyntaxTreeNode.getEndIndex方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxTreeNode.getEndIndex方法的具体用法?Java SyntaxTreeNode.getEndIndex怎么用?Java SyntaxTreeNode.getEndIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.syntax.grammar.SyntaxTreeNode
的用法示例。
在下文中一共展示了SyntaxTreeNode.getEndIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParent
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
/**
* Tries to get the parent of a node in a tree.
* Assumes the given node is in the given tree. If not, it will probably return empty, maybe... but maybe not.
* Returns empty if the node is just the whole tree.
*/
public static Optional<SyntaxTreeNode> getParent(SyntaxTreeNode node, SyntaxTreeNode wholeTree) {
int nodeStart = node.getStartIndex();
int nodeEnd = node.getEndIndex();
Optional<SyntaxTreeNode> curCandidate = Optional.of(wholeTree);
Optional<SyntaxTreeNode> lastCandidate = Optional.empty();
while(curCandidate.isPresent() && curCandidate.get() != node) {
lastCandidate = curCandidate;
curCandidate = curCandidate.get().getChildren().stream().filter(child -> {
int childStart = child.getStartIndex();
int childEnd = child.getEndIndex();
return (childStart <= nodeStart) && (childEnd >= nodeEnd);
}).findFirst();
}
return lastCandidate;
}
示例2: getArgumentConstituent
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private SyntaxTreeNode getArgumentConstituent(final SyntaxTreeNode node, final int head, final int excludeIndex) {
final boolean exclude = excludeIndex >= node.getStartIndex() && excludeIndex < node.getEndIndex();
if (!exclude && node.getDependencyStructure().getArbitraryHead() == head) {
return node;
}
for (final SyntaxTreeNode child : node.getChildren()) {
final SyntaxTreeNode result = getArgumentConstituent(child, head, excludeIndex);
if (result != null) {
return result;
}
}
return null;
}
示例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()
&& CollectionUtil.zip(parse1.getChildren().stream(), parse2.getChildren().stream(), SyntaxUtil::parsesEqual).allMatch(Boolean::booleanValue);
}
示例4: getContainedDependencies
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
/**
* Gets all of the dependencies that start and end inside the syntax tree rooted at the given node
*/
public static ImmutableSet<ResolvedDependency> getContainedDependencies(SyntaxTreeNode node, Parse parse) {
final int minIndex = node.getStartIndex();
final int maxIndex = node.getEndIndex();
return parse.dependencies.stream()
.filter(dep -> dep.getHead() >= minIndex && dep.getHead() < maxIndex &&
dep.getArgument() >= minIndex && dep.getArgument() <= maxIndex)
.collect(toImmutableSet());
}
示例5: 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);
}
示例6: isIndexInSpan
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
public static boolean isIndexInSpan(final int i, final SyntaxTreeNode node) {
return i >= node.getStartIndex() && i < node.getEndIndex();
}