我的目标是测试这些代码,以确保Stanford安装正确。首先,我使用StanfordCOreNLP包管理器安装了NuGet包,然后下载了一个包含需要使用jar -xf命令安装的jar文件的zip文件,然后运行代码。
在(var pipeline = new StanfordCoreNLP(props);),我收到一个错误,上面写着:
edu.stanford.nlp.io.RuntimeIOException:加载标签模型时出错(可能缺少模型文件)“ 内部异常IOException:无法将open"edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger“作为类路径、文件名或URL
var jarRoot = @"D:/VisualStudioProjects/C#MachineLearningProjects/Chapter3TwiterSentiment/CoreNLPTest2/CoreNLPTest2/edu/stanford/nlp/models/pos-tagger";
var text = "We're going to test our CoreNLP instalation!!";
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("ner.useSUTime", "0");
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
var annotation = new Annotation(text);
pipeline.annotate(annotation);
using (var stream = new ByteArrayOutputStream())
{
pipeline.prettyPrint(annotation, new PrintWriter(stream));
Console.WriteLine(stream.toString());
stream.close();
}
Console.ReadKey();发布于 2020-01-13 19:41:05
请遵循以下步骤:
步骤1:下载核NLP
步骤2:解压缩d:\stanford-corenlp-满-2018-10-05
步骤3:解压缩d:\stanford-corenlp-full-2018-10-05\stanford-corenlp-3.9.2-models.jar
步骤4:更改var jarRoot =jarRoot
步骤5:将props.setProperty("ner.useSUTime","0");改为props.setProperty("sutime.binders","0")
https://stackoverflow.com/questions/59721899
复制相似问题