简体   繁体   English

设置我自己的Stanford CoreNLP服务器时出现问题:

[英]Problems in setting up my own Stanford CoreNLP server:

I'm setting up my own stanford parser server following the tutorial in http://stanfordnlp.github.io/CoreNLP/corenlp-server.html . 我将按照http://stanfordnlp.github.io/CoreNLP/corenlp-server.html中的教程设置自己的斯坦福解析器服务器。 However, when I paste the example code, it comes out an error: 但是,当我粘贴示例代码时,它会出现错误:

Exception in thread "Thread-1" edu.stanford.nlp.io.RuntimeIOException: Could not connect to server: localhost:9000
at edu.stanford.nlp.pipeline.StanfordCoreNLPClient$2.run(StanfordCoreNLPClient.java:393)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
   at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1169)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:933)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
at edu.stanford.nlp.pipeline.StanfordCoreNLPClient$2.run(StanfordCoreNLPClient.java:374)

Here is my code: 这是我的代码:

import java.util.*;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLPClient;

public class tagger {
    public static void test(){
        // creates a StanfordCoreNLP object with POS tagging, lemmatization, NER, parsing, and coreference resolution
        Properties props = new Properties();

        props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");

        StanfordCoreNLPClient pipeline = new StanfordCoreNLPClient(props, "localhost", 9000, 2);
        // read some text in the text variable
        String text = "How are you today?";
        // create an empty Annotation just with the given text
        Annotation document = new Annotation(text);
        // run all Annotators on this text
        pipeline.annotate(document);
    }

    public static void main(String[] args){
        test();
    }
}

The code you give works unaltered for me. 您提供的代码对我来说没有改变。 (It doesn't print anything; you might try putting something like System.out.println(document.toShorterString()); at the end of test() while testing it, but it works....) (它不会打印任何内容;您可以在test()时在test()的末尾放置类似System.out.println(document.toShorterString());之类的东西,但它可以工作。

Did you start the server and leave it running using the first instruction here: http://stanfordnlp.github.io/CoreNLP/corenlp-server.html#getting-started ? 您是否使用此处的第一条指令启动服务器并使其保持运行状态: http : //stanfordnlp.github.io/CoreNLP/corenlp-server.html#getting-started This just looks like the server isn't running on port 9000 of your local machine. 看起来服务器未在本地计算机的端口9000上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM