Stanford CoreNLP:Java中增强的++依赖关系识别

时间:2017-02-16 22:57:10

标签: java stanford-nlp

我可以直接在 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;
}

1 个答案:

答案 0 :(得分:1)

您想在edu.stanford.nlp.trees.UniversalEnglishGrammaticalRelations:

中使用此方法
public static GrammaticalRelation getNmod(String prepositionString)

并提供你想要的介词。