detectSyntax method

Future<DetectSyntaxResponse> detectSyntax({
  1. required SyntaxLanguageCode languageCode,
  2. required String text,
})

Inspects text for syntax and the part of speech of words in the document. For more information, how-syntax.

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

Parameter languageCode : The language code of the input documents. You can specify any of the following languages supported by Amazon Comprehend: German ("de"), English ("en"), Spanish ("es"), French ("fr"), Italian ("it"), or Portuguese ("pt").

Parameter text : A UTF-8 string. Each string must contain fewer that 5,000 bytes of UTF encoded characters.

Implementation

Future<DetectSyntaxResponse> detectSyntax({
  required SyntaxLanguageCode languageCode,
  required String text,
}) async {
  ArgumentError.checkNotNull(languageCode, 'languageCode');
  ArgumentError.checkNotNull(text, 'text');
  _s.validateStringLength(
    'text',
    text,
    1,
    1152921504606846976,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Comprehend_20171127.DetectSyntax'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'LanguageCode': languageCode.toValue(),
      'Text': text,
    },
  );

  return DetectSyntaxResponse.fromJson(jsonResponse.body);
}