List of usage examples for edu.stanford.nlp.trees SemanticHeadFinder SemanticHeadFinder
public SemanticHeadFinder(boolean noCopulaHead)
From source file:ipgraph.datastructure.DTree.java
License:Open Source License
/** ************************************************************** * Build dependency-tree from a plain sentence *//* w w w. jav a 2 s . c o m*/ public static DTree buildTree(String s) { StanfordPCFGParser pcfgParser = new StanfordPCFGParser("", false); Tree tree = pcfgParser.getLexicalizedParser().parse(s); SemanticHeadFinder headFinder = new SemanticHeadFinder(false); // keep copula verbs as head GrammaticalStructure egs = new EnglishGrammaticalStructure(tree, string -> true, headFinder, true); // notes: typedDependencies() is suggested String conllx = EnglishGrammaticalStructure.dependenciesToString(egs, egs.typedDependencies(), tree, true, true); DTree dtree = LangTools.getDTreeFromCoNLLXString(conllx, true); return dtree; }