dmcc / PyStanfordDependencies

Python interface for converting Penn Treebank trees to Stanford Dependencies and Universal Depenencies
https://pypi.python.org/pypi/PyStanfordDependencies
68 stars 17 forks source link

jre has value 1.8 but 1.7 required and then CoreNLP needs 1.8+ #17

Open ccrowner opened 8 years ago

ccrowner commented 8 years ago

edited registry to 1.7 then got

JavaRuntimeVersionError too old must use 1.8+ for CoreNLP

I am using the jar_filename parameter to point to the recent stanford-parser.jar

Thanks!

dmcc commented 8 years ago

Thanks for the report. Can you explain what you mean by "1.7 required" and "edited registry to 1.7"? Also, which version of the JRE is actually installed?

ccrowner commented 8 years ago

I have both jre 1.7 and 1.8 installed

when PyStanfordDependencies threw the JavaVersionError "jre has value 1.8 but 1.7 required" I edited the Windows registry to jre version 1.7

that worked with respect to PyStanfordDependencies BUT led to an error in CoreNLP (the most recent version) which requires 1.8 (hence throws the error "CoreNLP needs 1.8+")

thanks

BTW your tool promises to be very useful, all the Python wrappers on the StanfordNLP site only run under Unix and though NLTK enables many of the StanfordNLP components they don't wrap the DependencyParser

On Wed, Sep 30, 2015 at 10:29 AM, David McClosky notifications@github.com wrote:

Thanks for the report. Can you explain what you mean by "1.7 required" and "edited registry to 1.7"? Also, which version of the JRE is actually installed?

— Reply to this email directly or view it on GitHub https://github.com/dmcc/PyStanfordDependencies/issues/17#issuecomment-144429745 .

dmcc commented 8 years ago

Can you send the full stacktrace for the "jre has value 1.8 but 1.7 required" error?

PyStanfordDependencies on its own doesn't care about the JRE versions, it just tries to detect when the jars require a different version. Are you using subprocess or JPype for your backend? (maybe JPype needs JRE 1.7 on Windows?).

ccrowner commented 8 years ago

OK - the program I run is stanford_dependencies_test.py (attached)

If I have jre 1.8 set in the registry

http://stackoverflow.com/questions/26324486/properly-installing-java-8-along-with-java-7

I get dependencies_error.txt

When I set the jre to 1.7 in the registry I get dependencies_error3.txt

Thanks for looking at this. You can see I print out the command you execute and have fiddled around with your code but got nowhere.

On Wed, Sep 30, 2015 at 12:05 PM, David McClosky notifications@github.com wrote:

Can you send the full stacktrace for the "jre has value 1.8 but 1.7 required" error?

PyStanfordDependencies on its own doesn't care about the JRE versions, it just tries to detect when the jars require a different version. Are you using subprocess or JPype for your backend? (maybe JPype needs JRE 1.7 on Windows?).

— Reply to this email directly or view it on GitHub https://github.com/dmcc/PyStanfordDependencies/issues/17#issuecomment-144461688 .

Command: java -ea -cp stanford-parser.jar edu.stanford.nlp.trees.EnglishGrammaticalStructure -basic -treeFile c:\users\crowner\appdata\local\temp\tmp3czf7c -keepPunct Exit code: 2 stderr: Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required. Error: could not find java.dll Error: Could not find Java SE Runtime Environment.

Command: java -ea -cp stanford-parser.jar edu.stanford.nlp.trees.EnglishGrammaticalStructure -basic -treeFile c:\users\crowner\appdata\local\temp\tmpsvzijl -keepPunct Exit code: 1 stderr: java.lang.UnsupportedClassVersionError: edu/stanford/nlp/trees/EnglishGrammaticalStructure : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Exception in thread "main"

C:\Users\crowner\Desktop\doc\stanford-corenlp-full-2015-04-20>python stanford_de pendencies_test.py > dependencies_error3.txt Traceback (most recent call last): File "stanford_dependencies_test.py", line 10, in sent = sd.convert_tree('(S1 (NP (DT some) (JJ blue) (NN moose)))',debug=True ) File "C:\Python27\lib\site-packages\StanfordDependencies\SubprocessBackend.py" , line 95, in convert_tree return self.convert_trees([ptb_tree], **kwargs)[0] File "C:\Python27\lib\site-packages\StanfordDependencies\SubprocessBackend.py" , line 78, in convert_trees self._raise_on_bad_exitcode(return_code, stderr, debug) File "C:\Python27\lib\site-packages\StanfordDependencies\SubprocessBackend.py" , line 107, in _raise_on_bad_exitcode raise JavaRuntimeVersionError() StanfordDependencies.StanfordDependencies.JavaRuntimeVersionError: Your Java run time is too old (must be 1.8+ to use CoreNLP version 3.5.0 or later and 1.6+ to use CoreNLP version 1.3.1 or later)

import os

os.environ['JAVAHOME'] = 'C:\Program Files\Java\jdk1.8.0_60\bin'

os.environ['JAVAHOME'] = 'C:\Program Files\Java\jdk1.7.0_51\bin'

import StanfordDependencies sd = StanfordDependencies.get_instance(backend='subprocess', jar_filename='stanford-parser.jar')

sent = sd.convert_tree('(S1 (NP (DT some) (JJ blue) (NN moose)))',debug=True) for token in sent: print token

dmcc commented 8 years ago

Hmm, sounds like having two different JREs on Windows is tricky. If it's at all possible, I would only have one version installed (though it sounds like StackOverflow users have found some workarounds).

Yeah, PyStanfordDependencies doesn't look at JAVAHOME unfortunately -- it's basically just running the java command and hoping that will run. In your case, it looks like running java triggers the error about the registry mismatch. So essentially, I think you need to find a way that running java -version prints out 1.8 without any errors. You might also want to try passing the path to a specific java binary with the java_command argument to StanfordDependencies.get_instance -- I'm not a Windows expert (nor do I have access to it) so I'm not sure if this will help.

ccrowner commented 8 years ago

Some good ideas, thanks.

On Wed, Sep 30, 2015 at 2:26 PM, David McClosky notifications@github.com wrote:

Hmm, sounds like having two different JREs on Windows is tricky. If it's at all possible, I would only have one version installed (though it sounds like StackOverflow users have found some workarounds).

Yeah, PyStanfordDependencies doesn't look at JAVAHOME unfortunately -- it's basically just running the java command and hoping that will run. In your case, it looks like running java triggers the error about the registry mismatch. So essentially, I think you need to find a way that running java -version prints out 1.8 without any errors. You might also want to try passing the path to a specific java binary with the java_command argument to StanfordDependencies.get_instance -- I'm not a Windows expert (nor do I have access to it) so I'm not sure if this will help.

— Reply to this email directly or view it on GitHub https://github.com/dmcc/PyStanfordDependencies/issues/17#issuecomment-144499309 .

ccrowner commented 8 years ago

One quick question that's probably obvious ;-)

Why are you depending upon the Stanford jar? If you can take a parse tree and convert it into dependencies it seems that I could call the Stanford Parser using some other wrapper (e.g. NLTK) and just pass the resulting tree to your code (again sorry if this is obvious I didn't look so much at your code logic - just trying to get past nit-noid version problems)

Thanks

On Wed, Sep 30, 2015 at 2:33 PM, Christopher Crowner ccrowner@gmail.com wrote:

Some good ideas, thanks.

On Wed, Sep 30, 2015 at 2:26 PM, David McClosky notifications@github.com wrote:

Hmm, sounds like having two different JREs on Windows is tricky. If it's at all possible, I would only have one version installed (though it sounds like StackOverflow users have found some workarounds).

Yeah, PyStanfordDependencies doesn't look at JAVAHOME unfortunately -- it's basically just running the java command and hoping that will run. In your case, it looks like running java triggers the error about the registry mismatch. So essentially, I think you need to find a way that running java -version prints out 1.8 without any errors. You might also want to try passing the path to a specific java binary with the java_command argument to StanfordDependencies.get_instance -- I'm not a Windows expert (nor do I have access to it) so I'm not sure if this will help.

— Reply to this email directly or view it on GitHub https://github.com/dmcc/PyStanfordDependencies/issues/17#issuecomment-144499309 .

dmcc commented 8 years ago

It's a good question. PyStanfordDependencies doesn't actually know how to convert trees to dependencies, it just knows two different ways (subprocess and JPype) for calling the conversion code in Stanford CoreNLP/Stanford Parser. In other words, if there was a jar that just had the dependency conversion code in it and didn't include a parser, PyStanfordDependencies would be fine with that. It just uses Stanford CoreNLP/Parser jars by default since those are the ones that are typically distributed.

ccrowner commented 8 years ago

Thanks, and thanks again for contributing something useful to the community!

On Wed, Sep 30, 2015 at 2:44 PM, David McClosky notifications@github.com wrote:

It's a good question. PyStanfordDependencies doesn't actually know how to convert trees to dependencies, it just knows two different ways (subprocess and JPype) for calling the conversion code in Stanford CoreNLP/Stanford Parser. In other words, if there was a jar that just had the dependency conversion code in it and didn't include a parser, PyStanfordDependencies would be fine with that. It just uses Stanford CoreNLP/Parser jars by default since those are the ones that are typically distributed.

— Reply to this email directly or view it on GitHub https://github.com/dmcc/PyStanfordDependencies/issues/17#issuecomment-144503762 .