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.66k stars 2.7k forks source link

TimeExpressionExtractorFactory.isDefaultExtractorPresent() checks for class but not for resources #122

Open reckart opened 8 years ago

reckart commented 8 years ago

TimeExpressionExtractorFactory.isDefaultExtractorPresent() check if the class for the default time expression extractor is present (i.e. edu.stanford.nlp.time.TimeExpressionExtractorImpl which is in the CoreNLP jar and thus likely always present). It doesn't check though if the resources required by this extractor are present (in the "models" jar which may actually not be present).

When not having the models jar on the classpath and using alternative means of providing the NERClassifierCombiner with models then causes the auto-detection to fail with this exception:

Caused by: edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl
    at edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:40)
    at edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(TimeExpressionExtractorFactory.java:57)
    at edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(TimeExpressionExtractorFactory.java:38)
    at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.<init>(NumberSequenceClassifier.java:81)
    at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.<init>(NumberSequenceClassifier.java:73)
    at edu.stanford.nlp.ie.NERClassifierCombiner.<init>(NERClassifierCombiner.java:103)
       <snip>
    ... 32 more
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:235)
    at edu.stanford.nlp.util.MetaClass.createInstance(MetaClass.java:380)
    at edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:38)
    ... 46 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:231)
    ... 48 more
Caused by: java.lang.RuntimeException: Error initializing binder 1
    at edu.stanford.nlp.time.Options.<init>(Options.java:92)
    at edu.stanford.nlp.time.TimeExpressionExtractorImpl.init(TimeExpressionExtractorImpl.java:45)
    at edu.stanford.nlp.time.TimeExpressionExtractorImpl.<init>(TimeExpressionExtractorImpl.java:39)
    ... 53 more
Caused by: java.lang.NullPointerException: Missing URL.
    at de.jollyday.HolidayManager.getInstance(HolidayManager.java:190)
    at edu.stanford.nlp.time.JollyDayHolidays.init(JollyDayHolidays.java:51)
    at edu.stanford.nlp.time.Options.<init>(Options.java:90)
    ... 55 more
AngledLuffa commented 8 years ago

Just FYI something is happening to your "." periods which are making them not come through on email.

On Wed, Jan 6, 2016 at 12:26 PM, Richard Eckart de Castilho < notifications@github.com> wrote:

TimeExpressionExtractorFactoryisDefaultExtractorPresent() check if the class for the default time expression extractor is present (ie edustanfordnlptimeTimeExpressionExtractorImpl which is in the CoreNLP jar and thus likely always present) It doesn't check though if the resources required by this extractor are present (in the "models" jar which may actually not be present)

When not having the models jar on the classpath and using alternative means of providing the NERClassifierCombiner with models then causes the auto-detection to fail with this exception:

Caused by: edustanfordnlputilReflectionLoading$ReflectionLoadingException: Error creating edustanfordnlptimeTimeExpressionExtractorImpl at edustanfordnlputilReflectionLoadingloadByReflection(ReflectionLoadingjava:40) at edustanfordnlptimeTimeExpressionExtractorFactorycreate(TimeExpressionExtractorFactoryjava:57) at edustanfordnlptimeTimeExpressionExtractorFactorycreateExtractor(TimeExpressionExtractorFactoryjava:38) at edustanfordnlpieregexpNumberSequenceClassifier(NumberSequenceClassifierjava:81) at edustanfordnlpieregexpNumberSequenceClassifier(NumberSequenceClassifierjava:73) at edustanfordnlpieNERClassifierCombiner(NERClassifierCombinerjava:103)

32 more Caused by: edustanfordnlputilMetaClass$ClassCreationException: MetaClass couldn't create public edustanfordnlptimeTimeExpressionExtractorImpl(javalangString,javautilProperties) with args [sutime, {}] at edustanfordnlputilMetaClass$ClassFactorycreateInstance(MetaClassjava:235) at edustanfordnlputilMetaClasscreateInstance(MetaClassjava:380) at edustanfordnlputilReflectionLoadingloadByReflection(ReflectionLoadingjava:38) 46 more Caused by: javalangreflectInvocationTargetException at sunreflectNativeConstructorAccessorImplnewInstance0(Native Method) at sunreflectNativeConstructorAccessorImplnewInstance(NativeConstructorAccessorImpljava:62) at sunreflectDelegatingConstructorAccessorImplnewInstance(DelegatingConstructorAccessorImpljava:45) at javalangreflectConstructornewInstance(Constructorjava:422) at edustanfordnlputilMetaClass$ClassFactorycreateInstance(MetaClassjava:231) 48 more Caused by: javalangRuntimeException: Error initializing binder 1 at edustanfordnlptimeOptions(Optionsjava:92) at edustanfordnlptimeTimeExpressionExtractorImplinit(TimeExpressionExtractorImpljava:45) at edustanfordnlptimeTimeExpressionExtractorImpl(TimeExpressionExtractorImpljava:39) 53 more Caused by: javalangNullPointerException: Missing URL at dejollydayHolidayManagergetInstance(HolidayManagerjava:190) at edustanfordnlptimeJollyDayHolidaysinit(JollyDayHolidaysjava:51) at edustanfordnlptimeOptions(Optionsjava:90) 55 more — Reply to this email directly or view it on GitHub https://github.com/stanfordnlp/CoreNLP/issues/122.
reckart commented 8 years ago

Well, that's GitHub's problem then - above in the comment, they are present.

AngledLuffa commented 8 years ago

In case it's relevant, your most recent email looks like

Well, that's Githubs problem then

with the ' in "that's" but not in "Githubs"

On Wed, Jan 6, 2016 at 1:06 PM, Richard Eckart de Castilho < notifications@github.com> wrote:

Well, that's Githubs problem then - above in the comment, they are present.

— Reply to this email directly or view it on GitHub https://github.com/stanfordnlp/CoreNLP/issues/122#issuecomment-169461063 .

reckart commented 8 years ago

Well, that's Githubs problem then

That's because I did first posted it with the typo and then edited the comment to correct it.

dickmao commented 6 years ago

Crude "fix"? https://github.com/dickmao/CoreNLP/commit/5a0b2693b0046542a72aff2ca38806c500d03f04?diff=split#diff-197bc6bb30fbb74a02668c3f9beed8be