gpt4 book ai didi

python - tagger = perceptron tagger() 回溯错误

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:02 37 4
gpt4 key购买 nike

from nltk.tag.perceptron import PerceptronTagger

tagger = PerceptronTagger()

def pos_tagging(X):
tagset = None
tokens = nltk.word_tokenize(X)
tags = nltk.tag._pos_tag(tokens, tagset, tagger)
pos_X = map(get_wordnet_pos, tags)
return pos_X

AI.py 是我的 python 文件

Traceback (most recent call last):

File "C:/Users/jpsamaranayake/PycharmProjects/AI/AI.py", line 206, in <module>

tagger = PerceptronTagger()

File "C:\Python27\lib\site-packages\nltk\tag\perceptron.py", line 141, in __init__
self.load(AP_MODEL_LOC)

File "C:\Python27\lib\site-packages\nltk\tag\perceptron.py", line 209, in load
self.model.weights, self.tagdict, self.classes = load(loc)

File "C:\Python27\lib\site-packages\nltk\data.py", line 801, in load
opened_resource = _open(resource_url)

File "C:\Python27\lib\site-packages\nltk\data.py", line 924, in _open
return urlopen(resource_url)

File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)

File "C:\Python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)

File "C:\Python27\lib\urllib2.py", line 454, in _open
'unknown_open', req)

File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)

File "C:\Python27\lib\urllib2.py", line 1265, in unknown_open
raise URLError('unknown url type: %s' % type)

urllib2.URLError: <urlopen error unknown url type: c>

最佳答案

将nltk版本更改为3.1并删除nltk.download()中之前的avareage perceptron tagger并重新安装

关于python - tagger = perceptron tagger() 回溯错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35795472/

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