[Solved]: Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model



Problem Statement:  Error when using StanfordCoreNLP

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:563)    at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81)    at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:262)    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129)    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125)    at lemmafirst.<init>(lemmafirst.java:39)    at lemmafirst.main(lemmafirst.java:83)Caused by: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model    at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:758)    at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:289)    at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:253)    at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:88)    at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:76)    at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:561)    ... 6 moreCaused 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:434)    at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:753)    ... 11 more

Solution: 

An easier way to add those model files is to simply add following dependencies in your pom.xml and let maven manage it for you:

  <properties>    <stanford.corenlp.version>3.9.1</stanford.corenlp.version>  </properties>  <dependencies>      <!-- Stanford dependecies -->       <dependency>            <groupId>edu.stanford.nlp</groupId>           <artifactId>stanford-corenlp</artifactId>           <version>${stanford.corenlp.version}</version>       </dependency>        <dependency>            <groupId>edu.stanford.nlp</groupId>           <artifactId>stanford-corenlp</artifactId>           <version>${stanford.corenlp.version}</version>           <classifier>models</classifier>         </dependency>  </dependencies>