1

I have to save the bigram collocations as a list in a variable but unable to do it with collocation(). I need to later return the variable from a function.

  • 1
    Provide please some short, reproducible code example. It will be easier for all to help you then. – dankal444 Sep 03 '20 at 09:20
  • I am actually using a=nltk.Text(tokenizedwords).collocations() but it ends up printing instead of getting stored in a as a list. What can I do? – Suchetha Suresh Sep 03 '20 at 20:33

1 Answers1

1

Try collocation_list() instead, collocations() is printing as it was designed to.

a=nltk.Text(tokenizedwords).collocation_list()

Sources:

dankal444
  • 3,172
  • 1
  • 23
  • 35