簡體   English   中英

設置我自己的Stanford CoreNLP服務器時出現問題:

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

我將按照http://stanfordnlp.github.io/CoreNLP/corenlp-server.html中的教程設置自己的斯坦福解析器服務器。 但是,當我粘貼示例代碼時,它會出現錯誤:

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)

這是我的代碼:

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

您提供的代碼對我來說沒有改變。 (它不會打印任何內容;您可以在test()時在test()的末尾放置類似System.out.println(document.toShorterString());之類的東西,但它可以工作。

您是否使用此處的第一條指令啟動服務器並使其保持運行狀態: http : //stanfordnlp.github.io/CoreNLP/corenlp-server.html#getting-started 看起來服務器未在本地計算機的端口9000上運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM