i have some requirement that is getting meaningful words from parsed text using stanford nlp in java. i am trying following sample code.
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
public class Demo
{
public static void main(String args[])
{
LexicalizedParser lp = new LexicalizedParser("englishPCFG.ser");
lp.setOptionFlags(new String[]{"-maxLength", "80","-retainTmpSubcategories"});
String sent = "my name is arjun";
Tree parse = (Tree) lp.apply(sent);
List taggedWords = parse.taggedYield();
System.out.println(parse.toString());
}
}
output:
(ROOT (S (NP (PRP$ my) (NN name)) (VP (VBZ is) (ADJP (JJ arjun)))))
required output:
name,arjun.
how to do this.please suggest me.
thanks.