【问题标题】:SLF4J Error when using CoreNLP in C#在 C# 中使用 CoreNLP 时出现 SLF4J 错误
【发布时间】:2018-11-06 17:31:33
【问题描述】:

我想在我的 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) 记录器实现

SLF4J:请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder 更多细节。

我搜索了 SLF4J 站点,但该解决方案仅适用于 Java 项目。我应该如何在我的 C# 项目中解决这个问题?

【问题讨论】:

    标签: c# stanford-nlp slf4j


    【解决方案1】:

    首先,进入 Visual Studio(我有 VS 2017)。然后转到“工具”菜单并选择“NuGet 包管理器”->“包管理器控制台”。包管理器控制台将出现。键入此命令:Install-Package slf4j-NetCommonLogging -Version 1.7.5.4 并按 Enter 键。 VS 将为您的项目安装 slf4j-NetCommonLogging dll 文件,它将正确运行而不会出现任何错误或警告。享受吧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 2014-11-17
      • 2020-01-15
      • 1970-01-01
      相关资源
      最近更新 更多