use of com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionScores in project java-sdk by watson-developer-cloud.
the class NaturalLanguageUnderstandingIT method analyzeTextForEmotionsWithoutTargetsIsSuccessful.
/**
* Analyze input text for emotions without targets.
*
* @throws Exception the exception
*/
@Test
public void analyzeTextForEmotionsWithoutTargetsIsSuccessful() throws Exception {
String text = "But I believe this thinking is wrong. I believe the road of true democracy remains the better path." + " I believe that in the 21st century, economies can only grow to a certain point until they need to open up" + " -- because entrepreneurs need to access information in order to invent; young people need a global" + " education in order to thrive; independent media needs to check the abuses of power.";
EmotionOptions emotion = new EmotionOptions.Builder().build();
Features features = new Features.Builder().emotion(emotion).build();
AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build();
AnalysisResults results = service.analyze(parameters).execute();
assertNotNull(results);
assertNotNull(results.getAnalyzedText());
assertNotNull(results.getEmotion());
assertNotNull(results.getEmotion().getDocument());
assertNotNull(results.getEmotion().getDocument().getEmotion());
EmotionScores scores = results.getEmotion().getDocument().getEmotion();
assertNotNull(scores.getAnger());
assertNotNull(scores.getDisgust());
assertNotNull(scores.getFear());
assertNotNull(scores.getJoy());
assertNotNull(scores.getSadness());
assertNull(results.getEmotion().getTargets());
}
Aggregations