// Path: src/sentimentr-service/src/main/java/io/pivotal/fe/sentiment/engine/NLP.java
// public class NLP {
//     static StanfordCoreNLP pipeline;
//  
//     public static void init() {
//         pipeline = new StanfordCoreNLP("nlp.properties");
//     }
//   
//     public static int findSentiment(String text) {
//  
//         int mainSentiment = 0;
//         if (text != null && text.length() > 0) {
//             int longest = 0;
//             Annotation annotation = pipeline.process(text);
//             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;
//     }
// }


import io.pivotal.fe.sentiment.engine.NLP;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
package io.pivotal.fe.sentiment;





@SpringBootApplication
@RestController
public class SentimentAnayticsServiceApplication {

	@RequestMapping("/env")
	public Map<String,Object> env(HttpServletRequest request) {
	    Map<String,Object> model = new HashMap<String,Object>();
	    model.put("ip", request.getLocalAddr());
	    model.put("port", request.getLocalPort());
		return model;
	}

	@RequestMapping("/sentiment/{text}")
	public Map<String,Object> sentiment(@PathVariable String text, HttpServletRequest request) {
// Path: src/sentimentr-service/src/main/java/io/pivotal/fe/sentiment/engine/NLP.java
// public class NLP {
//     static StanfordCoreNLP pipeline;
//  
//     public static void init() {
//         pipeline = new StanfordCoreNLP("nlp.properties");
//     }
//   
//     public static int findSentiment(String text) {
//  
//         int mainSentiment = 0;
//         if (text != null && text.length() > 0) {
//             int longest = 0;
//             Annotation annotation = pipeline.process(text);
//             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;
//     }
// }


// Path: src/sentimentr-service/src/main/java/io/pivotal/fe/sentiment/SentimentAnayticsServiceApplication.java
import io.pivotal.fe.sentiment.engine.NLP;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

package io.pivotal.fe.sentiment;





@SpringBootApplication
@RestController
public class SentimentAnayticsServiceApplication {

	@RequestMapping("/env")
	public Map<String,Object> env(HttpServletRequest request) {
	    Map<String,Object> model = new HashMap<String,Object>();
	    model.put("ip", request.getLocalAddr());
	    model.put("port", request.getLocalPort());
		return model;
	}

	@RequestMapping("/sentiment/{text}")
	public Map<String,Object> sentiment(@PathVariable String text, HttpServletRequest request) {
		int sentiment = NLP.findSentiment(text);