在尝试使用Stanford Core NLP工具时获取Java错误

时间:2014-07-25 16:25:39

标签: java classpath stanford-nlp

我遇到了在尝试使用Stanford Core NLP工具时遇到各种错误的问题。我的目标是在类似于here的服务器上运行管道,这样我就可以根据需要从另一个程序发出请求,而不必每次等待模型重新加载(这需要〜 20秒)。

然而,当从Netbeans运行我自己的代码并将所需的jar添加到类路径中时,或者运行上面的服务器等代码并将类路径设置为时,我无法使用这些工具。 jars在命令行上。

我一直试图让这个工作好几天,并且真的不知道它为什么不起作用。

我尝试完全按照Error in stanford nlp core的最佳答案状态,使用完全相同的示例代码并将相同的jar添加到类路径中(除了使用更新版本的工具中的jar) )。我和他们之间唯一的区别就是我使用Linux和Netbeans而不是Windows和Eclipse,但我不明白为什么会有所作为?我收到此错误消息:

Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model 

尝试运行此代码时。

我还尝试在Tomcat上的servlet中运行工具时显式设置模型,但是当我尝试向servlet发出请求时,我得到nu.xom.node的ClassNotFoundException - 但是xom .jar在类路径上。

感谢您的帮助,如果需要,我可以提供更多有关任何内容的详细信息,我尝试提供代码和错误消息的链接,但显然不能在帖子中添加两个以上。

更新

运行代码时的堆栈跟踪,如上面的第二个链接:

Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
        at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:558)
        at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:267)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125)
        at NLP.main(NLP.java:13)
Caused by: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:763)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:294)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:259)
        at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:97)
        at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:77)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:556)
        ... 5 more
Caused by: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as either class path, filename or URL
        at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:446)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:758)
        ... 10 more

向servlet发出请求时出现错误消息,该请求明确加载模型:

Jul 25, 2014 5:04:28 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [CoreNlpServer] in context with path [/CoreNLP-Server] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: nu.xom.Node
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:259)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.xmlPrint(StanfordCoreNLP.java:948)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.xmlPrint(StanfordCoreNLP.java:935)
        at CoreNlpServer.doGet(CoreNlpServer.java:44)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案