【发布时间】:2016-11-26 02:58:38
【问题描述】:
我正在尝试运行示例代码provided here for Stanford.NLP for .NET。
我通过 Nuget 安装了该软件包,下载了 CoreNLP zip 存档,并解压缩了 stanford-corenlp-3.7.0-models.jar。解压后,我找到了 stanford-corenlp-full-2016-10-31\edu\stanford\nlp\models 中的“models”目录。
这是我要运行的代码:
public static void Test1()
{
// Path to the folder with models extracted from `stanford-corenlp-3.6.0-models.jar`
var jarRoot = @"..\..\..\stanford-corenlp-full-2016-10-31\edu\stanford\nlp\models\";
// Text for processing
var text = "Kosgi Santosh sent an email to Stanford University. He didn't get a reply.";
// Annotation pipeline configuration
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, parse, ner,dcoref");
props.setProperty("ner.useSUTime", "0");
// We should change current directory, so StanfordCoreNLP could find all the model files automatically
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
// Annotation
var annotation = new Annotation(text);
pipeline.annotate(annotation);
// Result - Pretty Print
using (var stream = new ByteArrayOutputStream())
{
pipeline.prettyPrint(annotation, new PrintWriter(stream));
Console.WriteLine(stream.toString());
stream.close();
}
}
运行代码时出现以下错误:
在 stanford-corenlp-3.6.0.dll 中发生了“java.lang.RuntimeException”类型的第一次机会异常 stanford-corenlp-3.6.0.dll 中发生了“java.lang.RuntimeException”类型的未处理异常 附加信息:edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model(可能缺少模型文件)
我做错了什么?我真的很想让这个工作。 :(
【问题讨论】:
标签: c# .net nlp stanford-nlp