Skip to content

DetectSentiment

Source: src/AWS/Comprehend/DetectSentiment.ts

Runtime binding for comprehend:DetectSentiment — infer the prevailing sentiment of a piece of text (POSITIVE, NEGATIVE, NEUTRAL, or MIXED).

Comprehend’s synchronous detect APIs are pure pay-per-call with no resource to manage: the binding takes no arguments and grants the function comprehend:DetectSentiment (the action has no resource-level IAM).

// init
const detectSentiment = yield* AWS.Comprehend.DetectSentiment();
// runtime
const result = yield* detectSentiment({
Text: "I love this product, it works wonderfully!",
LanguageCode: "en",
});
// result.Sentiment === "POSITIVE"
// result.SentimentScore.Positive ~ 0.99