wolverene
wolverene

Reputation: 11

Visual Studio, C# and StanfordCoreNLP problem

My goal is to test this code to make sure that Stanford Core NLP installed properly. First I installed StanfordCOreNLP package using NuGet package manager and then I downloaded a zip file that contained a jar file that needed to be installed using jar -xf command , and then I ran the code.

At (var pipeline = new StanfordCoreNLP(props);) I'm getting an error that says:

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

Inner Exception IOException:Unable to open"edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as class path, filename or 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();

Upvotes: 0

Views: 709

Answers (1)

vinbalraj
vinbalraj

Reputation: 21

Please follow the below steps:

Step 1: Download Core NLP
Step 2: Unzip d:\stanford-corenlp-full-2018-10-05
Step 3: Unzip d:\stanford-corenlp-full-2018-10-05\stanford-corenlp-3.9.2-models.jar
Step 4: Change var jarRoot = @"d:/stanford-corenlp-full-2018-10-05/stanford-corenlp-3.9.2-models";
Step 5: Change props.setProperty("ner.useSUTime", "0"); to props.setProperty("sutime.binders", "0")

Upvotes: 1

Related Questions