我想通過下面的代碼使用斯坦福POS惡搞在NLTK爲「不是有效的Win32應用程序」:運行在NLTK斯坦福POS惡搞導致在Windows
import nltk
from nltk.tag.stanford import POSTagger
st = POSTagger('E:\Assistant\models\english-bidirectional-distsim.tagger',
'E:\Assistant\stanford-postagger.jar')
st.tag('What is the airspeed of an unladen swallow?'.split())
這裏是輸出:
Traceback (most recent call last):
File "E:\J2EE\eclipse\WSNLP\nlp\src\tagger.py", line 5, in <module>
st.tag('What is the airspeed of an unladen swallow?'.split())
File "C:\Python34\lib\site-packages\nltk\tag\stanford.py", line 59, in tag
return self.tag_sents([tokens])[0]
File "C:\Python34\lib\site-packages\nltk\tag\stanford.py", line 81, in tag_sents
stdout=PIPE, stderr=PIPE)
File "C:\Python34\lib\site-packages\nltk\internals.py", line 153, in java
p = subprocess.Popen(cmd, stdin=stdin, stdout=stdout, stderr=stderr)
File "C:\Python34\lib\subprocess.py", line 858, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
PS我的java主頁已設置,我沒有問題,我的Java安裝。有人可以解釋這個錯誤在說什麼嗎?這對我沒有幫助。提前致謝。
你可以從命令行運行Java嗎?如果沒有,請先解決。 – tripleee 2014-10-30 07:45:33
我可以在命令行中運行java。即使我添加了stanford jar的環境變量到我的java家中。還有其他的可能嗎? – Mohammadreza 2014-10-31 04:17:17
關於這個問題的任何想法? – Mohammadreza 2014-11-01 03:48:52