2016-06-06 4 views
1

내 코드에서 nltk.pos_tag를 사용하려고했지만 이렇게하면 오류가 발생합니다. 나는 이미 Penn treebank와 max_ent_treebank_pos를 다운로드했다. 그러나 오류는 계속 발생합니다. 여기에 내 코드 :nltk.post_tag를 사용하는 중 오류가 발생했습니다.

import nltk 
from nltk import tag 
from nltk import* 



a = "Alan Shearer is the first player to score over a hundred Premier League goals." 
a_sentences = nltk.sent_tokenize(a) 
a_words  = [nltk.word_tokenize(sentence) for sentence in a_sentences] 
a_pos  = [nltk.pos_tag(sentence) for sentence in a_words] 
print(a_pos) 

이것은 내가 오류입니다 : 파이썬에서

"Traceback (most recent call last): 
    File "<pyshell#9>", line 1, in <module> 
    print (nltk.pos_tag(text)) 
    File "C:\Python34\lib\site-packages\nltk\tag\__init__.py", line 110, in pos_tag 
tagger = PerceptronTagger() 
File "C:\Python34\lib\site-packages\nltk\tag\perceptron.py", line 140, in __init__ 
AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE)) 
File "C:\Python34\lib\site-packages\nltk\data.py", line 641, in find 
raise LookupError(resource_not_found) 
LookupError: 

Resource 'taggers/averaged_perceptron_tagger/averaged_perceptron 
_tagger.pickle' not found. Please use the NLTK Downloader to 
obtain the resource: >>> nltk.download() 
Searched in: 
    - 'C:\\Users\\T01142/nltk_data' 
    - 'C:\\nltk_data' 
    - 'D:\\nltk_data' 
    - 'E:\\nltk_data' 
    - 'C:\\Python34\\nltk_data' 
    - 'C:\\Python34\\lib\\nltk_data' 
    - 'C:\\Users\\T01142\\AppData\\Roaming\\nltk_data' 
+0

[다음을 사용하여 POS 태깅을하는 방법 NLTK POS tagger in Python?] (http://stackoverflow.com/questions/8590370/how-to-do-pos-tagging-using-the-nltk-pos-tagger-in-python) – alvas

+0

http : //를 참조하십시오. stackoverflow.com/a/37651321/610569 – alvas

+2

감사! :)하지만 nltk 다운로더에서 'averaged_perceptron_tagger'를 다운로드하여 얻었습니다. – aqua

답변

1

콜이 :

nltk.download ('averaged_perceptron_tagger')