我正在关注NLTK教程,而在本书展示了另一个结果的同时,我在Python交互式外壳程序中遇到了此错误。任何想法如何解决这个问题?
>>> import nltk
>>> nltk.corpus.gutenberg.files()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'PlaintextCorpusReader' object has no attribute 'files'
该教程已有6年的历史,因此它使用的是旧版本NLTK
。nltk.corpus.gutenberg.fileids()
将为您提供所需的结果。
In [22]: nltk.corpus.gutenberg.fileids()
Out[22]:
['austen-emma.txt',
'austen-persuasion.txt',
'austen-sense.txt',
'bible-kjv.txt',
'blake-poems.txt',
'bryant-stories.txt',
'burgess-busterbrown.txt',
'carroll-alice.txt',
'chesterton-ball.txt',
'chesterton-brown.txt',
'chesterton-thursday.txt',
'edgeworth-parents.txt',
'melville-moby_dick.txt',
'milton-paradise.txt',
'shakespeare-caesar.txt',
'shakespeare-hamlet.txt',
'shakespeare-macbeth.txt',
'whitman-leaves.txt']
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句