I've had no issues with running the exercises in the book in IDLE up until this point; however, I keep receiving this ValueError with the collocations() function. Does anyone have any solution to this? Thanks!
>>>text4.collocations()
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
text4.collocations()
File "/Users/selinalkan/Library/Python/3.7/lib/python/site-packages/nltk/text.py", line 444, in collocations
w1 + " " + w2 for w1, w2 in self.collocation_list(num, window_size)
File "/Users/selinalkan/Library/Python/3.7/lib/python/site-packages/nltk/text.py", line 444, in <listcomp>
w1 + " " + w2 for w1, w2 in self.collocation_list(num, window_size)
ValueError: too many values to unpack (expected 2)```
This is a known bug. See NLTK issue #2299. You can work around it by using collocation_list() and then using a string join(). You can eliminate enclosing quotes on output with a print().
I've had no issues with running the exercises in the book in IDLE up until this point; however, I keep receiving this ValueError with the collocations() function. Does anyone have any solution to this? Thanks!