2016-10-01 156 views
1

我想使用CoreNLP服务器注释多个句子。但是,如果我尝试与太多句子我越来越:如果我运行这个只是10或20的句子,但由于它们的数量变大的服务器似乎edu.stanford.nlp.io.RuntimeIOException:无法连接到服务器

Exception in thread "Thread-48" edu.stanford.nlp.io.RuntimeIOException: Could not connect to server: 192.168.108.60:9000 
    at edu.stanford.nlp.pipeline.StanfordCoreNLPClient$2.run(StanfordCoreNLPClient.java:393) 
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://192.168.108.60:9000?properties=%7B+%22inputFormat%22%3A+%22serialized%22%2C+%22outputSerializer%22%3A+%22edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer%22%2C+%22inputSerializer%22%3A+%22edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer%22%2C+%22annotators%22%3A+%22tokenize%2C+ssplit%2C+pos%2C+lemma%2C+ner%2C+parse%2C+dcoref%22%2C+%22outputFormat%22%3A+%22serialized%22+%7D 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) 
    at edu.stanford.nlp.pipeline.StanfordCoreNLPClient$2.run(StanfordCoreNLPClient.java:381) 

一切工作崩溃和我达到超时限制或至少 - 这是我对此的唯一解释。

StanfordCoreNLPClient coreNlp = new StanfordCoreNLPClient(props, "192.168.108.60", 9000); 

// .. 

for(int windowSize : windowSizeList) { 

    Map<String, List<TaggedSentence>> aspectMap = new HashMap<>(); 

    for (int i = 0; i < sentenceList.size(); i++) { 

     Annotation document = sentenceList.get(i); 

     try { 
      coreNlp.annotate(document); 
     } catch(Exception e) { 
      LOGGER.error("Error", e); 
     } 

     // ... 
    } 
} 

我该如何解决这个问题?


编辑:好吧,我发现有一个超时选项:

props.setProperty("timeout", "50000"); 

但这并不能帮助。反正它失败了 - 它只需要更长的时间。

+0

您是使用3.6.0发行版还是从GitHub编译?自3.6.0版本以来,已经有一些稳定性修补程序可以帮助实现这一点。 –

回答

0

我有一个类似的问题。在我的情况,我想用指代消解和我通过以下注释解决:记号化,SSPLIT,POS,引理,NER,depparse,提,COREF

  • 或者类似下面的命令行:

的Java -Xmx5g -cp斯坦福corenlp-3.6.0.jar:斯坦福大学corenlp的模型-3.6.0.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators记号化,SSPLIT,POS ,词条,ner,depparse,提及,coref -file example_file.txt

原因是它效率更高(与速度有关),根据此页面:http://stanfordnlp.github.io/CoreNLP/coref.html#overview