New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSError: Java command failed when using stanford parser example #1239
Comments
@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:
from nltk.internals import find_jars_within_path
from nltk.parse.stanford import StanfordDependencyParser
dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
stanford_dir = st._stanford_jar.rpartition('/')[0]
# or in windows comment the line above and uncomment the one below:
#stanford_dir = st._stanford_jar.rpartition("\\")[0]
stanford_jars = find_jars_within_path(stanford_dir)
st.stanford_jar = ':'.join(stanford_jars)
[parse.tree() for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")] |
Thank you! It works with the 2015-04-20 version. |
Did the classpath hack also work? |
I didn't try - I just deleted the latest version and downloaded the 2015-04-20 version. |
Hi! I tried to follow your hack but for me there is no `StanfordDependencyParser``:
Any idea how to solve this? I would really like to use the latest stanford version. |
@methodds Pardon my typo, it's |
Thank you for the link. Unfortunately, I can't get the environment variables to work on my linux mint os. My
Echoing the variables looks right:
However (even after rebooting) NLTK still does not find the tagger:
|
Do |
Thank you for your tip, but I did source .bashrc beforehand and it did not work. I tried it again and unfortunately it's still not working. |
What is your Linux distribution and version? Can you do a |
Thank you for investigating. ``lsb_release -a` returns
|
Go to the place where you want to run your python script, do this: Then go to your home directory, start python and do the same: Do you see the 2 sets of environment variables differ? |
I guess you wanted me to use |
Glad that |
Thank you :) |
what is 'st' in the command 'stanford_dir = st._stanford_jar.rpartition('/')[0]' |
I have the same question as hansen7 |
for few who have been looking what is st, |
Hi,
I am trying to run the stanford parser example. E.g.
executing the last command results with an error:
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
The text was updated successfully, but these errors were encountered: