detectTargetedSentiment method

Future<DetectTargetedSentimentResponse> detectTargetedSentiment({
  1. required LanguageCode languageCode,
  2. required String text,
})

Inspects the input text and returns a sentiment analysis for each entity identified in the text.

For more information about targeted sentiment, see Targeted sentiment in the Amazon Comprehend Developer Guide.

May throw InternalServerException. May throw InvalidRequestException. May throw TextSizeLimitExceededException. May throw UnsupportedLanguageException.

Parameter languageCode : The language of the input documents. Currently, English is the only supported language.

Parameter text : A UTF-8 text string. The maximum string length is 5 KB.

Implementation

Future<DetectTargetedSentimentResponse> detectTargetedSentiment({
  required LanguageCode languageCode,
  required String text,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Comprehend_20171127.DetectTargetedSentiment'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'LanguageCode': languageCode.value,
      'Text': text,
    },
  );

  return DetectTargetedSentimentResponse.fromJson(jsonResponse.body);
}