Robert Guzman
Robert Guzman

Reputation: 11

Stanford NLP CoreNLP .NET

Trying to run example but I keep getting an unable to open the "english-left3words-distsim.tagger" file is probably missing. The file is not missing, the directory points to the location of the model jar files, the path: edu\stanford\nlp\models\pos-tagger\english-left3words is correct in the jar file.

I'm using 3.7.0, installed from nuget in visual studio 2015.

Below is the code:

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();
        }

I did see a similar question on Stack where they were not pointing to the jar file but I am pointing to the correct location of where the jar file exists. Any ideas?

Upvotes: 0

Views: 1956

Answers (1)

Robert Guzman
Robert Guzman

Reputation: 11

Ultimately I pointed the directory to the actual folder, decompressed jar file, and that worked. Very confusing that one stack question stated the exact opposite...

Upvotes: 1

Related Questions