how to get wanted nodes from Stanford Parser nlp
- by vitaly
Hello all!
My mean problem is that I dont know how to extract nodes from GrammaticalStructure.
I am using englishPCFG.ser in java netbeans.
My target is o know the quality of the screen like:
the screen of iphone 4 is great.
I want to extract screen and great.
how can i extract the NN (screen) and VP (great)
the code that I wrote is:
LexicalizedParser lp = new LexicalizedParser("C:\\englishPCFG.ser");
lp.setOptionFlags(new String[]{"-maxLength", "80", "-retainTmpSubcategories"});
String sent ="the screen is very good.";
Tree parse = (Tree) lp.apply(Arrays.asList(sent));
parse.pennPrint();
System.out.println();
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
Collection tdl = gs.typedDependenciesCollapsed();