Stanford CoreNLP for .NET – get SemanticGraph for document annotation

I’m using the .NET port of Stanford’s CoreNLP:

I have dependency extraction working for single sentences, but I can’t figure out how to get a SemanticGraph for an entire document. This is roughly what I do for a sentence:

var document = new Annotation(text);
var sentences = (document.get(typeof(CoreAnnotations.SentencesAnnotation)) as java.util.ArrayList).Cast<Annotation>().ToList();
var sentence = sentences.Single();
var dependencies = sentence.get(typeof(SemanticGraphCoreAnnotations.CollapsedCCProcessedDependenciesAnnotation)) as SemanticGraph;

But how do I get a SemanticGraph from a document annotation representing multiple sentences? For example “John bought a car. It was fast.” I need to be able to link “It” in the second sentence with “car” in the first sentence. Is this possible?

(Also: I find the members and types exposed through this .NET port rather confusing and I’m not sure that my above, rather verbose, syntax is the correct way to do this for sentences. Is it?)

Source: .net

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.