program for tagger and sentiment analysis in stanford nlp

◇◆丶佛笑我妖孽 提交于 2019-12-08 12:02:09

问题


I have a c# code (though copied) im getting error at this statement ->var pipeline = new StanfordCoreNLP(props); (An unhandled exception of type 'java.lang.RuntimeException' occurred in stanford-corenlp-3.7.0.dll

Additional information: edu.stanford.nlp.io.RuntimeIOException: Error while loading a tagger model (probably missing model file))

my models n core nlp are of same version stanford-corenlp-3.7.0-models.jar stanford-corenlp-3.7.0.jar

any help wold be greatly appreciated !!


回答1:


Many sources advised to extract 'stanford-corenlp-full-2017-06-09'(link) folder and add extracted 'stanford-corenlp-3.8.0-models.jar' to the project.

I tried many methods, to change its properties 'Build Action to Content and the Copy to Output Directory setting to Copy if newer', but couldn't find a solution to perform the same for multiple files in inner folders.

So, What I did is :

Extracted 'stanford-corenlp-3.8.0-models.jar' and copied it to 'bin/debug'. And my code is as follows:

var jarRoot = @"stanford-corenlp-3.8.0-models\";
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, parse, sentiment");
props.setProperty("sutime.binders", "0");
var curDir = Environment.CurrentDirectory;
var modelsDirectory = curDir + "\\" + jarRoot + @"\edu\stanford\nlp\models";
Directory.SetCurrentDirectory(jarRoot);

// Loading POS Tagger
var tagger = new MaxentTagger(modelsDirectory + @"\pos-tagger\english-left3words\english-left3words-distsim.tagger");

var pipeline = new StanfordCoreNLP(props);

Its working fine for me with this settings and code.

Note: The version changes should be made. Also in production environment, it should be handled differently(and I dont know how!!!).



来源:https://stackoverflow.com/questions/43677813/program-for-tagger-and-sentiment-analysis-in-stanford-nlp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!