I downloaded stanford core nlp packages and tried to test it on my machine.
Using command: java -cp \"*\" -mx1g edu.stanford.nlp.sentiment.SentimentPipeline -f
This is working fine for me -
Maven Dependencies :
edu.stanford.nlp
stanford-corenlp
3.5.2
models
edu.stanford.nlp
stanford-corenlp
3.5.2
edu.stanford.nlp
stanford-parser
3.5.2
Java Code :
public static void main(String[] args) throws IOException {
String text = "This World is an amazing place";
Properties props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, parse, sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = pipeline.process(text);
List sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
String sentiment = sentence.get(SentimentCoreAnnotations.SentimentClass.class);
System.out.println(sentiment + "\t" + sentence);
}
}
Results :
Very positive This World is an amazing place