Search code examples
nlpstanford-nlp

Stanford CoreNLP model sentiment.ser.gz missing?


I am new stanford to corenlp and trying to use it. I was able to run sentimental analysis pipeline and corenlp software. While when I am trying to execute evaluate tool it is asking for model sentiment.ser.gz.

java edu.stanford.nlp.sentiment.Evaluate edu/stanford/nlp/models/sentiment/sentiment.ser.gz test.txt

I could not find the model in the software that I downloaded from stanford site or anywhere on internet.

Can someone please guide if we can create our own model or if I can find anywhere on the internet.

Appreciate your help.


Solution

  • The file stanford-corenlp-full-2014-01-04.zip contains another file called stanford-corenlp-3.3.1-models.jar. The latter file is a ZIP archive that contains the model file you are looking for.

    CoreNLP is able to load the model file from the classpath if you add the stanford-corenlp-3.3.1-models.jar to your Java classpath, so you do not have to do anything.

    It also appears the documentation on running the Evaluate tool is slightly outdated.

    The correct call goes like this (tested with CoreNLP 3.3.1 and the test data downloaded from the sentiment homepage):

    java -cp "*" edu.stanford.nlp.sentiment.Evaluate -model edu/stanford/nlp/models/sentiment/sentiment.ser.gz -treebank test.txt
    

    The '-cp "*"' adds everything in the current directory to the classpath. Thus, the command above must be executed in the directory to which you extracted CoreNLP, otherwise it will not work.

    If you do not add the "-model" and -treebank" to the call, you'll an error message like this

    Unknown argument test.txt
    

    If you do not supply a treebank and a model, you get another error message

    Exception in thread "main" java.lang.NullPointerException
        at java.io.File.<init>(File.java:277)