1

I have been working on this project for a while. I'm using stanford NLP. I've added its dependency in my maven project. it used to work completely fine but now it shows this error: (I even downloaded similar project from git to find out if something is wrong done by me yet same message is displayed for that too. please let me know the problem)

Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos

    Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
        at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:493)
        at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:260)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:127)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:123)
        at CoreNlpExample.main(CoreNlpExample.java:17)
    Caused by: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:749)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:283)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:247)
        at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:78)
        at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:62)
        at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:491)
        ... 5 more
    Caused by: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as either class path, filename or URL
        at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:419)
        at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:744)
        ... 10 more
Lokesh Pandey
  • 1,739
  • 23
  • 50
Gurjot kaur
  • 145
  • 1
  • 13

1 Answers1

1

You need to include the models jar in your classpath. You can either download this manually, or include it with maven via the instructions at https://stanfordnlp.github.io/CoreNLP/download.html (replace version as appropriate):

<dependencies> <dependency>
    <groupId>edu.stanford.nlp</groupId>
    <artifactId>stanford-corenlp</artifactId>
    <version>3.8.0</version> 
  </dependency>
<dependency>
    <groupId>edu.stanford.nlp</groupId>
    <artifactId>stanford-corenlp</artifactId>
    <version>3.8.0</version>
    <classifier>models</classifier> 
  </dependency> 
</dependencies>
Gabor Angeli
  • 5,729
  • 1
  • 18
  • 29
  • i'm getting this kind of error now:SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.OutOfMemoryError: Java heap space – Gurjot kaur Oct 12 '17 at 04:55
  • @Gurjotkaur read this https://stackoverflow.com/questions/7421612/slf4j-failed-to-load-class-org-slf4j-impl-staticloggerbinder – Lokesh Pandey Oct 12 '17 at 05:27
  • @Lokesh i added the given dependencies too...but it does not help...same error yet again! any other solution please? – Gurjot kaur Oct 12 '17 at 06:10
  • @Gurjotkaur In that case you can raise this issue on github . – Lokesh Pandey Oct 12 '17 at 06:13
  • @Gurjotkaur also try one more thing while updating check the force update of snapshot and releases. and update you maven once again. – Lokesh Pandey Oct 12 '17 at 06:16
  • Also, it sounds like you haven't given Java enough memory. Make sure to set -mx to a few gb. – Gabor Angeli Oct 12 '17 at 06:21
  • i've now given it 3gb space and tried the solution of the mentioned link...but it doesnt solve anything – Gurjot kaur Oct 12 '17 at 09:54