我正在开发一个 java 项目,使用斯坦福 nlp 库从文本中提取主语、谓语、宾语。 我写了这段代码
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
String text = "the quick fox jumps over the lazy dog";
Annotation document = new Annotation(text);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(SentencesAnnotation.class);
for (CoreMap sentence: sentences) {
for (CoreLabel token: sentence.get(TokensAnnotation.class)) {
String word = token.get(TextAnnotation.class);
String pos = token.get(PartOfSpeechAnnotation.class);
String ne = token.get(NamedEntityTagAnnotation.class);
}
Tree tree = sentence.get(TreeAnnotation.class);
SemanticGraph dependencies =
sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
}
Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);
我有一个异常(exception):
Exception in thread "main" java.lang.NoClassDefFoundError: de/jollyday/HolidayManager.
at test_ir.Main.main(Main.java:88)
Caused by: java.lang.ClassNotFoundException: de.jollyday.HolidayManager
最佳答案
确保 jollyday jar 文件在运行时位于类路径中。这应该可以解决你的问题。
关于java - Java 斯坦福图书馆异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22760291/