我已按照https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software,Stanford Parser and NLTK,enter link description here中的所有说明操作。但仍然有一些错误。
这是我的代码:
import os
from nltk.parse import stanford
java_path = 'C:\\Program Files\\Java\\jdk1.8.0_65\\bin\\java.exe'
os.environ['JAVAHOME'] = java_path
os.environ['STANFORD_PARSER'] = 'C:/Users/stanford/stanford/stanford-parser.jar'
os.environ['STANFORD_MODELS'] = 'C:/Users/stanford/stanford/stanford-parser-3.6.0-models.jar'
parser = stanford.StanfordParser(model_path="C:/Users/englishPCFG.ser.gz")
sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?"))
print sentences
# GUI
for line in sentences:
for sentence in line:
sentence.draw()
收到错误:
raise OSError('Java command failed : ' + str(cmd))
OSError: Java command failed :
我已经更新了nltk,安装了所有stanford解析器jar文件。我使用的是python 2.7,windows 7。