Search code examples
nlpnltkchunks

How can I save the result of nltk.chunk.ne_chunk as a list?


How can I save the result of the function nltk.chunk.ne_chunk(tagged) into a list?


Solution

  • Perhaps you are after this:

    result = list(nltk.chunk.ne_chunk(tagged))
    

    The recognizer returns a “generator”, from which you could fetch output a little at a time (great with a huge dataset), or collect all the output by turning it into a list as above.