Below is my code running into console application in visual studio
using System;
using System.Collections.Generic;
using edu.stanford.nlp.ling;
using edu.stanford.nlp.pipeline;
using edu.stanford.nlp.util;
namespace ConsoleApp1
{
class Program
{
readonly static java.lang.Class sentencesAnnotationClass =
new CoreAnnotations.SentencesAnnotation().getClass();
readonly static java.lang.Class tokensAnnotationClass =
new CoreAnnotations.TokensAnnotation().getClass();
readonly static java.lang.Class textAnnotationClass =
new CoreAnnotations.TextAnnotation().getClass();
readonly static java.lang.Class partOfSpeechAnnotationClass =
new CoreAnnotations.PartOfSpeechAnnotation().getClass();
readonly static java.lang.Class namedEntityTagAnnotationClass =
new CoreAnnotations.NamedEntityTagAnnotation().getClass();
readonly static java.lang.Class normalizedNamedEntityTagAnnotation =
new CoreAnnotations.NormalizedNamedEntityTagAnnotation().getClass();
static void Main(string[] args)
{
// creates a StanfordCoreNLP object with POS tagging, lemmatization, NER, parsing, and coreference resolution
var props = new java.util.Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
props.setProperty("ner.useSUTime", "0");
StanfordCoreNLPClient pipeline = new StanfordCoreNLPClient(props, "http://localhost", 9000, 2);
// read some text in the text variable
var text = "Kosgi Santosh sent an email to Stanford University.";
// create an empty Annotation just with the given text
Annotation document = new Annotation(text);
// run all Annotators on this text
pipeline.annotate(document);
var sentences = document.get(sentencesAnnotationClass) as java.util.AbstractList;
foreach (CoreMap sentence in sentences)
{
var tokens = sentence.get(tokensAnnotationClass) as java.util.AbstractList;
Console.WriteLine("----");
foreach (CoreLabel token in tokens)
{
var word = token.get(textAnnotationClass);
var pos = token.get(partOfSpeechAnnotationClass);
var ner = token.get(namedEntityTagAnnotationClass);
Console.WriteLine("{0}\t[pos={1};\tner={2};", word, pos, ner);
}
}
}
}
}
In below screen short of highlighted line execution then getting null value.
I am trying since long time why this above line giving null value, actually my requirement is NER to involve into my project thats the reason executing this code.
