java - 线程 "main"java.lang.NoClassDefFoundError : edu/stanford/nlp/pipeline/StanfordCoreNLP 中出现异常

标签 java nlp stanford-nlp

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

import edu.stanford.nlp.pipeline.*;

导入java.util.*;

公共(public)类情感分析{

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

最佳答案

使用以下步骤验证 jar

关于java - 线程 "main"java.lang.NoClassDefFoundError : edu/stanford/nlp/pipeline/StanfordCoreNLP 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47167485/

相关文章:

java - 使用 Ant API 编译 Java 文件时出错 - "error starting modern compiler"

java - 将 drools guvnor 5.5 升级到 drools 6.0

python - 如何在文本 block 中找到所有已知成分字符串?

stanford-nlp - CoreNLP 加载语言特定属性失败

java - 在 Android Studio 中翻译 Java 文件中的字符串值

java - 声明主方法同步

nlp - 是否有必要在使用 Spacy、Bert 时对文本分类进行停用词移除、词干提取/词形还原?

Python Gensim : how to calculate document similarity using the LDA model?

python - 如何导入 Stanford POS Tagger

java - Stanford-CoreNLP 和 Stanford-Parser 中的 Maven 类名冲突