Can someone tell me how to extract only nouns from the following output:
I signed and analyzed the “Give me a movie review” line based on this grammar using the following procedure: -
sent=nltk.word_tokenize(msg) parser=nltk.ChartParser(grammar) trees=parser.nbest_parse(sent) for tree in trees: print tree tokens=find_all_NP(tree) tokens1=nltk.word_tokenize(tokens[0]) print tokens1
and got the following result:
>>> (S (VP (V Give) (Det me)) (NP (Det the) (N review) (PP (P of) (N movie)))) (S (VP (V Give) (Det me)) (NP (Det the) (N review) (NP (PP (P of) (N movie))))) ['the', 'review', 'of', 'movie'] >>>
Now I would like to get only nouns. How to do it?
python django nlp
Amanda
source share