stanfordnlp / CoreNLP

CoreNLP: A Java suite of core NLP tools for tokenization, sentence segmentation, NER, parsing, coreference, sentiment analysis, etc.
http://stanfordnlp.github.io/CoreNLP/
GNU General Public License v3.0
9.72k stars 2.7k forks source link

Exceptions while using Java client send Chinese to coreNLP Server #693

Closed NintendoLink closed 6 years ago

NintendoLink commented 6 years ago

I set up a CoreNLP Server on my computer to Handle Chinese NLP.

D:\repository\edu\stanford\nlp\stanford-corenlp\3.9.1>java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-chinese.properties -port 9000 -timeout 15000 --- StanfordCoreNLPServer#main() called --- setting default constituency parser using SR parser: edu/stanford/nlp/models/srparser/englishSR.ser.gz Threads: 8 Starting server... StanfordCoreNLPServer listening at /0:0:0:0:0:0:0:0:9000

when i use Chrome(http post) to call coreNLP api ,It works.:

[/0:0:0:0:0:0:0:1:64386] API call w/annotators tokenize,ssplit,pos,depparse,lemma,natlog,ner,openie待机时间长 [/0:0:0:0:0:0:0:1:64423] API call w/annotators tokenize,ssplit,pos,depparse,lemma,natlog,ner,openie 运行速度快 [/0:0:0:0:0:0:0:1:64447] API call w/annotators tokenize,ssplit,pos,depparse,lemma,natlog,ner,openie 电池容量大 [/0:0:0:0:0:0:0:1:64447] API call w/annotators tokenize,ssplit,pos,depparse,lemma,natlog,ner,openie 服务态度很好 [/0:0:0:0:0:0:0:1:51261] API call w/annotators tokenize,ssplit,pos,depparse,lemma,natlog,ner,openie 今天天气真不错

But when I use Java Clinet to Call api ,it Throws Exception on Server. Client Code(official example):

Properties props = new Properties(); props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref"); StanfordCoreNLPClient pipeline = new StanfordCoreNLPClient(props, "http://localhost", 9000, 2) ; String text = "今天天气真好"; // Add your text here! Annotation document = new Annotation(text); pipeline.annotate(document);

Client is holding on,because it recieve nothing probably. Server Exceptions:

API call w/annotators tokenize,ssplit,pos,lemma,ner,parse,dcoref Exception in thread "pool-1-thread-8" java.lang.NoClassDefFoundError: edu/stanford/nlp/pipeline/CoreNLPProtos$Document at edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.read(ProtobufAnnotationSerializer.java:193) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer.getDocument(StanfordCoreNLPServer.java:325) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer.access$500(StanfordCoreNLPServer.java:50) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle(StanfordCoreNLPServer.java:831) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.AuthFilter.doFilter(Unknown Source) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source) at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

I am guessing I somehow miss Specify Parameters?

When I first call API by using java Client, Exception traces on client:

TOP ELEMENT: java.lang.ClassLoader.defineClass1(Native Method) [Thread-1] ERROR edu.stanford.nlp.pipeline.StanfordCoreNLPClient - java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessageV3$ExtendableMessageOrBuilder java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:763) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) java.net.URLClassLoader.defineClass(URLClassLoader.java:467) java.net.URLClassLoader.access$100(URLClassLoader.java:73) java.net.URLClassLoader$1.run(URLClassLoader.java:368) java.net.URLClassLoader$1.run(URLClassLoader.java:362) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:361) java.lang.ClassLoader.loadClass(ClassLoader.java:424) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) java.lang.ClassLoader.loadClass(ClassLoader.java:357) java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:763) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) java.net.URLClassLoader.defineClass(URLClassLoader.java:467) java.net.URLClassLoader.access$100(URLClassLoader.java:73) java.net.URLClassLoader$1.run(URLClassLoader.java:368) java.net.URLClassLoader$1.run(URLClassLoader.java:362) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:361) java.lang.ClassLoader.loadClass(ClassLoader.java:424) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) java.lang.ClassLoader.loadClass(ClassLoader.java:357) edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.toProtoBuilder(ProtobufAnnotationSerializer.java:611) edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.toProto(ProtobufAnnotationSerializer.java:579) edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer.write(ProtobufAnnotationSerializer.java:184) edu.stanford.nlp.pipeline.StanfordCoreNLPClient.lambda$null$482(StanfordCoreNLPClient.java:437) java.lang.Thread.run(Thread.java:748) Caused by: class java.lang.ClassNotFoundException: com.google.protobuf.GeneratedMessageV3$ExtendableMessageOrBuilder java.net.URLClassLoader.findClass(URLClassLoader.java:381) java.lang.ClassLoader.loadClass(ClassLoader.java:424) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) java.lang.ClassLoader.loadClass(ClassLoader.java:357) java.lang.ClassLoader.defineClass1(Native Method) ...28 more [Thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize [Thread-1] INFO edu.stanford.nlp.pipeline.TokenizerAnnotator - No tokenizer type provided. Defaulting to PTBTokenizer.

J38 commented 6 years ago

dcoref does not work for Chinese. Please use the coref annotator. When I run your example with the client and server as you specify it works fine as long as I change dcoref to coref.

NintendoLink commented 6 years ago

thanks a lot. finnally i add protobuf dependcency in folder.,it works