DetectSentiment and DetectDominantLanguage are two of Comprehend's simplest pretrained calls, and two of the most commonly combined. Sentiment analysis needs to know what language it is scoring, and language detection is the fastest way to find that out when you don't already know it.
This page covers both operations on their own, then the two-step pattern of detecting language first and passing the result into sentiment.
DetectSentiment returns a top-level Sentiment label - POSITIVE, NEGATIVE, NEUTRAL, or MIXED - and a SentimentScore object with a confidence value for all four, always summing close to 1.0. The label is simply whichever score is highest; if your use case cares about degree, not just direction, read SentimentScore directly rather than branching only on Sentiment.
MIXED is a real, distinct outcome, not a fallback for "unsure." Comprehend assigns it when a passage contains genuinely conflicting sentiment - praise and complaint in the same sentence, for example - and it is common in product reviews and support tickets. Treat it as its own routing bucket (often "needs human review") rather than discarding it or forcing it into positive or negative.
DetectDominantLanguage returns Languages, a list of {LanguageCode, Score} pairs, potentially more than one for text that mixes languages or is too short to classify confidently. There is no LanguageCode parameter on the request - detecting it is the entire point of the call, which is a common point of confusion for people used to every other Detect operation requiring one.
Sentiment models are language-specific under the hood. Passing an incorrect LanguageCode - English text tagged as Spanish, for instance - does not usually raise an error; it silently returns a lower-quality or misleading sentiment score, because the wrong language model was applied. This is why the detect-then-score pattern in the working example matters whenever the input language isn't already known with certainty, rather than defaulting every call to "en".
Both operations return probabilistic scores, not ground truth. Very short text (a few words), sarcasm, and domain-specific slang all reduce reliability. For high-stakes routing decisions, treat a low top score - on either the language or the sentiment call - as a signal to fall back to a default path or human review rather than trusting a marginal result.
Defaulting every call to LanguageCode: "en" - text in another language gets scored through the wrong model with no error raised. Fix: run DetectDominantLanguage first whenever the input language isn't already known.
Ignoring MIXED as if it were an error - it is a valid, meaningful sentiment outcome. Fix: route MIXED results to a dedicated handling path instead of coercing them to positive or negative.
Reading only the Sentiment label and discarding SentimentScore - you lose the confidence margin between labels. Fix: check SentimentScore when a close call (for example Positive 0.52 vs Neutral 0.45) matters to your logic.
Trusting a single-word or very short DetectDominantLanguage result - confidence drops sharply on short strings. Fix: concatenate more context before detecting language, or treat low scores as "unknown" rather than authoritative.
Scoring sentiment per sentence and averaging - this can wash out a MIXED signal that only appears across the whole passage. Fix: score the full passage in one call when sentiment depends on overall context.
POSITIVE, NEGATIVE, NEUTRAL, and MIXED. MIXED means the text contains genuinely conflicting sentiment, not that the model is unsure.
Why does DetectSentiment need a LanguageCode but DetectDominantLanguage doesn't?
Sentiment scoring uses a language-specific model, so it needs to know which one to apply. Detecting the language is the entire purpose of DetectDominantLanguage, so it takes no language input.
What happens if I pass the wrong LanguageCode to DetectSentiment?
The call typically still returns a result, but accuracy degrades because the wrong language model was applied - there is usually no explicit error, which makes this an easy mistake to miss.
Can DetectDominantLanguage return more than one language?
Yes. Languages is a list, and text that mixes languages or is very short can return multiple candidates - pick the highest Score if you only need one.
Should I trust sentiment scores on very short text?
Be cautious. A few words gives the model less context, and both sentiment and language detection scores tend to be less reliable on very short strings.
Is there a bulk way to score sentiment for many documents?
Yes - StartSentimentDetectionJob runs the same model asynchronously across an S3 prefix of documents and writes scored results to another S3 prefix.
Does Comprehend support more than a handful of languages for sentiment?
Sentiment and language detection support a range of languages via LanguageCode, but coverage varies by operation - check the current service documentation for the exact supported list before depending on a specific language.