Search code examples
pythonnlpnltkchunking

Chunking with nltk


How can I obtain all the chunk from a sentence given a pattern. Exemple

NP:{<NN><NN>}

Sentence tagged:

[("money", "NN"), ("market", "NN") ("fund", "NN")]

If I parse I obtain

(S (NP money/NN market/NN) fund/NN)

I would like to have also the other alternative that is

(S money/NN (NP market/NN fund/NN))

Solution

  • I think your question is about getting the n most likely parses of a sentence. Am I right? If yes, see the nbest_parse(sent, n=None) function in the 2.0 documentation.