我使用以下命令在 Ubuntu 16.04 上启动了我的 Standford NLP 服务器(CoreNLP v 3.91, ):stanford-corenlp-full-2018-02-27.zip
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
过了一段时间,如果我对它扔了太多的句子,它就会爆炸。
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle (StanfordCoreNLPServer.java:866)
[pool-1-thread-6] INFO CoreNLP - [/127.0.0.1:34048] API call w/annotators tokenize,ssplit,pos,parse,depparse
But if you ask any feminist directly (and I have, one of my best friends is a woman's studies major and we have had MANY heated passionate arguments; i've spoken to her friends too), they will fully say that modern feminism is about having the choice, and while they completely disagree with women who take this choice, it is still their choice to make.
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle(StanfordCoreNLPServer.java:866)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[Thread-0] INFO CoreNLP - CoreNLP Server is shutting down.
不幸的是,这会杀死我的服务器。我的 python 脚本捕获了由服务器超时引起的异常,但是我怎样才能通过它,并继续使用服务器。我目前正在使用eval()
上述命令重新启动服务器。
有没有更好的方法跳过这些崩溃?
编辑:这是一个示例,当我向它抛出太大的句子时,CoreNLP v 3.91 失败:
注意一个很长的句子将如何导致超时异常,并且它会使服务器崩溃。