package udacity.storm.tools;

import java.util.Properties;

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.util.CoreMap;

public class SentimentAnalyzer {
    static StanfordCoreNLP pipeline;
 
    public static void init() {
    	Properties props = new Properties();
        props.setProperty("annotators", "tokenize,ssplit,parse,sentiment");
        pipeline = new StanfordCoreNLP(props);
    }
 
    public static int findSentiment(String tweet) {
 
        int mainSentiment = 0;
        if (tweet != null && tweet.length() > 0) {
            int longest = 0;
            Annotation annotation = pipeline.process(tweet);
            for (CoreMap sentence : annotation
                    .get(CoreAnnotations.SentencesAnnotation.class)) {
                Tree tree = sentence
                        .get(SentimentCoreAnnotations.AnnotatedTree.class);
                int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
                String partText = sentence.toString();
                if (partText.length() > longest) {
                    mainSentiment = sentiment;
                    longest = partText.length();
                }
 
            }
        }
        return mainSentiment;
    }
}
@@ -655,25 +655,170 @@
 ops);%0A    %7D%0A
- 
+%0A    public static int getBinarySentiment(int sentiment)%7B%0A        if(sentiment%3C=2)%0A            return 0;%0A        else%0A            return 1;%0A    %7D%0A
 %0A    public 
@@ -1187,16 +1187,20 @@
 entence%0A
+    
         
@@ -1263,24 +1263,24 @@
 ree.class);%0A
-
             
@@ -1416,17 +1416,16 @@
       if
- 
 (partTex
@@ -1445,17 +1445,16 @@
 longest)
- 
 %7B%0A      
@@ -1561,18 +1561,16 @@
       %7D%0A
- %0A
         
@@ -1600,16 +1600,35 @@
  return 
+getBinarySentiment(
 mainSent
@@ -1632,17 +1632,18 @@
 entiment
+)
 ;%0A    %7D%0A
 %7D
@@ -1641,9 +1641,10 @@
 ;%0A    %7D%0A
-
 %7D
+%0A

Use binary scores to represent sentiment in map