Frequently asked questions (FAQ)

Questions and Answers

How does it work? Where is C# source code for Stanford.NLP.NET?

Stanford.NLP.NET is built on top of IKVM.NET (Java VM that runs on top of .NET VM). There is no C# source code and no efforts for Java->C# code translation. This project uses IKVM.NET Bytecode Compiler that converts Java bytecode (*.jar) to .NET (*.dll).

I heard that IKVM.NET is dead, what will be with this project?

Yes, there is an official announcement of The End of IKVM.NET, but it does not mean the end of Stanford.NLP.NET. Current stable version of IKVM.NET has perfect support of Java 8 and we have a confirmation from Stanford NLP group that CoreNLP will remain Java 8 compatible for foreseeable future.

What NuGet package should I reference and use?

It really depends on your task, you always should try to choose one (referencing of more than one package is a not supported scenario). If your task is rather complicated or you do not know which one to choose - use Stanford.NLP.CoreNLP. This is an umbrella package that integrates all Stanford tools.

Stanford.NLP.CoreNLP not loading models

This is probably the most common problem with CoreNLP (especially for newcomers). stanfrod-corenlp-ful-*.zip archive contains files stanford-corenlp-3.8.0-models.jar with models inside (this is a zip archive). In Java world, you add this jar on the class path, and it automatically resolves models' location in the archive.

CoreNLP has a file DefaultPaths.java that specifies path to model file. So when you instantiate StanfordCoreNLP with Properties object that does not specify models' location, you should guarantee that models could be found by default path (related to Environment.CurrentDirectory).

The simplest way to guarantee existence of files at path like Environment.CurrentDirectory + "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz" is to unzip a jar archive to the folder, and temporary change the current directory to the unzipped folder.

1: 
2: 
3: 
4: 
5: 
6: 
var jarRoot = "nlp.stanford.edu/stanford-corenlp-full-2016-10-31/jar-modules/";
...
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(jarRoot);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);

The other way is to specify paths to all models that your pipeline needs (it actually depends on the list of annotators). This option is more complicated because you have to find correct property keys, and specify paths to all used model. But it may be useful if you want to minimize the size of your deployment package.

1: 
2: 
3: 
4: 
5: 
6: 
var props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, depparse");
props.put("ner.model",
          "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz");
props.put("ner.applyNumericClassifiers", "false");
var pipeline = new StanfordCoreNLP(props);

StackOverflow Exception

You probably try to execute code under IIS Express. So you have two options here: deploy to IIS or run under 64bit version of IIS Express. In VS2015 it is./ under Tools> Options> Projects and Solutions > Web Projects > Use the 64 bit version of IIS Express for web sites and projects

Fork me on GitHub