Search in sources :

Example 1 with EmotionScores

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());
}
Also used : AnalyzeOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions) EmotionScores(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionScores) AnalysisResults(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults) EmotionOptions(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionOptions) Features(com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest) Test(org.junit.Test)

Aggregations

WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 AnalysisResults (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults)1 AnalyzeOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions)1 EmotionOptions (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionOptions)1 EmotionScores (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionScores)1 Features (com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features)1 Test (org.junit.Test)1