c# - 在 C# 中使用 CoreNLP 时出现 SLF4J 错误
问题描述
我想将斯坦福 CoreNLP 包含在我的 Unity3D 项目中。我从 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# 项目中解决这个问题?
解决方案
首先,转到 Visual Studio(我有 VS 2017)。然后转到“工具”菜单并选择“NuGet 包管理器”->“包管理器控制台”。包管理器控制台将出现。键入此命令:Install-Package slf4j-NetCommonLogging -Version 1.7.5.4 并按 Enter 键。VS 将为您的项目安装 slf4j-NetCommonLogging dll 文件,它将正常运行而不会出现任何错误或警告。享受。
推荐阅读
- assembly - 不推荐使用架构的 HLA 编译问题
- google-maps - 如何在 Ionic 3 上使用本地谷歌地图显示路线
- python - 如何处理不返回错误的代码?
- r - 从连续月份的列制作日期列
- java - org.h2.jdbc.JdbcSQLException: NULL 不允许用于列“ID”;@GeneratedValue(strategy = GenerationType.IDENTITY) id 的 SQL 语句问题
- python - 已安装 Python 库但无法导入
- angular - Angular 6路由:同一页面的不同参数
- amazon-web-services - AppSync 检查 DynamoDB 记录是否存在
- html - 第一个孩子增加内容的宽度,直到父边界调用溢出椭圆
- javascript - 使用 requirejs 在 angularjs 中使用 Highcharts 时出错。自定义指令抛出错误