小编Tom*_*wik的帖子

NLTK 的问题,搭配:解包的值太多(预期为 2)

我试图用 NLTK 检索搭配,但出现错误。我使用了内置的古腾堡语料库

我写:

alice = nltk.corpus.gutenberg.fileids()[7]
al = nltk.corpus.gutenberg.words(alice)
al_text = nltk.Text(al)
al_text.collocations(25)
Run Code Online (Sandbox Code Playgroud)

我有:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-a6905d575410> in <module>
----> 1 al_text.collocations(25)

C:\ProgramData\Anaconda3\lib\site-packages\nltk\text.py in collocations(self, num, window_size)
    442 
    443         collocation_strings = [
--> 444             w1 + " " + w2 for w1, w2 in self.collocation_list(num, window_size)
    445         ]
    446         print(tokenwrap(collocation_strings, separator="; "))

C:\ProgramData\Anaconda3\lib\site-packages\nltk\text.py in <listcomp>(.0)
    442 
    443         collocation_strings = [
--> 444             w1 + " " + w2 for w1, w2 in self.collocation_list(num, window_size) …
Run Code Online (Sandbox Code Playgroud)

python nltk

7
推荐指数
0
解决办法
1310
查看次数

标签 统计

nltk ×1

python ×1