2017-03-13 8 views
0

저는 Stanford POS Tagger를 Python으로 사용하려고합니다. Python NLTK pos_tag not returning the correct part-of-speech tagStanford POS Tagger를 가져 오는 방법

다음과 같은 오류 받기 :

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "U:\Python35\site-packages\nltk\tag\stanford.py", line 136, in __init__ 
    super(StanfordPOSTagger, self).__init__(*args, **kwargs) 
TypeError: __init__() got an unexpected keyword argument 'path_to_model' 

내가 변경해야을

home = 'U:/ManWin/My Documents/Research Project' 
from nltk.tag.stanford import StanfordPOSTagger as POS_Tag 
_path_to_model = home + '/stanford-postagger/models/english-bidirectional-distsim.tagger' 
_path_to_jar = home + '/stanford-postagger/stanford-postagger.jar' 
st = POS_Tag(path_to_model=_path_to_model, path_to_jar=_path_to_jar) 

여기에 대한 대답에서 마지막 줄을 복사 한 적이 있습니까?

+0

보인다. 링크 된 질문에 대한 대답에 따르면, 가져 오기 라인은 다음과 같습니다 :'from nltk.tag.stanford import POSTagger'. 대신 StanordPOSTagger라는 것을 가져오고 있습니다. –

답변

1

path_to_model의 이름이 model_filename으로 변경되었습니다. 그래서, 함께 마지막 줄을 바꿉니다

st = POS_Tag(model_filename=_path_to_model, path_to_jar=_path_to_jar)

또는 매개 변수가 순서에 있기 때문에, 단지 쓰기 : 당신이 여기에 잘못된 클래스를 인스턴스화하는 것처럼

st = POS_Tag(_path_to_model, _path_to_jar)

+0

완벽한 - 고마워요! – user3058703