PII real-time analysis (API) - Amazon Comprehend

PII real-time analysis (API)

Amazon Comprehend provides real-time synchronous API operations to analyze personally identifiable information (PII) in a document.

Locating PII real-time entities (API)

To locate PII in a single document, you can use the Amazon Comprehend DetectPiiEntities operation. Your input text can include up to 100 kilobytes of UTF-8 encoded characters. Supported languages include English and Spanish.

Locating PII using (CLI)

The following example uses the DetectPiiEntities operation with the AWS CLI.

The example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

aws comprehend detect-pii-entities \ --text "Hello Paul Santos. The latest statement for your credit card \ account 1111-0000-1111-0000 was mailed to 123 Any Street, Seattle, WA \ 98109." \ --language-code en

Amazon Comprehend responds with the following:

{ "Entities": [ { "Score": 0.9999669790267944, "Type": "NAME", "BeginOffset": 6, "EndOffset": 18 }, { "Score": 0.8905550241470337, "Type": "CREDIT_DEBIT_NUMBER", "BeginOffset": 69, "EndOffset": 88 }, { "Score": 0.9999889731407166, "Type": "ADDRESS", "BeginOffset": 103, "EndOffset": 138 } ] }

Labeling PII real-time entities (API)

You can use real-time synchronous API operations to return the labels of identified PII entity types. For more information, see Labeling PII entities.

Labeling PII entities (CLI)

The following example uses the ContainsPiiEntities operation with the AWS CLI.

The example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

aws comprehend contains-pii-entities \ --text "Hello Paul Santos. The latest statement for your credit card \ account 1111-0000-1111-0000 was mailed to 123 Any Street, Seattle, WA \ 98109." \ --language-code en

Amazon Comprehend responds with the following:

{ "Labels": [ { "Name": "NAME", "Score": 0.9149109721183777 }, { "Name": "CREDIT_DEBIT_NUMBER", "Score": 0.8905550241470337 } { "Name": "ADDRESS", "Score": 0.9951046109199524 } ] }