Determines the dominant language of the input text. For a list of languages that Amazon Comprehend can detect, see Amazon Comprehend Supported Languages.
Parameters:
-
text
(CustomerInputString)
–
A UTF-8 text string. The string must contain at least 20 characters. The maximum string size is 100 KB.
Raises:
Source code in docs_src/capo_comprehend/_services/comprehend.py
| def detect_dominant_language(
self,
text: "capo_comprehend.types.customer_input_string.CustomerInputString",
*,
config_overrides: Optional[ComprehendClientConfig] = None,
) -> "capo_comprehend.types.detect_dominant_language_response.DetectDominantLanguageResponse":
"""<p>Determines the dominant language of the input text. For a list of languages that Amazon Comprehend can detect, see <a href="https://docs.aws.amazon.com/comprehend/latest/dg/how-languages.html">Amazon Comprehend Supported Languages</a>. </p>
Args:
text: <p>A UTF-8 text string. The string must contain at least 20 characters. The maximum string size is 100 KB.</p>
Raises:
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.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_comprehend.types.detect_dominant_language_request.DetectDominantLanguageRequest]",
) -> OperationResponse[
"capo_comprehend.types.detect_dominant_language_response.DetectDominantLanguageResponse"
]:
import capo_comprehend._operations.comprehend_20171127.detect_dominant_language
output, http_response = (
capo_comprehend._operations.comprehend_20171127.detect_dominant_language.detect_dominant_language(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_comprehend.types.detect_dominant_language_request.DetectDominantLanguageRequest",
) -> dict[str, Any]:
import capo_comprehend.types.detect_dominant_language_request
return (
capo_comprehend.types.detect_dominant_language_request.redact_sensitive(
input_
)
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("DetectDominantLanguage", redact_input=_redact_input),
)
input_: capo_comprehend.types.detect_dominant_language_request.DetectDominantLanguageRequest = {
"text": text
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|