text.collocations() 出现 ValueError: too many values to unpack (expected 2)

Python 自然语言处理 P39

text4.collocations()
Traceback (most recent call last):

  File "<ipython-input-83-56fc6e5515a1>", line 1, in <module>
    text4.collocations()

  File "D:\Users\asus\Anaconda3\lib\site-packages\nltk\text.py", line 444, in collocations
    w1 + " " + w2 for w1, w2 in self.collocation_list(num, window_size)

  File "D:\Users\asus\Anaconda3\lib\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)

修改为

text4.collocation_list()
Out[84]: 
['United States',
 'fellow citizens',
 'four years',
 'years ago',
 'Federal Government',
 'General Government',
 'American people',
 'Vice President',
 'Old World',
 'Almighty God',
 'Fellow citizens',
 'Chief Magistrate',
 'Chief Justice',
 'God bless',
 'every citizen',
 'Indian tribes',
 'public debt',
 'one another',
 'foreign nations',
 'political parties']
发布了44 篇原创文章 · 获赞 0 · 访问量 1313

猜你喜欢

转载自blog.csdn.net/qq_41664688/article/details/104249869
今日推荐