首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Visual、C#和StanfordCoreNLP问题

Visual、C#和StanfordCoreNLP问题
EN

Stack Overflow用户
提问于 2020-01-13 18:10:16
回答 1查看 405关注 0票数 0

我的目标是测试这些代码,以确保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

代码语言:javascript
复制
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();
EN

回答 1

Stack Overflow用户

发布于 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")

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59721899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档