Search code examples
nlpstanford-nlp

Classpath Error when training a model with Stanford NLP


I get a classpath error when I want to train my NER model :

Loading JAR-internal classifier /edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... Exception in thread "main" java.lang.RuntimeException: Error loading classifier from jar file (most likely you are not running this code from a jar file or the named classifier is not stored in the jar file)

I'm using this command line :

java -cp "stanford-ner.jar:lib/*" edu.stanford.nlp.ie.crf.CRFClassifier /Users/Desktop/austen.prop

I'm following the instructions from the Stanford NER FAQ http://nlp.stanford.edu/software/crf-faq.shtml

Someone know how to run correctly this command ?


Solution

  • Ok, I fixed my problem, you need to use this command line :

    java -cp "stanford-ner.jar:lib/*" -mx4g edu.stanford.nlp.ie.crf.CRFClassifier -prop /your/path/austen.txt

    You need to specify the absolute path to your property file to run your model.

    For more details follow this good guide : how to train a french NER based on stanford-nlp Conditional Random Fields model?