I downloaded the stanford nlp and when i run the code which is given in their website .
I get an error in this line :
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
The error is as follows :
Exception in thread "main" java.lang.NoClassDefFoundError: nu/xom/Node
at sample1.main(sample1.java:35)
Caused by: java.lang.ClassNotFoundException: nu.xom.Node
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
I use eclipse , should i do some configuration ? Please help me out with it !
I have downloaded the stanford-corenlp-2012-01-08.tgz from the link you provided. Using 7-zip I have uncompressed it and found another compressed file with name stanford-corenlp-2012-01-08 and again uncompressed it using 7-zip. The content is shown below:
Then I created a new Java Project in eclipse and created a new folder lib inside that project and put
- joda-time.jar
- stanford-corenlp-2011-12-27-models.jar
- stanford-corenlp-2012-01-08.jar
- xom.jar
jars to the lib. Then set the project Java Build Path to these jars.
Next I created a test class with main method.
import java.util.Properties;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
public class NLP {
/**
* @param args
*/
public static void main(String[] args) {
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP coreNLP = new StanfordCoreNLP(props);
}
}
And lastly run the application. The output is depicted below:
It runs successfully.
Hope this will help you.
I had the same problem using stanford-corenlp-full-2014-10-31.
Tapas Bose's answer is very good, but for this current version (and maybe other earlier ones), you also need to include another two .jar files to get rid of the error:
- ejml-0.23.jar
- jollyday.jar
The developers updated this information on the website, too:
To process one file using Stanford CoreNLP, use the following sort of command line (adjust the JAR file date extensions to your downloaded release):
java -cp stanford-corenlp-VV.jar:stanford-corenlp-VV-models.jar:xom.jar:joda-time.jar:jollyday.jar:ejml-VV.jar -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP [ -props <YOUR CONFIGURATION FILE> ] -file <YOUR INPUT FILE>
you also need to add xom.jar to build path.
Please include ejml-0.23.jar in your libraries.