1
votes

I want to include Stanford CoreNLP in my Unity3D project. I included CoreNLP from Nuget and downloaded the NLP models from CoreNLP. Then I copied the NLP model folder into the project -> bin -> Debug folder.

The code looks like this:

var jarRoot = @"stanford-corenlp-3.9.1-models\";
const string text = "Kosgi Santosh sent an email to Stanford University. He didn't get a reply.";
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("sutime.binders", "0");
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);

// Annotation
var annotation = new Annotation(text);
pipeline.annotate(annotation);
var sentences = annotation.get(typeof(CoreAnnotations.SentencesAnnotation));
if (sentences == null)
{
 return;
}
foreach (Annotation sentence in sentences as ArrayList)
{
 System.Console.WriteLine(sentence);
}

After running, I only got some Error info

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I searched SLF4J site however the solution only applies to Java project. How do I supposed to solve this in my C# project?

1

1 Answers

2
votes

First, go to the Visual Studio (I have VS 2017). Then go to the Tools menu and select NuGet Package Manager->Package Manager Console. The Package Manager Console will appear. Type this command: Install-Package slf4j-NetCommonLogging -Version 1.7.5.4 and press Enter key. The VS will install slf4j-NetCommonLogging dll file for your project and it will run correctly without any errors or warnings. Enjoy.