1

I already follow all the instructions in https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software, Stanford Parser and NLTK, enter link description here. But still got some errors.

Here is my codes:

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()

Error received:

raise OSError('Java command failed : ' + str(cmd))

OSError: Java command failed :

I already updated nltk, installed all the stanford parser jar files. I use python 2.7, windows 7.

Community
  • 1
  • 1
lulu
  • 173
  • 1
  • 10
  • As far as I understand from links you provided, `STANFORD_PARSER` and `STANFORD_MODELS` should point to directory with `.jar` files, in your case `'C:/Users/stanford/stanford'`. Have you tried this? – merletta Dec 25 '15 at 09:47
  • Yes. but i still received the same error. – lulu Dec 25 '15 at 09:58

0 Answers0