Search code examples
pythonnlpcollocation

List the collocations for a txt file


I want to list the collocations as reported by the NLTK for Dracula.txt. How do i do this? I am able to find word frequency by adding it to my corpus. I also have a variable DracWords dracWords = mycorpus.words('Dracula.txt') which has the words from the Dracula text. From this i can do Frequency Distributions, but what I want now is to list the collocations from it.

Any help is appreciated.


Solution

  • Thanks everyone. was able to get it with

    nltk.Text(mycorpus.words('Dracula.txt')).collocations()