0

I'm very new to Stanford's coreNLP and I'm trying to train it by creating a model. I have a folder that has dev.txt, train.txt, and test.txt as well as a jar file named stanford-corenlp-3.5.1-models.jar. According to this question, I can create a model by executing the following command in the terminal:

java -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath train.txt -devPath     dev.txt -train -model model.ser.gz

However, when I run that in the terminal, I get the following error:

Error: could not find or load main class edu.stanford.nlp.sentiment.SentimentTraining

Can anyone provide step-by-step instructions of how to go about training CoreNLP? I went on the Stanford website to see how training is done, but I'm still confused. I thought all I needed to create a model (e.g model.ser.gz) were those three text files and one jar file.

Any help is very appreciated, thank you!

Community
  • 1
  • 1
user3266259
  • 369
  • 3
  • 8
  • 22

1 Answers1

1

You need to include the CoreNLP jar file in your classpath. So, your java command should look like:

java -cp /path/to/corenlp/jar:/path/to/corenlp/library/dependencies -mx8g ...

From the root of the CoreNLP distribution, you can just include all the jars in the directory; e.g.,

java -cp "*" -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath train.txt -devPath dev.txt -train -model model.ser.gz

Gabor Angeli
  • 5,729
  • 1
  • 18
  • 29
  • I downloaded the coreNLP master distribution and ran the command from the root, but I still got the same error: Could not find or load main class edu.stanford.nlp.sentiment.SentimentTraining. When I looked through the folders, I found a java file called SentimentTraining.java, but there was no class file for it. What do you suggest I do? – user3266259 Nov 10 '15 at 05:30
  • 1
    1. You should go here and download Stanford CoreNLP 3.5.2: http://nlp.stanford.edu/software/corenlp.shtml 2. then run your command out of the folder you download and add -cp "*" as Gabor suggests above 3. "edu/stanford/nlp/sentiment/SentimentTraining.class" is present in the jar stanford-corenlp-3.5.2.jar 4. You can see what files are in a .jar with this command: "jar -tf stanford-corenlp-3.5.2.jar" – StanfordNLPHelp Nov 10 '15 at 05:37
  • I'm going to try that once I get to my computer! Thanks again :) @StanfordNLPHelp – user3266259 Nov 10 '15 at 14:32
  • @StanfordNLPHelp finally had the chance to download coreNLP again and I ran the command from the folder. Everything seems to be working and I'm running it as we speak :) – user3266259 Nov 12 '15 at 05:49