我的准则:
import nltk.data
tokenizer = nltk.data.load('nltk:tokenizers/punkt/english.pickle')
错误信息:
[ec2-user@ip-172-31-31-31 sentiment]$ python mapper_local_v1.0.py
Traceback (most recent call last):
File "mapper_local_v1.0.py", line 16, in <module>
tokenizer = nltk.data.load('nltk:tokenizers/punkt/english.pickle')
File "/usr/lib/python2.6/site-packages/nltk/data.py", line 774, in load
opened_resource = _open(resource_url)
File "/usr/lib/python2.6/site-packages/nltk/data.py", line 888, in _open
return find(path_, path + ['']).open()
File "/usr/lib/python2.6/site-packages/nltk/data.py", line 618, in find
raise LookupError(resource_not_found)
LookupError:
Resource u'tokenizers/punkt/english.pickle' not found. Please
use the NLTK Downloader to obtain the resource:
>>>nltk.download()
Searched in:
- '/home/ec2-user/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
- u''
我试着在 Unix 机器上运行这个程序:
根据错误消息,我从 unix 机器登录到 python shell,然后使用以下命令:
import nltk
nltk.download()
然后我使用 d-down 加载器和 l-list 选项下载了所有可用的内容,但问题仍然存在。
我尽最大努力在网上找到解决方案,但我得到了相同的解决方案,我做了我在上述步骤中提到。