我想在我的Unity3D项目中包含Stanford CoreNLP . 我从Nuget收录了CoreNLP,并从CoreNLP下载了NLP模型 . 然后我将NLP模型文件夹复制到 project -> bin -> Debug
文件夹中 .
代码如下所示:
var jarRoot = @"stanford-corenlp-3.9.1-models\";
const string text = "Kosgi Santosh sent an email to Stanford University. He didn't get a reply.";
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("sutime.binders", "0");
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
// Annotation
var annotation = new Annotation(text);
pipeline.annotate(annotation);
var sentences = annotation.get(typeof(CoreAnnotations.SentencesAnnotation));
if (sentences == null)
{
return;
}
foreach (Annotation sentence in sentences as ArrayList)
{
System.Console.WriteLine(sentence);
}
运行后,我只收到一些错误信息
SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder” . SLF4J:默认为无操作(NOP) Logger 实现SLF4J:有关更多详细信息,请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder .
我搜索了SLF4J网站,但该解决方案仅适用于Java项目 . 我怎么能在我的C#项目中解决这个问题?
1 回答
SLF4J是一个Java日志库,与您的C#项目无关 .
似乎CoreNLP(我个人并不熟悉)是一个Java应用程序 . 您需要修复该应用程序的配置,以便在其classpath中包含Java SLF4J binding library . 有关于在_1330504中设置CoreNLP类路径的说明;我建议仔细检查你是否正确配置了CoreNLP .