我的代码:
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选项下载了所有可用的内容,但问题仍然存在。
我尽力在Internet中找到解决方案,但得到的解决方案与上述步骤中提到的解决方案相同。