use of software.amazon.awssdk.services.comprehend.model.DetectSentimentResponse in project aws-doc-sdk-examples by awsdocs.
the class DetectSentiment method detectSentiments.
// snippet-start:[comprehend.java2.detect_sentiment.main]
public static void detectSentiments(ComprehendClient comClient, String text) {
try {
DetectSentimentRequest detectSentimentRequest = DetectSentimentRequest.builder().text(text).languageCode("en").build();
DetectSentimentResponse detectSentimentResult = comClient.detectSentiment(detectSentimentRequest);
System.out.println("The Neutral value is " + detectSentimentResult.sentimentScore().neutral());
} catch (ComprehendException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations