如何解决java异常错误

时间:2018-05-10 10:20:36

标签: java eclipse

我在使用java语言在eclipse中工作但写错时我有错误 用于标记文本的POS standford 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

我使用configure build path放置所有库,那么我该如何解决类代码的错误如下:

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());
      }
    } 
    }

}

1 个答案:

答案 0 :(得分:0)

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