gpt4 book ai didi

nltk pos_tag 用法

转载 作者:行者123 更新时间:2023-12-04 07:05:03 30 4
gpt4 key购买 nike

我正在尝试在 NLTK 中使用语音标记并使用了以下命令:

>>> text = nltk.word_tokenize("And now for something completely different")

>>> nltk.pos_tag(text)

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
nltk.pos_tag(text)
File "C:\Python27\lib\site-packages\nltk\tag\__init__.py", line 99, in pos_tag
tagger = load(_POS_TAGGER)
File "C:\Python27\lib\site-packages\nltk\data.py", line 605, in load
resource_val = pickle.load(_open(resource_url))
File "C:\Python27\lib\site-packages\nltk\data.py", line 686, in _open
return find(path).open()
File "C:\Python27\lib\site-packages\nltk\data.py", line 467, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found. Please use the NLTK Downloader to obtain the resource:

但是,我收到一条错误消息,其中显示:
engish.pickle not found.

我已经下载了整个语料库,并且 english.pickle 文件在 maxtent_treebank_pos_tagger 中

我该怎么做才能让它发挥作用?

最佳答案

您的 Python 安装无法访问 maxent 或 treemap。

首先,检查标记器是否确实存在:
从命令行启动 Python。
>>> import nltk
然后你可以检查使用
>>> dir (nltk)
查看列表以查看是否 maxenttreebank都在那里。

更容易打字

>>> "maxent" in dir(nltk)
>>> True
>>> "treebank" in dir(nltk)
>>> True

使用 nltk.download() --> 模型选项卡并检查树状图标记器是否显示为已安装。
您还应该尝试再次下载标记器。

NLTK Downloader, Models Tab

关于nltk pos_tag 用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14089887/

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