我可以直接在 Java 代码中直接查找 nmod:from 和 nmod:of Enhanced ++ Dependencies?
semanticGraph.getChildrenWithReln(rootToken, UniversalEnglishGrammaticalRelations.NOMINAL_MODIFIER);
getChildrenWithReln
方法的第二个参数需要GrammaticalRelation
。不幸的是,我发现只有UniversalEnglishGrammaticalRelations.NOMINAL_MODIFIER
而不是UniversalEnglishGrammaticalRelations.NOMINAL_MODIFIER_FROM
。
我的临时解决方案:
public List<IndexedWord> getChildrenByRelation(IndexedWord root, String shortName, String specific) {
final List<SemanticGraphEdge> outputEdges = semanticGraphWrapper.get().getOutEdgesSorted(root);
final List<IndexedWord> tokens = new ArrayList<>();
GrammaticalRelation relation;
for (SemanticGraphEdge edge : outputEdges) {
relation = edge.getRelation();
if (relation.getShortName().equals(shortName) && relation.getSpecific().equals(specific))
tokens.add(edge.getTarget());
}
return tokens;
}
答案 0 :(得分:1)
您想在edu.stanford.nlp.trees.UniversalEnglishGrammaticalRelations:
public static GrammaticalRelation getNmod(String prepositionString)
并提供你想要的介词。