I have a text which I want to extract the noun phrases from it. I can easily get the typed parser for the text that i have, but wondering how i can extract the noun phrases in the text ?
You can extract noun phrases from Tree by using following code. It assumes you have parsed sentence stored in parse (i.e. parse is output of LexicalizedParser class apply method)
public static List<Tree> GetNounPhrases()
{
List<Tree> phraseList=new ArrayList<Tree>();
for (Tree subtree: parse)
{
if(subtree.label().value().equals("NP"))
{
phraseList.add(subtree);
System.out.println(subtree);
}
}
return phraseList;
}