我正在尝试运行此处提供的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();
}
}
当我运行代码时,出现以下错误:
我做错了什么?我真的很想让它起作用。:(java.lang.RuntimeException类型的第一次机会异常在stanford-corenlp-3.6.0.dll中发生 java.lang.RuntimeException类型的未处理异常在stanford-corenlp-3.6.0.dll中发生 额外信息:edu.stanford.nlp.io.RuntimeIOException: 加载标签模型时出错(可能是缺少模型文件)