本文整理汇总了Java中edu.uw.easysrl.syntax.grammar.SyntaxTreeNode.getAllLabelledDependencies方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxTreeNode.getAllLabelledDependencies方法的具体用法?Java SyntaxTreeNode.getAllLabelledDependencies怎么用?Java SyntaxTreeNode.getAllLabelledDependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.syntax.grammar.SyntaxTreeNode
的用法示例。
在下文中一共展示了SyntaxTreeNode.getAllLabelledDependencies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printParse
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
@Override
protected void printParse(final SyntaxTreeNode parse, final int sentenceNumber, final StringBuilder result) {
final List<List<ResolvedDependency>> labels = new ArrayList<>();
for (final SyntaxTreeNodeLeaf leaf : parse.getLeaves()) {
labels.add(new ArrayList<>(leaf.getCategory().getNumberOfArguments()));
for (int i = 0; i < leaf.getCategory().getNumberOfArguments(); i++) {
labels.get(labels.size() - 1).add(null); // TODO
}
}
for (final ResolvedDependency dep : parse.getAllLabelledDependencies()) {
final List<ResolvedDependency> labelsForWord = labels.get(dep.getHead());
if (dep.getArgumentIndex() > -1) {
labelsForWord.set(dep.getArgNumber() - 1, dep);
}
}
Preconditions.checkState(parse.getSemantics().isPresent());
result.append(parse.getSemantics().get());
Util.debugHook();
}
示例2: getPredicate
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private String getPredicate(final SyntaxTreeNode parse, final int index) {
final SyntaxTreeNodeLeaf node = parse.getLeaves().get(index);
final StringBuilder result = new StringBuilder();
result.append(MorphaStemmer.stemToken(node.getWord()));
final Category category = node.getCategory();
final List<Integer> indices = new ArrayList<>();
indices.add(index);
// Add particles if necessary. e.g. give_up, take_off
for (int i = 1; i <= category.getNumberOfArguments(); i++) {
if (category.getArgument(i) == Category.PR) {
for (final ResolvedDependency dep : parse.getAllLabelledDependencies()) {
if (dep.getHead() == index && dep.getArgNumber() == i) {
final String particle = parse.getLeaves().get(dep.getArgumentIndex()).getWord();
indices.add(dep.getArgumentIndex());
result.append("_");
result.append(particle);
break;
}
}
}
}
if (includeWordIndices) {
result.append("@");
for (int i = 0; i < indices.size(); i++) {
if (i > 0) {
result.append(",");
}
result.append(indices.get(i));
}
}
return result.toString();
}