本文整理汇总了Java中edu.uw.easysrl.syntax.grammar.SyntaxTreeNode.getLeaves方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxTreeNode.getLeaves方法的具体用法?Java SyntaxTreeNode.getLeaves怎么用?Java SyntaxTreeNode.getLeaves使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.syntax.grammar.SyntaxTreeNode
的用法示例。
在下文中一共展示了SyntaxTreeNode.getLeaves方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: printParse
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
@Override
protected void printParse(final SyntaxTreeNode parse, final int sentenceNumber, final StringBuilder result) {
final Table table = new Table();
final Tr leafRow = new Tr();
table.appendChild(leafRow);
for (final SyntaxTreeNodeLeaf leaf : parse.getLeaves()) {
leafRow.appendChild(makeTokenCell(leaf));
}
for (final List<SyntaxTreeNode> row : getRows(parse)) {
final Tr lineRow = new Tr();
final Tr categoryRow = new Tr();
table.appendChild(lineRow);
table.appendChild(categoryRow);
int indent = 0;
while (indent < row.size()) {
final SyntaxTreeNode cell = row.get(indent);
if (cell == null) {
lineRow.appendChild(makeEmptyCell());
categoryRow.appendChild(makeEmptyCell());
indent = indent + 1;
} else {
double cellGate = gateVisitor != null ? gateVisitor.getGateMap().get(cell) : 0.0;
final int width = getWidth(cell);
lineRow.appendChild(makeLineCell(width));
categoryRow.appendChild(makeCategoryCell(cell, cellGate, width));
indent = indent + width;
}
}
}
result.append(table.write());
result.append(new Br().write());
result.append(new Br().write());
result.append(new Br().write());
}
示例3: CCGandSRLparse
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private CCGandSRLparse(final SyntaxTreeNode ccgParse, final Collection<ResolvedDependency> dependencyParse,
final List<InputWord> words) {
super();
this.ccgParse = ccgParse;
this.dependencyParse = dependencyParse;
this.words = words;
for (final ResolvedDependency dep : dependencyParse) {
headToArgNumberToDependency.put(dep.getHead(), dep.getArgNumber(), dep);
}
this.leaves = ccgParse.getLeaves();
}
示例4: makeDictFromParses
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
public static Map<String, Collection<Category>> makeDictFromParses(final Iterator<SyntaxTreeNode> input) {
final Multiset<String> wordCounts = HashMultiset.create();
final Map<String, Multiset<Category>> wordToCatToCount = new HashMap<>();
int sentenceCount = 0;
// First, count how many times each word occurs with each category
while (input.hasNext()) {
final SyntaxTreeNode sentence = input.next();
final List<SyntaxTreeNodeLeaf> leaves = sentence.getLeaves();
for (int i = 0; i < leaves.size(); i++) {
final String word = leaves.get(i).getWord();
final Category cat = leaves.get(i).getCategory();
wordCounts.add(word);
if (!wordToCatToCount.containsKey(word)) {
final Multiset<Category> tmp = HashMultiset.create();
wordToCatToCount.put(word, tmp);
}
wordToCatToCount.get(word).add(cat);
}
sentenceCount++;
if (sentenceCount % 100 == 0) {
System.out.println(sentenceCount);
}
}
return makeDict(wordCounts, wordToCatToCount);
}