Error in the stanford nlp kernel

I downloaded stanford nlp and when I run the code that is listed on the website .

I get an error on 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 am using eclipse, should I do some configuration? Please help me with this!

+5
source share
4 answers

I downloaded stanford-corenlp-2012-01-08.tgz from the link you provided. Using 7-zip, I unpacked it and found another compressed file called stanford-corenlp-2012-01-08 and again uncompressed using 7-zip. Content shown below: enter image description here

Then I created a new Java project in eclipse and created a new lib folder inside this project and placed

  • Joda-time.jar
  • Stanford-corenlp-2011-12-27-models.jar
  • Stanford-corenlp-2012-01-08.jar
  • xom.jar

banks in lib. Then set the Java Build Path to these banks.

enter image description here

Next, I created a test class with the 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 finally, launch the application. The result is shown below:

enter image description here

Successful.

Hope this helps you.

+30
source

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 possibly other earlier ones), you also need to include two more .jar files to get rid of the error:

  • ejml-0.23.jar
  • jollyday.jar

The developers updated this information on the website :

To process a single file using Stanford CoreNLP, use the following command line command (configure the file extension of the JAR file for the 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> 
+1
source

you also need to add xom.jar to create the path.

+1
source

Please list ejml-0.23.jar in your libraries.

0
source

Source: https://habr.com/ru/post/909542/


All Articles