1

I'm trying to annotate multiple sentences using the CoreNLP server. However, if I try to that with too many sentences I'm getting:

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)

Everything is working if I run this for just 10 or 20 sentences but as the number of them gets larger the server seems to crumble and I'm reaching a timeout limit or something - at least that's the only explanation I have for this.

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

        // ...
    }
}

How can I fix this issue?


Edit: Okay, I found that there is a timeout option:

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

but that does not help. It's failing anyways - it just takes longer.

Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • Are you using the 3.6.0 release, or compiling from GitHub? There are a bunch of stability fixes that have been incorporated since 3.6.0 that may help this. – Gabor Angeli Oct 02 '16 at 19:36

1 Answers1

0

I had a similar problem. In my case, I wanted to use the coreference resolution and I solved by using the following annotators: tokenize,ssplit,pos,lemma,ner,depparse,mention,coref

  • Or a command line like the one below:

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,mention,coref -file example_file.txt

The reason is that it's more efficient (in relation to speed), according to this page: http://stanfordnlp.github.io/CoreNLP/coref.html#overview