Search code examples
javamavenstanford-nlp

Loading specific model file from CoreNLP Model jar file rather than a local copy of it


Can refer to the already packaged model in StanfordCoreNLP library jar, instead of having duplicate copy of the model in the project working directory for this purpose?.

Properties configuration = new Properties();
configuration.put("annotators", "tokenize,ssplit,pos,lemma,ner");
configuration.put("ner.model", "english.all.3class.distsim.crf.ser.gz");
StanfordCoreNLP coreNLP  = new StanfordCoreNLP(configuration);

ps: The question was a part of another SO question which went unanswered.


Solution

  • This path:

    edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz

    is in stanford-corenlp-3.7.0-models.jar.

    So if you put that in your properties, it will be loaded from the jar.