2017-02-16 27 views
-1

我可以直接找NMOD:從NMOD:的的Java代碼增強++依賴呢?斯坦福CoreNLP:增強++依賴性識別在Java中

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

你想用這種方法在edu.stanford.nlp.trees.UniversalEnglishGrammaticalRelations:

public static GrammaticalRelation getNmod(String prepositionString) 

,並提供你想要的介詞。