首页 文章

线程“main”中的异常java.lang.NoClassDefFoundError:edu / stanford / nlp / pipeline / StanfordCoreNLP

提问于
浏览
1

我从https://stanfordnlp.github.io/CoreNLP/下载了stanford corenlp zip文件,然后将其解压缩并插入其中 . 现在我尝试运行以下java文件 . javac -cp "*" SentimentAnalysis.java works 很好,但 java SentimentAnalysis 抛出错误,线程中的异常"main" java.lang.NoClassDefFoundError:edu / stanford / nlp / pipeline / StanfordCoreNLP .

import edu.stanford.nlp.pipeline.*;

import java.util . *;

公共课SentimentAnalysis {

public static void main(String[] args) {

    // creates a StanfordCoreNLP object, with POS tagging, lemmatization, NER, parsing, and coreference resolution
    Properties props = new Properties();
    props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

    // read some text in the text variable
    String text = "Hello madam, this is a dam";

    // create an empty Annotation just with the given text
    Annotation document = new Annotation(text);

    // run all Annotators on this text
    pipeline.annotate(document);

}

}

错误如下

Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/pipeline/StanfordCoreNLP
    at SentimentAnalysis.main(SentimentAnalysis.java:39)
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLP
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

1 回答

相关问题