Skip to content

batch_detect_syntax async

batch_detect_syntax(
    text_list: CustomerInputStringList,
    language_code: SyntaxLanguageCode,
    *,
    config_overrides: Optional[AsyncComprehendClientConfig] = None,
) -> BatchDetectSyntaxResponse

Inspects the text of a batch of documents for the syntax and part of speech of the words in the document and returns information about them. For more information, see Syntax in the Comprehend Developer Guide.

Parameters:

  • text_list (CustomerInputStringList) –

    A list containing the UTF-8 encoded text of the input documents. The list can contain a maximum of 25 documents. The maximum size for each document is 5 KB.

  • language_code (SyntaxLanguageCode) –

    The language 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"). All documents must be in the same language.

Raises:

Source code in docs_src/capo_comprehend/_services/async_comprehend.py
async def batch_detect_syntax(
    self,
    text_list: "capo_comprehend.types.customer_input_string_list.CustomerInputStringList",
    language_code: "capo_comprehend.types.syntax_language_code.SyntaxLanguageCode",
    *,
    config_overrides: Optional[AsyncComprehendClientConfig] = None,
) -> "capo_comprehend.types.batch_detect_syntax_response.BatchDetectSyntaxResponse":
    """<p>Inspects the text of a batch of documents for the syntax and part of speech of the words in the document and returns information about them. For more information, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/how-syntax.html">Syntax</a> in the Comprehend Developer Guide. </p>

    Args:
        text_list: <p>A list containing the UTF-8 encoded text of the input documents. The list can contain a maximum of 25 documents. The maximum size for each document is 5 KB.</p>
        language_code: <p>The language 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"). All documents must be in the same language.</p>

    Raises:
        capo_comprehend.errors.batch_size_limit_exceeded_exception.BatchSizeLimitExceededException: <p>The number of documents in the request exceeds the limit of 25. Try your request again with fewer documents.</p>
        capo_comprehend.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_comprehend.errors.invalid_request_exception.InvalidRequestException: <p>The request is invalid.</p>
        capo_comprehend.errors.text_size_limit_exceeded_exception.TextSizeLimitExceededException: <p>The size of the input text exceeds the limit. Use a smaller document.</p>
        capo_comprehend.errors.unsupported_language_exception.UnsupportedLanguageException: <p>Amazon Comprehend can't process the language of the input text. For a list of supported languages, <a href="https://docs.aws.amazon.com/comprehend/latest/dg/supported-languages.html">Supported languages</a> in the Comprehend Developer Guide. </p>
        capo_comprehend.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_comprehend.types.batch_detect_syntax_request.BatchDetectSyntaxRequest]",
    ) -> AsyncOperationResponse[
        "capo_comprehend.types.batch_detect_syntax_response.BatchDetectSyntaxResponse"
    ]:
        import capo_comprehend._operations.comprehend_20171127.batch_detect_syntax

        (
            output,
            http_response,
        ) = await capo_comprehend._operations.comprehend_20171127.batch_detect_syntax.async_batch_detect_syntax(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_comprehend.types.batch_detect_syntax_request.BatchDetectSyntaxRequest",
    ) -> dict[str, Any]:
        import capo_comprehend.types.batch_detect_syntax_request

        return capo_comprehend.types.batch_detect_syntax_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("BatchDetectSyntax", redact_input=_redact_input),
    )
    input_: capo_comprehend.types.batch_detect_syntax_request.BatchDetectSyntaxRequest = {
        "text_list": text_list,
        "language_code": language_code,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output