我们在运行coco评估任务时,会用到cocoevalcap这个类库,具体会用到里面的ROUGE_L、CIDEr以及SPICE这些个评价指标;
运行报错了就是SPICE这个类库报错了,报错信息如下:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/semgraph/semgrex/SemgrexPattern
at edu.anu.spice.SpiceParser.<clinit>(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:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
真的难受的,改了一天的错,突然发现我们从网上拉取到的stanford-corenlp-full-2015-12-09这个包,他在解压之后会放在当前项目的spice/lib这个文件夹下面,但是运行的时候一直报错的路径是你的python环境下的site-packages/pycocoeval/spice/lib这个路径;
所以一直报错NoClassDefFoundError是这个路径里面没有把下面这两个jar包导入进去
stanford-corenlp-3.6.0.jar &&& stanford-corenlp-3.6.0-models.jar
解决办法
就是把这两个包放一份在你的python环境下的site-packages/pycocoeval/spice/lib这个路径下面,问题完美解决!!!!