sina-al / pynlp

A pythonic wrapper for Stanford CoreNLP.
MIT License
107 stars 11 forks source link

CoreNLPServerError: Status code: [500] (edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl) #12

Closed hexingren closed 6 years ago

hexingren commented 6 years ago

Hello,

I received CoreNLPServerError when trying to make it work with Version 3.9.1 of CoreNLP. Does it support the latest version for NER? Thanks!

sina-al commented 6 years ago

Hey,

What version of Java do you have installed? What version of CoreNLP do you have installed?

hexingren commented 6 years ago

I was using Java 9 and CoreNLP v3.9.1.

It turned out that something happened to the NER tagger on the CoreNLP server side. The error message below pops out when I try to tag any sentence using the NER tagger via the web interface on http://localhost:9000.

""" edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl """

sina-al commented 6 years ago

Try running the CoreNLP server as instructed here but also add the flag

--add-modules java.se.ee

There's no way to do this via pynlp currently but I will add it soon.

Alternatively you can use Java 8

hexingren commented 6 years ago

I started the server using """ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000 --add-modules java.se.ee """ and I was able to see the demo box at http://localhost:9000. When I input a sentence at http://localhost:9000, almost all the other taggers, i.e., POS, dependency parse, openie, worked.

However, the NER tagger threw the following exception. """ edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl """

The detailed error message on the console is """ [pool-1-thread-1] INFO CoreNLP - [/0:0:0:0:0:0:0:1:51810] API call w/annotators tokenize,ssplit,pos,lemma,ner James F. Thomas, III and Emily K. Cheung Thomas, husband and wife. [pool-1-thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize [pool-1-thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit [pool-1-thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos [pool-1-thread-1] INFO edu.stanford.nlp.tagger.maxent.MaxentTagger - Loading POS tagger from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [0.7 sec]. [pool-1-thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma [pool-1-thread-1] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ner [pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [1.2 sec]. [pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [0.6 sec]. [pool-1-thread-1] INFO edu.stanford.nlp.ie.AbstractSequenceClassifier - Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [0.6 sec]. [pool-1-thread-1] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1. edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl at edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:38) at edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(TimeExpressionExtractorFactory.java:60) at edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(TimeExpressionExtractorFactory.java:43) at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.(NumberSequenceClassifier.java:86) at edu.stanford.nlp.ie.NERClassifierCombiner.(NERClassifierCombiner.java:135) at edu.stanford.nlp.pipeline.NERCombinerAnnotator.(NERCombinerAnnotator.java:131) at edu.stanford.nlp.pipeline.AnnotatorImplementations.ner(AnnotatorImplementations.java:68) at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$getNamedAnnotators$44(StanfordCoreNLP.java:546) at edu.stanford.nlp.pipeline.StanfordCoreNLP.lambda$null$69(StanfordCoreNLP.java:625) at edu.stanford.nlp.util.Lazy$3.compute(Lazy.java:126) at edu.stanford.nlp.util.Lazy.get(Lazy.java:31) at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:149) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:495) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:201) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:194) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:181) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer.mkStanfordCoreNLP(StanfordCoreNLPServer.java:366) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer.access$800(StanfordCoreNLPServer.java:50) at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle(StanfordCoreNLPServer.java:851) at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(Unknown Source) at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source) at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: edu.stanford.nlp.util.MetaClass$ClassCreationException: MetaClass couldn't create public edu.stanford.nlp.time.TimeExpressionExtractorImpl(java.lang.String,java.util.Properties) with args [sutime, {}] at edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:237) at edu.stanford.nlp.util.MetaClass.createInstance(MetaClass.java:382) at edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:36) ... 27 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) at edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:233) ... 29 more Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException at de.jollyday.util.CalendarUtil.(CalendarUtil.java:42) at de.jollyday.HolidayManager.(HolidayManager.java:66) at de.jollyday.impl.DefaultHolidayManager.(DefaultHolidayManager.java:46) at edu.stanford.nlp.time.JollyDayHolidays$MyXMLManager.(JollyDayHolidays.java:148) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) at java.base/java.lang.Class.newInstance(Unknown Source) at de.jollyday.caching.HolidayManagerValueHandler.instantiateManagerImpl(HolidayManagerValueHandler.java:60) at de.jollyday.caching.HolidayManagerValueHandler.createValue(HolidayManagerValueHandler.java:41) at de.jollyday.caching.HolidayManagerValueHandler.createValue(HolidayManagerValueHandler.java:13) at de.jollyday.util.Cache.get(Cache.java:51) at de.jollyday.HolidayManager.createManager(HolidayManager.java:168) at de.jollyday.HolidayManager.getInstance(HolidayManager.java:148) at edu.stanford.nlp.time.JollyDayHolidays.init(JollyDayHolidays.java:57) at edu.stanford.nlp.time.Options.(Options.java:119) at edu.stanford.nlp.time.TimeExpressionExtractorImpl.init(TimeExpressionExtractorImpl.java:44) at edu.stanford.nlp.time.TimeExpressionExtractorImpl.(TimeExpressionExtractorImpl.java:39) ... 34 more Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 53 more """ Does this suggest the problem is on CoreNLP server side? Thank you.

sina-al commented 6 years ago

Can you try appending the following option whilst constructing your pynlp.client.StanfordCoreNLP object

annotators = 'ner, ' # + your other annotators
options = {"ner.useSUTime": False}

nlp = StanfordCoreNLP(annotators=annotators, options=options)
hexingren commented 6 years ago

Nice catch!!! It worked.

Could you elaborate the magic here? What is useSUTime and why does it matter? Was the problem on the server side or the wrapper? I tried every Python wrapper of CoreNLP online and they all failed on NER (but worked for other annotators). Really want to know the reasons. Many thanks!

sina-al commented 6 years ago

I'm not too sure to be honest. I based the suggestion off a closed issue on the original repository. For more info I would probably suggest opening an issue on the CoreNLP repository directly.

Thanks