I'm using the Stanford NLP tools in C#, via the IKVM Java interface. Also getting ideas from https://sergey-tihon.github.io/Stanford.NLP.NET/StanfordCoreNLP.html
String text = "This is a test sentence.";
var props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, parse");
var curDir = Environment.CurrentDirectory;
Directory.SetCurrentDirectory(modelsDirectory);
var pipeline = new StanfordCoreNLP(props);
Directory.SetCurrentDirectory(curDir);
var annotation = new Annotation(text);
pipeline.annotate(annotation);
This code works fine to get my Annotation
. However, when I try to access the annotation to extract various entities in the annotation, I run into trouble. Using code from this: How can I split a text into sentences using the Stanford parser?
List<CoreMap> sentences = annotation.get(SentencesAnnotation.class);
Not clear how to translate SentencesAnnotation.class
into something that C# will accept.