尝试运行示例,但我一直无法打开" english-left3words-distsim.tagger"文件可能丢失了。该文件不会丢失,该目录指向模型jar文件的位置,路径:edu \ stanford \ nlp \ models \ pos-tagger \ english-left3words在jar文件中是正确的。
我使用的是3.7.0,在2015年的visual studio中安装了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文件存在的正确位置。有什么想法吗?
答案 0 :(得分:1)
最终我将目录指向实际文件夹,解压缩的jar文件,并且工作正常。非常令人困惑的是,一个堆栈问题恰恰相反......