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

时间:2017-11-07 21:08:55

标签: java nlp stanford-nlp

我从https://stanfordnlp.github.io/CoreNLP/下载了stanford corenlp压缩文件然后解压缩并插入其中。现在我尝试运行以下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。*;

公共课堂情感分析{

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 个答案:

答案 0 :(得分:0)

使用以下步骤验证jar