运行Stanford Dependency Parser时出错

时间:2015-12-25 07:25:27

标签: python windows parsing stanford-nlp

我已按照https://github.com/nltk/nltk/wiki/Installing-Third-Party-SoftwareStanford Parser and NLTKenter 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。

0 个答案:

没有答案