0

I followed instructions in the following link (which is for previous versions of NLTK): Stanford Parser and NLTK.

I got the following errors when I typed in: sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?")).

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-12-9af7b505d133>", line 1, in <module>
    sentences = parser.raw_parse_sents(('hello,my name is melroy.','what is your name?'))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/parse/stanford.py", line 150, in raw_parse_sents
    return self._parse_trees_output(self._execute(cmd, '\n'.join(sentences), verbose))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/parse/stanford.py", line 216, in _execute
    stdout=PIPE, stderr=PIPE)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/internals.py", line 134, in java
    raise OSError('Java command failed : ' + str(cmd))
OSError: Java command failed : [u'/usr/bin/java', u'-mx1000m', '-cp', '/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-models.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/ejml-0.23.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/slf4j-api.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/slf4j-simple.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-javadoc.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-models.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-sources.jar:/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser.jar', u'edu.stanford.nlp.parser.lexparser.LexicalizedParser', u'-model', '/Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-models/edu/stanford/nlp/models/lexparser', u'-sentences', u'newline', u'-outputFormat', u'penn', u'-encoding', u'utf8', '/var/folders/8j/ptm7g49n12g94wn8cn44frr40000gn/T/tmp7mHjA3']

Could anyone give an example (with step-by-step instruction) of how exactly is Stanford Parser configured and used with NLTK 3.6.0 (Python 2)? Thanks!

Community
  • 1
  • 1
user3373273
  • 61
  • 1
  • 3
  • 1
    Have you tried to execute that command manually? – user3159253 May 08 '16 at 07:18
  • can you be more specific? (i'm new to coding) – user3373273 May 08 '16 at 15:38
  • Well, you have the command `/usr/bin/java -mx1000m -cp /Users/su/Desktop/OJO/STANFORD_PARSE/stanford-parser-3.6.0-models.jar: -sentences newline -outputFormat penn -encoding utf8 /var/folders/8j/ptm7g49n12g94wn8cn44frr40000gn/T/tmp7mHjA3` which is executed by python, and failed. Have you tried to run this command manually? What results did it give? However I suppose that `var/folders/8j/ptm7g49n12g94wn8cn44frr40000gn/T/tmp7mHjA3` is a temporary folder for some intermediate data, so you should check if it really exists right now. – user3159253 May 08 '16 at 16:23
  • Did you install Java? – alvas May 09 '16 at 12:32

0 Answers0