detectToxicContent method
Future<DetectToxicContentResponse>
detectToxicContent({
- required LanguageCode languageCode,
- required List<
TextSegment> textSegments,
Performs toxicity analysis on the list of text strings that you provide as input. The API response contains a results list that matches the size of the input list. For more information about toxicity detection, see Toxicity detection 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 text. Currently, English is the only supported
language.
Parameter textSegments :
A list of up to 10 text strings. Each string has a maximum size of 1 KB,
and the maximum size of the list is 10 KB.
Implementation
Future<DetectToxicContentResponse> detectToxicContent({
required LanguageCode languageCode,
required List<TextSegment> textSegments,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Comprehend_20171127.DetectToxicContent'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'LanguageCode': languageCode.value,
'TextSegments': textSegments,
},
);
return DetectToxicContentResponse.fromJson(jsonResponse.body);
}