1

我正在尝试使用 CoreNLP 服务器注释多个句子。但是,如果我尝试用太多的句子来做到这一点,我会得到:

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)

如果我只运行 10 或 20 个句子,那么一切正常,但是随着它们的数量越来越大,服务器似乎崩溃了,我达到了超时限制或其他东西 - 至少这是我对此的唯一解释。

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");

但这无济于事。无论如何它都失败了——只是需要更长的时间。

4

1 回答 1

0

我有一个类似的问题。就我而言,我想使用共指解析,并通过使用以下注释器来解决:tokenize,ssplit,pos,lemma,ner,depparse,mention,coref

  • 或者像下面这样的命令行:

java -Xmx5g -cp stanford-corenlp-3.6.0.jar:stanford-corenlp-models-3.6.0.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,depparse ,提及,coref -file example_file.txt

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

于 2016-10-19T15:05:05.240 回答