nltk: OSError: Java command failed when using stanford parser example
Hi,
I am trying to run the stanford parser example. E.g.
from nltk.parse.stanford import *
dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
[parse.tree() for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")]
executing the last command results with an error:
OSError: Java command failed : [u'/usr/bin/java', u'-mx1000m', '-cp', ....
when I reproduce the same command on the command line, I get the error Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
Therefore, after adding slf4j-api.jar
to the classpath on the commandline, parsing is successful.
How can slf4j-api.jar
be added to nltk classpath, so parsing will be successful?
Thank you! Happy holidays
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (7 by maintainers)
what is ‘st’ in the command ‘stanford_dir = st._stanford_jar.rpartition(’/‘)[0]’
@yuvval Just to be sure are you using Stanford Parser version 2015-12-09? If so, this error occurs because of the new StanfordNLP using more dependencies than before. This is similar to #1237
You would have to wait for a while before #1237 is fixed and NLTK catches up with Standford tools.
The quick fix solution is to either: