1

I am trying to put in my collocation results into a variable.

I am able to do this

print(corpus.collocations()) 

and get the output on the console...

but when I do

my_results = corpus.collocations()
print(type(corpus.collocations()))

I get the output as

<class 'NoneType'>
Kumar
  • 1,017
  • 1
  • 11
  • 16
  • 1
    I'm not familiar with this module, but perhaps this function `collocations()` is printing its results instead of returning them? – TerryA Jan 06 '16 at 01:22
  • 2
    I think that the problem is that `collocations()` prints to screen, rather than returns. You might benefit from [this question I asked a while ago](http://stackoverflow.com/q/14422797/198633) – inspectorG4dget Jan 06 '16 at 01:25

1 Answers1

1

Use collocation_list() instead of collocations().

In your case -

myresults = corpus.collocations_list()

myresults has a a list of tuples. The tuples consists of consecutive words for all collocations