Exemple #1
0
        private StafordCoreNlpSentimentClass FindSentiment(string text)
        {
            var sentimentList = new List <int>();

            if (!String.IsNullOrWhiteSpace(text))
            {
                var annotation = _nlp.process(text);

                var SentencesAnnotationClass    = new edu.stanford.nlp.ling.CoreAnnotations.SentencesAnnotation().getClass();
                var SentimentAnnotatedTreeClass = new edu.stanford.nlp.sentiment.SentimentCoreAnnotations.AnnotatedTree().getClass();

                java.util.ArrayList bla = (java.util.ArrayList)annotation.get(SentencesAnnotationClass);


                foreach (edu.stanford.nlp.util.CoreMap sentence in bla)
                {
                    var tree      = (edu.stanford.nlp.trees.Tree)sentence.get(SentimentAnnotatedTreeClass);
                    int sentiment = edu.stanford.nlp.neural.rnn.RNNCoreAnnotations.getPredictedClass(tree);
                    sentimentList.Add(sentiment);
                }
            }

            return(SummarizeSentiment(sentimentList));
        }