Skip to content

detect_pii_entities

detect_pii_entities(
    text: String,
    language_code: LanguageCode,
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
) -> DetectPiiEntitiesResponse

Inspects the input text for entities that contain personally identifiable information (PII) and returns information about them.

Parameters:

  • text (String) –

    A UTF-8 text string. The maximum string size is 100 KB.

  • language_code (LanguageCode) –

    The language of the input text. Enter the language code for English (en) or Spanish (es).

Raises:

Source code in docs_src/capo_comprehend/_services/comprehend.py
def detect_pii_entities(
    self,
    text: "capo_comprehend.types.string.String",
    language_code: "capo_comprehend.types.language_code.LanguageCode",
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
) -> "capo_comprehend.types.detect_pii_entities_response.DetectPiiEntitiesResponse":
    """<p>Inspects the input text for entities that contain personally identifiable information (PII) and returns information about them.</p>

    Args:
        text: <p>A UTF-8 text string. The maximum string size is 100 KB.</p>
        language_code: <p>The language of the input text. Enter the language code for English (en) or Spanish (es).</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.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.
    """

    def _handler(
        req: "OperationRequest[capo_comprehend.types.detect_pii_entities_request.DetectPiiEntitiesRequest]",
    ) -> OperationResponse[
        "capo_comprehend.types.detect_pii_entities_response.DetectPiiEntitiesResponse"
    ]:
        import capo_comprehend._operations.comprehend_20171127.detect_pii_entities

        output, http_response = (
            capo_comprehend._operations.comprehend_20171127.detect_pii_entities.detect_pii_entities(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DetectPiiEntities")
    )
    input_: capo_comprehend.types.detect_pii_entities_request.DetectPiiEntitiesRequest = {
        "text": text,
        "language_code": language_code,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output