【问题标题】:how can solve java exception error [duplicate]如何解决java异常错误[重复]
【发布时间】:2018-05-10 10:20:35
【问题描述】:

我正在使用 java 语言在 Eclipse 中工作,但是在编写 用于标记文本的 POS 标准 API 代码。 PLZ,任何人都可以帮助我, 错误如下

"Exception in thread "main" java.lang.NoClassDefFoundError: 
 org/slf4j/LoggerFactory at edu.stanford.nlp.pipeline.StanfordCoreNLP. 
(StanfordCore.<clinit>(StanfordCoreNLP.java:99)
at tweetfileanalysis.TweetPOS.tweettag(TweetPOS.java:23)
at tweetfileanalysis.ReadJson.readJsonf(ReadJson.java:288)
at tweetfileanalysis.Mainclass.main(Mainclass.java:17)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown 
Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more

我通过使用配置构建路径来放置所有库,所以我可以做些什么来解决类代码的错误如下:

package tweetfileanalysis;

import edu.stanford.nlp.ie.util.RelationTriple;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.naturalli.NaturalLogicAnnotations;
import edu.stanford.nlp.util.CoreMap;

import java.util.Collection;
import java.util.Properties;


public class TweetPOS{

public TweetPOS() 
{}
 public static void tweettag(String tweet) 
 {
 // Create the Stanford CoreNLP pipeline
    Properties props = new Properties();
    props.getProperty("annotators", 
 "tokenize,ssplit,pos,lemma,depparse,natlog,openie");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

    // Annotate an example document.
    Annotation doc = new Annotation("Obama was born in Hawaii. He is our 
  president.");
    pipeline.annotate(doc);
  System.out.println("fhfbg");
    // Loop over sentences in the document
    for (CoreMap sentence : 
  doc.get(CoreAnnotations.SentencesAnnotation.class)) {
      // Get the OpenIE triples for the sentence
     Collection<RelationTriple> triples = 
 sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
      // Print the triples
    System.out.println("uuuuuuuuuuuuuuuuuuu");
      for (RelationTriple triple : triples) {
        System.out.println(triple.confidence + "\t" +
            triple.subjectLemmaGloss() + "\t" +
            triple.relationLemmaGloss() + "\t" +
            triple.objectLemmaGloss());
      }
    } 
    }

}

【问题讨论】:

    标签: java eclipse


    【解决方案1】:

    下载 slf4j.jar here 并配置您的构建路径。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-23
      • 2013-06-07
      • 1970-01-01
      • 2014-09-02
      • 2012-01-12
      • 2011-10-20
      • 1970-01-01
      • 2019-07-11
      相关资源
      最近更新 更多