我在使用Jena RDF API的Java项目中使用Stanford POS tagger 3.7.0。 Jena需要slf4j-api-1.7.12.jar和slf4j-log4j12-1.7.12.jar,但是当尝试在类路径中调用具有这些jar的POS标记时,我收到以下错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at edu.stanford.nlp.util.logging.Redwood$ConsoleHandler.out(Redwood.java:920)
at edu.stanford.nlp.util.logging.RedwoodConfiguration.<init>(RedwoodConfiguration.java:28)
at edu.stanford.nlp.util.logging.RedwoodConfiguration.empty(RedwoodConfiguration.java:385)
at util.Splitter.split(Splitter.java:58)
at core.Main.main(Main.java:23)
Caused by: java.lang.IllegalStateException: Could not find SLF4J in your classpath
at edu.stanford.nlp.util.logging.RedwoodConfiguration$Handlers.lambda$static$530(RedwoodConfiguration.java:190)
at edu.stanford.nlp.util.logging.RedwoodConfiguration$Handlers$7.buildChain(RedwoodConfiguration.java:309)
at edu.stanford.nlp.util.logging.RedwoodConfiguration$Handlers$7.apply(RedwoodConfiguration.java:318)
at edu.stanford.nlp.util.logging.RedwoodConfiguration.lambda$handlers$535(RedwoodConfiguration.java:363)
at edu.stanford.nlp.util.logging.RedwoodConfiguration.apply(RedwoodConfiguration.java:41)
at edu.stanford.nlp.util.logging.Redwood.<clinit>(Redwood.java:609)
... 5 more
Caused by: edu.stanford.nlp.util.MetaClass$ClassCreationException: java.lang.ClassNotFoundException: edu.stanford.nlp.util.logging.SLF4JHandler
at edu.stanford.nlp.util.MetaClass.createFactory(MetaClass.java:364)
at edu.stanford.nlp.util.MetaClass.createInstance(MetaClass.java:381)
at edu.stanford.nlp.util.logging.RedwoodConfiguration$Handlers.lambda$static$530(RedwoodConfiguration.java:186)
... 10 more
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.util.logging.SLF4JHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at edu.stanford.nlp.util.MetaClass$ClassFactory.construct(MetaClass.java:135)
at edu.stanford.nlp.util.MetaClass$ClassFactory.<init>(MetaClass.java:202)
at edu.stanford.nlp.util.MetaClass$ClassFactory.<init>(MetaClass.java:69)
at edu.stanford.nlp.util.MetaClass.createFactory(MetaClass.java:360)
... 12 more
我已经看到有similar problem的人通过从类路径中删除SLF4J来解决它。事实上,当我移除罐子时,POS标签工作正常,但Jena停止工作。
有没有办法让SLF4J保持在类路径中并且仍能让POS标记器工作?
答案 0 :(得分:0)
我认为最好的解决方案是使用完整的Stanford CoreNLP 3.7.0版本,该版本不会遇到此问题,但会拥有所有的POS标记功能。
完整下载可在此处获取:
http://stanfordnlp.github.io/CoreNLP/download.html
这个问题应该在Stanford CoreNLP 3.8.0的独立发行版中解决,我们将在初夏尝试发布。