【发布时间】:2017-06-12 08:31:10
【问题描述】:
尝试运行示例但我一直无法打开“english-left3words-distim.tagger”文件可能丢失。文件没有丢失,目录指向模型jar文件的位置,jar文件中路径:edu\stanford\nlp\models\pos-tagger\english-left3words是正确的。
我正在使用 3.7.0,从 Visual Studio 2015 中的 nuget 安装。
下面是代码:
var jarRoot = @"E:\VS Projects\Stanford.NLP.NET-master\Jar-files";
// 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");
// 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 document = new Annotation(text);
pipeline.annotate(document);
// Result - Pretty Print
using (var stream = new ByteArrayOutputStream())
{
pipeline.prettyPrint(document, new PrintWriter(stream));
Console.WriteLine(stream.toString());
stream.close();
}
我确实在 Stack 上看到了一个类似的问题,他们没有指向 jar 文件,但我指向的是 jar 文件所在的正确位置。有什么想法吗?
【问题讨论】:
标签: c# stanford-nlp