coco-caption icon indicating copy to clipboard operation
coco-caption copied to clipboard

Semgrex Class Not Found Exception

Open shaunakjoshi12 opened this issue 6 years ago • 3 comments

Even after installing Stanford Core NLP 3.9.2 and pasting the core and the models.jar files in lib,further adding all the jars of core-nlp folder into the CLASSPATH the following issue comes

Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/semgraph/semgrex/SemgrexPattern at edu.anu.spice.SpiceParser.(SpiceParser.java:64) at edu.anu.spice.SpiceScorer.scoreBatch(SpiceScorer.java:70) at edu.anu.spice.SpiceScorer.main(SpiceScorer.java:60) Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.semgraph.semgrex.SemgrexPattern at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more Traceback (most recent call last): File "test_results.py", line 50, in metrics_dict = nlgeval.compute_metrics(references, hypotheses) File "/home/shaunak/ProjectSSSP/FULL_S/caption_generator_resnet/nlg_eval_master/nlgeval/init.py", line 299, in compute_metrics score, scores = scorer.compute_score(refs, hyps) File "/home/shaunak/ProjectSSSP/FULL_S/caption_generator_resnet/nlg_eval_master/nlgeval/pycocoevalcap/spice/spice.py", line 70, in compute_score cwd=os.path.dirname(os.path.abspath(file))) File "/home/shaunak/anaconda2/lib/python2.7/subprocess.py", line 186, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['java', '-jar', '-Xmx8G', 'spice-1.0.jar', '/home/shaunak/ProjectSSSP/FULL_S/caption_generator_resnet/nlg_eval_master/nlgeval/pycocoevalcap/spice/tmp/tmpVBAF4B', '-cache', '/home/shaunak/ProjectSSSP/FULL_S/caption_generator_resnet/nlg_eval_master/nlgeval/pycocoevalcap/spice/cache', '-out', '/home/shaunak/ProjectSSSP/FULL_S/caption_generator_resnet/nlg_eval_master/nlgeval/pycocoevalcap/spice/tmp/tmpp_GQD4', '-subset', '-silent']' returned non-zero exit status 1 python2 -W ignore test_results.py 26.40s user 0.85s system 193% cpu 14.052 total

Tried this with java 8 and java 9

shaunakjoshi12 avatar Feb 03 '19 19:02 shaunakjoshi12

Came across the same problem. Other metrics are working fine.

muneebable avatar Mar 05 '19 17:03 muneebable

Same issue here with Stanford Core NLP version 3.9.2.

The solution is to use Stanford Core NLP 3.6.0 as specified in the get_stanford_models.sh script. The simplest way to get the correct model is to run ./get_stanford_models.sh as stated in the README.

Alternatively you can run cocoEvalCapDemo.ipynb notebook, which will additionally verify that your installation is working.

Edit: Add solution to issue

idobrusin avatar Mar 13 '19 17:03 idobrusin

Pay special attention to the get_stanford_models.sh script, you may ignore running the script but download the stanford-corenlp-full-2015-12-09 (Stanford Core NLP 3.6.0) package and unzip it yourself, but there are some important file movement in that script:for example: mv $SPICELIB/$CORENLP/$JAR.jar $SPICELIB/ mv $SPICELIB/$CORENLP/$JAR-models.jar $SPICELIB/,if you downloaded the zip file yourself cause of the low speed on the remote server like me, you should do the file movements yourself too.

keepcreative avatar Sep 20 '23 07:09 keepcreative