本文整理汇总了Java中edu.uw.easysrl.syntax.grammar.SyntaxTreeNode.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java SyntaxTreeNode.getChildren方法的具体用法?Java SyntaxTreeNode.getChildren怎么用?Java SyntaxTreeNode.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.syntax.grammar.SyntaxTreeNode
的用法示例。
在下文中一共展示了SyntaxTreeNode.getChildren方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRows
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private int getRows(final SyntaxTreeNode node, final List<List<SyntaxTreeNode>> rows,
final int minIndentation) {
int maxChildLevel = 0;
int i = minIndentation;
for (final SyntaxTreeNode child : node.getChildren()) {
maxChildLevel = Math.max(getRows(child, rows, i), maxChildLevel);
i = i + getWidth(child);
}
int level;
if (node.getChildren().size() > 0) {
level = maxChildLevel + 1;
} else {
level = 0;
}
while (rows.size() < level + 1) {
rows.add(new ArrayList<>());
}
while (rows.get(level).size() < minIndentation + 1) {
rows.get(level).add(null);
}
rows.get(level).set(minIndentation, node);
return level;
}
示例2: getRows
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private static int getRows(SyntaxTreeNode node,
List<List<SyntaxTreeNode>> result, int minIndentation) {
if (node.getDependenciesLabelledAtThisNode().size() > 0) {
return getRows(node.getChild(0), result, minIndentation);
}
int maxChildLevel = 0;
int i = minIndentation;
for (final SyntaxTreeNode child : node.getChildren()) {
maxChildLevel = Math.max(getRows(child, result, i), maxChildLevel);
i = i + getWidth(child);
}
final int level = node.getChildren().isEmpty() ? 0 : maxChildLevel + 1;
while (result.size() < level + 1) {
result.add(new ArrayList<SyntaxTreeNode>());
}
while (result.get(level).size() < minIndentation + 1) {
result.get(level).add(null);
}
result.get(level).set(minIndentation, node);
return level;
}
示例3: 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;
}
示例4: updateNode
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private boolean updateNode(final List<SyntaxTreeNodeLeaf> result, final SyntaxTreeNode node) {
boolean change = false;
if (node.getChildren().size() == 2 && isVPtoAdverb(node.getChild(1))
) {
if (node.getChild(1).getLeaves().get(0).getCategory().equals(Category.valueOf("(S[to]\\NP)/(S[b]\\NP)"))) {
// He retired (to spend time with family)
setCategory(result, node.getChild(1).getLeaves().get(0).getHeadIndex(),
Category.valueOf("((S\\NP)\\(S\\NP))/(S[b]\\NP)"));
change = true;
}
}
for (final SyntaxTreeNode child : node.getChildren()) {
change = change || updateNode(result, child);
}
return change;
}
示例5: getHash
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
private int getHash(final SyntaxTreeNode parse) {
Integer result = nodeToHash.get(parse);
if (result == null) {
result = 0;
// Add in a hash for each dependency at this node.
final List<UnlabelledDependency> resolvedUnlabelledDependencies = parse
.getResolvedUnlabelledDependencies();
if (resolvedUnlabelledDependencies != null) {
for (final UnlabelledDependency dep : resolvedUnlabelledDependencies) {
for (final int arg : dep.getArguments()) {
if (dep.getHead() != arg) {
result = result
^ categoryToArgumentToHeadToModifierToHash.get(dep.getCategory(),
dep.getArgNumber())[dep.getHead()][arg];
}
}
}
}
for (final SyntaxTreeNode child : parse.getChildren()) {
result = result ^ getHash(child);
}
}
return result;
}
示例6: extractDependencies
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
public static void extractDependencies(final SyntaxTreeNode parse, final Collection<UnlabelledDependency> deps) {
if (parse.getChildren().size() == 2) {
deps.addAll(parse.getResolvedUnlabelledDependencies());
}
for (final SyntaxTreeNode child : parse.getChildren()) {
extractDependencies(child, deps);
}
}
示例7: getWidth
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
int getWidth(final SyntaxTreeNode node) {
if (node.getChildren().size() == 0) {
return 1;
} else {
int result = 0;
for (final SyntaxTreeNode child : node.getChildren()) {
result = result + getWidth(child);
}
return result;
}
}
示例8: getRows
import edu.uw.easysrl.syntax.grammar.SyntaxTreeNode; //导入方法依赖的package包/类
int getRows(final SyntaxTreeNode node, final List<List<SyntaxTreeNode>> result, final int minIndentation) {
if (node.getDependenciesLabelledAtThisNode().size() > 0) {
return getRows(node.getChild(0), result, minIndentation);
}
int maxChildLevel = 0;
int i = minIndentation;
for (final SyntaxTreeNode child : node.getChildren()) {
maxChildLevel = Math.max(getRows(child, result, i), maxChildLevel);
i = i + getWidth(child);
}
int level;
if (node.getChildren().size() > 0) {
level = maxChildLevel + 1;
} else {
level = 0;
}
while (result.size() < level + 1) {
result.add(new ArrayList<SyntaxTreeNode>());
}
while (result.get(level).size() < minIndentation + 1) {
result.get(level).add(null);
}
result.get(level).set(minIndentation, node);
return level;
}