how to get wanted nodes from Stanford Parser nlp
Posted
by
vitaly
on Stack Overflow
See other posts from Stack Overflow
or by vitaly
Published on 2011-01-07T19:13:02Z
Indexed on
2011/01/09
6:53 UTC
Read the original article
Hit count: 388
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();
© Stack Overflow or respective owner