nltk pos_tag的用法 [英] nltk pos_tag usage

查看:899
本文介绍了nltk pos_tag的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use speech tagging in NLTK and have used this command:

>>> 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:

但是,我收到一条错误消息,显示:

However, I get an error message which shows:

engish.pickle not found.

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

I have download the whole corpora and the english.pickle file is there in the maxtent_treebank_pos_tagger

我该怎么做才能使它正常工作?

What can I do to get this to work?

推荐答案

您的Python安装无法达到maxent或treemap.

Your Python installation is not able to reach maxent or treemap.

首先,检查标记器是否确实存在: 从命令行启动Python.

First, check if the tagger is indeed there: Start Python from the command line.

>>> import nltk

然后您可以使用

>>> dir (nltk)

浏览列表以查看maxenttreebank是否都在其中.

Look through the list to see if maxent and treebank are both there.

更容易键入

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

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

Use nltk.download() --> Models tab and check to see if the treemap tagger shows as installed. You should also try downloading the tagger again.

这篇关于nltk pos_tag的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆