gpt4 book ai didi

python - 找不到资源 u'tokenizers/punkt/english.pickle'

转载 作者:IT老高 更新时间:2023-10-28 21:09:48 30 4
gpt4 key购买 nike

我的代码:

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 loader 和 l-list 选项下载了所有可用的东西,但问题仍然存在。

我尽力在互联网上找到解决方案,但我得到的解决方案与我在上述步骤中提到的相同。

最佳答案

添加到 alvas' answer ,您只能下载 punkt 语料库:

nltk.download('punkt')

下载 all 对我来说听起来有点矫枉过正。除非那是你想要的。

关于python - 找不到资源 u'tokenizers/punkt/english.pickle',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26570944/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com