detectSentiment method
Future<DetectSentimentResponse>
detectSentiment({
- required LanguageCode languageCode,
- required String text,
Inspects text and returns an inference of the prevailing sentiment
(POSITIVE, NEUTRAL, MIXED, or
NEGATIVE).
May throw InternalServerException.
May throw InvalidRequestException.
May throw TextSizeLimitExceededException.
May throw UnsupportedLanguageException.
Parameter languageCode :
The language of the input documents. You can specify any of the primary
languages supported by Amazon Comprehend. All documents must be in the
same language.
Parameter text :
A UTF-8 text string. The maximum string size is 5 KB.
Implementation
Future<DetectSentimentResponse> detectSentiment({
required LanguageCode languageCode,
required String text,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Comprehend_20171127.DetectSentiment'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'LanguageCode': languageCode.value,
'Text': text,
},
);
return DetectSentimentResponse.fromJson(jsonResponse.body);
}