2012-06-15 3 views
1

매개 변수.JVM으로 인해 작동하지 NLTK에서 스탠포드 늘어진 장식을 붙이는 첫 번째 라인이 제대로 작동</p> <pre><code>st = StanfordTagger('bidirectional-distsim-wsj-0-18.tagger') st.tag('What is the airspeed of an unladen swallow ?'.split()) </code></pre> <p>예제 코드 다음 실행하지만, 두 번째 줄은 다음과 같은 오류를주고있다 동안 유선 오류가 오전

Could not create the Java virtual machine. 

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1- py2.6.egg/nltk/tag/stanford.py", line 51, in tag 
return self.batch_tag([tokens])[0] 
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/tag/stanford.py", line 77, in batch_tag 
stdout=PIPE, stderr=PIPE) 
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0.1rc1-py2.6.egg/nltk/internals.py", line 166, in java 
raise OSError('Java command failed!') 
OSError: Java command failed! 

내가 경로로 .USR/lib 디렉토리/JVM을 추가하지만 여전히 그것은 하나 나를 위해 작동하지 않는

답변

2

를 작동하지 않는 노력했다. 그래서 나는 다음과 그것의 작업을 완벽하게 시도했다.

st = POSTagger('path-to/stanford-postagger-full-2012-07-09/models/wsj-0-18-left3words.tagger','path-to/stanford-postagger-full-2012-07-09/stanford-postagger.jar') 

및 사용 NLTK의 토큰 화 방법 대신 파이썬의 분할()

taggedSentence= st.tag(nltk.word_tokenize(sentence))