Amazon Comprehend

2022/05/20 - Amazon Comprehend - 5 updated api methods

Changes  Comprehend releases 14 new entity types for DetectPiiEntities and ContainsPiiEntities APIs.

ContainsPiiEntities (updated) Link ¶
Changes (response)
{'Labels': {'Name': {'CA_HEALTH_NUMBER',
                     'CA_SOCIAL_INSURANCE_NUMBER',
                     'INTERNATIONAL_BANK_ACCOUNT_NUMBER',
                     'IN_AADHAAR',
                     'IN_NREGA',
                     'IN_PERMANENT_ACCOUNT_NUMBER',
                     'IN_VOTER_NUMBER',
                     'LICENSE_PLATE',
                     'SWIFT_CODE',
                     'UK_NATIONAL_HEALTH_SERVICE_NUMBER',
                     'UK_NATIONAL_INSURANCE_NUMBER',
                     'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER',
                     'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER',
                     'VEHICLE_IDENTIFICATION_NUMBER'}}}

Analyzes input text for the presence of personally identifiable information (PII) and returns the labels of identified PII entity types such as name, address, bank account number, or phone number.

See also: AWS API Documentation

Request Syntax

client.contains_pii_entities(
    Text='string',
    LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW'
)
type Text

string

param Text

[REQUIRED]

Creates a new document classification request to analyze a single document in real-time, returning personally identifiable information (PII) entity labels.

type LanguageCode

string

param LanguageCode

[REQUIRED]

The language of the input documents. Currently, English is the only valid language.

rtype

dict

returns

Response Syntax

{
    'Labels': [
        {
            'Name': 'BANK_ACCOUNT_NUMBER'|'BANK_ROUTING'|'CREDIT_DEBIT_NUMBER'|'CREDIT_DEBIT_CVV'|'CREDIT_DEBIT_EXPIRY'|'PIN'|'EMAIL'|'ADDRESS'|'NAME'|'PHONE'|'SSN'|'DATE_TIME'|'PASSPORT_NUMBER'|'DRIVER_ID'|'URL'|'AGE'|'USERNAME'|'PASSWORD'|'AWS_ACCESS_KEY'|'AWS_SECRET_KEY'|'IP_ADDRESS'|'MAC_ADDRESS'|'ALL'|'LICENSE_PLATE'|'VEHICLE_IDENTIFICATION_NUMBER'|'UK_NATIONAL_INSURANCE_NUMBER'|'CA_SOCIAL_INSURANCE_NUMBER'|'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER'|'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER'|'IN_PERMANENT_ACCOUNT_NUMBER'|'IN_NREGA'|'INTERNATIONAL_BANK_ACCOUNT_NUMBER'|'SWIFT_CODE'|'UK_NATIONAL_HEALTH_SERVICE_NUMBER'|'CA_HEALTH_NUMBER'|'IN_AADHAAR'|'IN_VOTER_NUMBER',
            'Score': ...
        },
    ]
}

Response Structure

  • (dict) --

    • Labels (list) --

      The labels used in the document being analyzed. Individual labels represent personally identifiable information (PII) entity types.

      • (dict) --

        Specifies one of the label or labels that categorize the personally identifiable information (PII) entity being analyzed.

        • Name (string) --

          The name of the label.

        • Score (float) --

          The level of confidence that Amazon Comprehend has in the accuracy of the detection.

DescribePiiEntitiesDetectionJob (updated) Link ¶
Changes (response)
{'PiiEntitiesDetectionJobProperties': {'RedactionConfig': {'PiiEntityTypes': {'CA_HEALTH_NUMBER',
                                                                              'CA_SOCIAL_INSURANCE_NUMBER',
                                                                              'INTERNATIONAL_BANK_ACCOUNT_NUMBER',
                                                                              'IN_AADHAAR',
                                                                              'IN_NREGA',
                                                                              'IN_PERMANENT_ACCOUNT_NUMBER',
                                                                              'IN_VOTER_NUMBER',
                                                                              'LICENSE_PLATE',
                                                                              'SWIFT_CODE',
                                                                              'UK_NATIONAL_HEALTH_SERVICE_NUMBER',
                                                                              'UK_NATIONAL_INSURANCE_NUMBER',
                                                                              'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER',
                                                                              'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER',
                                                                              'VEHICLE_IDENTIFICATION_NUMBER'}}}}

Gets the properties associated with a PII entities detection job. For example, you can use this operation to get the job status.

See also: AWS API Documentation

Request Syntax

client.describe_pii_entities_detection_job(
    JobId='string'
)
type JobId

string

param JobId

[REQUIRED]

The identifier that Amazon Comprehend generated for the job. The operation returns this identifier in its response.

rtype

dict

returns

Response Syntax

{
    'PiiEntitiesDetectionJobProperties': {
        'JobId': 'string',
        'JobArn': 'string',
        'JobName': 'string',
        'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED',
        'Message': 'string',
        'SubmitTime': datetime(2015, 1, 1),
        'EndTime': datetime(2015, 1, 1),
        'InputDataConfig': {
            'S3Uri': 'string',
            'InputFormat': 'ONE_DOC_PER_FILE'|'ONE_DOC_PER_LINE',
            'DocumentReaderConfig': {
                'DocumentReadAction': 'TEXTRACT_DETECT_DOCUMENT_TEXT'|'TEXTRACT_ANALYZE_DOCUMENT',
                'DocumentReadMode': 'SERVICE_DEFAULT'|'FORCE_DOCUMENT_READ_ACTION',
                'FeatureTypes': [
                    'TABLES'|'FORMS',
                ]
            }
        },
        'OutputDataConfig': {
            'S3Uri': 'string',
            'KmsKeyId': 'string'
        },
        'RedactionConfig': {
            'PiiEntityTypes': [
                'BANK_ACCOUNT_NUMBER'|'BANK_ROUTING'|'CREDIT_DEBIT_NUMBER'|'CREDIT_DEBIT_CVV'|'CREDIT_DEBIT_EXPIRY'|'PIN'|'EMAIL'|'ADDRESS'|'NAME'|'PHONE'|'SSN'|'DATE_TIME'|'PASSPORT_NUMBER'|'DRIVER_ID'|'URL'|'AGE'|'USERNAME'|'PASSWORD'|'AWS_ACCESS_KEY'|'AWS_SECRET_KEY'|'IP_ADDRESS'|'MAC_ADDRESS'|'ALL'|'LICENSE_PLATE'|'VEHICLE_IDENTIFICATION_NUMBER'|'UK_NATIONAL_INSURANCE_NUMBER'|'CA_SOCIAL_INSURANCE_NUMBER'|'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER'|'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER'|'IN_PERMANENT_ACCOUNT_NUMBER'|'IN_NREGA'|'INTERNATIONAL_BANK_ACCOUNT_NUMBER'|'SWIFT_CODE'|'UK_NATIONAL_HEALTH_SERVICE_NUMBER'|'CA_HEALTH_NUMBER'|'IN_AADHAAR'|'IN_VOTER_NUMBER',
            ],
            'MaskMode': 'MASK'|'REPLACE_WITH_PII_ENTITY_TYPE',
            'MaskCharacter': 'string'
        },
        'LanguageCode': 'en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW',
        'DataAccessRoleArn': 'string',
        'Mode': 'ONLY_REDACTION'|'ONLY_OFFSETS'
    }
}

Response Structure

  • (dict) --

    • PiiEntitiesDetectionJobProperties (dict) --

      Provides information about a PII entities detection job.

      • JobId (string) --

        The identifier assigned to the PII entities detection job.

      • JobArn (string) --

        The Amazon Resource Name (ARN) of the PII entities detection job. It is a unique, fully qualified identifier for the job. It includes the AWS account, Region, and the job ID. The format of the ARN is as follows:

        arn:<partition>:comprehend:<region>:<account-id>:pii-entities-detection-job/<job-id>

        The following is an example job ARN:

        arn:aws:comprehend:us-west-2:111122223333:pii-entities-detection-job/1234abcd12ab34cd56ef1234567890ab

      • JobName (string) --

        The name that you assigned the PII entities detection job.

      • JobStatus (string) --

        The current status of the PII entities detection job. If the status is FAILED , the Message field shows the reason for the failure.

      • Message (string) --

        A description of the status of a job.

      • SubmitTime (datetime) --

        The time that the PII entities detection job was submitted for processing.

      • EndTime (datetime) --

        The time that the PII entities detection job completed.

      • InputDataConfig (dict) --

        The input properties for a PII entities detection job.

        • S3Uri (string) --

          The Amazon S3 URI for the input data. The URI must be in same region as the API endpoint that you are calling. The URI can point to a single input file or it can provide the prefix for a collection of data files.

          For example, if you use the URI S3://bucketName/prefix , if the prefix is a single file, Amazon Comprehend uses that file as input. If more than one file begins with the prefix, Amazon Comprehend uses all of them as input.

        • InputFormat (string) --

          Specifies how the text in an input file should be processed:

          • ONE_DOC_PER_FILE - Each file is considered a separate document. Use this option when you are processing large documents, such as newspaper articles or scientific papers.

          • ONE_DOC_PER_LINE - Each line in a file is considered a separate document. Use this option when you are processing many short documents, such as text messages.

        • DocumentReaderConfig (dict) --

          The document reader config field applies only for InputDataConfig of StartEntitiesDetectionJob.

          Use DocumentReaderConfig to provide specifications about how you want your inference documents read. Currently it applies for PDF documents in StartEntitiesDetectionJob custom inference.

          • DocumentReadAction (string) --

            This enum field will start with two values which will apply to PDFs:

            • TEXTRACT_DETECT_DOCUMENT_TEXT - The service calls DetectDocumentText for PDF documents per page.

            • TEXTRACT_ANALYZE_DOCUMENT - The service calls AnalyzeDocument for PDF documents per page.

          • DocumentReadMode (string) --

            This enum field provides two values:

            • SERVICE_DEFAULT - use service defaults for Document reading. For Digital PDF it would mean using an internal parser instead of Textract APIs

            • FORCE_DOCUMENT_READ_ACTION - Always use specified action for DocumentReadAction, including Digital PDF.

          • FeatureTypes (list) --

            Specifies how the text in an input file should be processed:

            • (string) --

              A list of the types of analyses to perform. This field specifies what feature types need to be extracted from the document where entity recognition is expected.

              • TABLES - Add TABLES to the list to return information about the tables that are detected in the input document.

              • FORMS - Add FORMS to return detected form data.

      • OutputDataConfig (dict) --

        The output data configuration that you supplied when you created the PII entities detection job.

        • S3Uri (string) --

          When you use the PiiOutputDataConfig object with asynchronous operations, you specify the Amazon S3 location where you want to write the output data.

          For a PII entity detection job, the output file is plain text, not a compressed archive. The output file name is the same as the input file, with .out appended at the end.

        • KmsKeyId (string) --

          ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to encrypt the output results from an analysis job.

      • RedactionConfig (dict) --

        Provides configuration parameters for PII entity redaction.

        This parameter is required if you set the Mode parameter to ONLY_REDACTION . In that case, you must provide a RedactionConfig definition that includes the PiiEntityTypes parameter.

        • PiiEntityTypes (list) --

          An array of the types of PII entities that Amazon Comprehend detects in the input text for your request.

          • (string) --

        • MaskMode (string) --

          Specifies whether the PII entity is redacted with the mask character or the entity type.

        • MaskCharacter (string) --

          A character that replaces each character in the redacted PII entity.

      • LanguageCode (string) --

        The language code of the input documents

      • DataAccessRoleArn (string) --

        The Amazon Resource Name (ARN) that gives Amazon Comprehend read access to your input data.

      • Mode (string) --

        Specifies whether the output provides the locations (offsets) of PII entities or a file in which PII entities are redacted.

DetectPiiEntities (updated) Link ¶
Changes (response)
{'Entities': {'Type': {'CA_HEALTH_NUMBER',
                       'CA_SOCIAL_INSURANCE_NUMBER',
                       'INTERNATIONAL_BANK_ACCOUNT_NUMBER',
                       'IN_AADHAAR',
                       'IN_NREGA',
                       'IN_PERMANENT_ACCOUNT_NUMBER',
                       'IN_VOTER_NUMBER',
                       'LICENSE_PLATE',
                       'SWIFT_CODE',
                       'UK_NATIONAL_HEALTH_SERVICE_NUMBER',
                       'UK_NATIONAL_INSURANCE_NUMBER',
                       'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER',
                       'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER',
                       'VEHICLE_IDENTIFICATION_NUMBER'}}}

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

See also: AWS API Documentation

Request Syntax

client.detect_pii_entities(
    Text='string',
    LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW'
)
type Text

string

param Text

[REQUIRED]

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

type LanguageCode

string

param LanguageCode

[REQUIRED]

The language of the input documents. Currently, English is the only valid language.

rtype

dict

returns

Response Syntax

{
    'Entities': [
        {
            'Score': ...,
            'Type': 'BANK_ACCOUNT_NUMBER'|'BANK_ROUTING'|'CREDIT_DEBIT_NUMBER'|'CREDIT_DEBIT_CVV'|'CREDIT_DEBIT_EXPIRY'|'PIN'|'EMAIL'|'ADDRESS'|'NAME'|'PHONE'|'SSN'|'DATE_TIME'|'PASSPORT_NUMBER'|'DRIVER_ID'|'URL'|'AGE'|'USERNAME'|'PASSWORD'|'AWS_ACCESS_KEY'|'AWS_SECRET_KEY'|'IP_ADDRESS'|'MAC_ADDRESS'|'ALL'|'LICENSE_PLATE'|'VEHICLE_IDENTIFICATION_NUMBER'|'UK_NATIONAL_INSURANCE_NUMBER'|'CA_SOCIAL_INSURANCE_NUMBER'|'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER'|'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER'|'IN_PERMANENT_ACCOUNT_NUMBER'|'IN_NREGA'|'INTERNATIONAL_BANK_ACCOUNT_NUMBER'|'SWIFT_CODE'|'UK_NATIONAL_HEALTH_SERVICE_NUMBER'|'CA_HEALTH_NUMBER'|'IN_AADHAAR'|'IN_VOTER_NUMBER',
            'BeginOffset': 123,
            'EndOffset': 123
        },
    ]
}

Response Structure

  • (dict) --

    • Entities (list) --

      A collection of PII entities identified in the input text. For each entity, the response provides the entity type, where the entity text begins and ends, and the level of confidence that Amazon Comprehend has in the detection.

      • (dict) --

        Provides information about a PII entity.

        • Score (float) --

          The level of confidence that Amazon Comprehend has in the accuracy of the detection.

        • Type (string) --

          The entity's type.

        • BeginOffset (integer) --

          A character offset in the input text that shows where the PII entity begins (the first character is at position 0). The offset returns the position of each UTF-8 code point in the string. A code point is the abstract character from a particular graphical representation. For example, a multi-byte UTF-8 character maps to a single code point.

        • EndOffset (integer) --

          A character offset in the input text that shows where the PII entity ends. The offset returns the position of each UTF-8 code point in the string. A code point is the abstract character from a particular graphical representation. For example, a multi-byte UTF-8 character maps to a single code point.

ListPiiEntitiesDetectionJobs (updated) Link ¶
Changes (response)
{'PiiEntitiesDetectionJobPropertiesList': {'RedactionConfig': {'PiiEntityTypes': {'CA_HEALTH_NUMBER',
                                                                                  'CA_SOCIAL_INSURANCE_NUMBER',
                                                                                  'INTERNATIONAL_BANK_ACCOUNT_NUMBER',
                                                                                  'IN_AADHAAR',
                                                                                  'IN_NREGA',
                                                                                  'IN_PERMANENT_ACCOUNT_NUMBER',
                                                                                  'IN_VOTER_NUMBER',
                                                                                  'LICENSE_PLATE',
                                                                                  'SWIFT_CODE',
                                                                                  'UK_NATIONAL_HEALTH_SERVICE_NUMBER',
                                                                                  'UK_NATIONAL_INSURANCE_NUMBER',
                                                                                  'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER',
                                                                                  'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER',
                                                                                  'VEHICLE_IDENTIFICATION_NUMBER'}}}}

Gets a list of the PII entity detection jobs that you have submitted.

See also: AWS API Documentation

Request Syntax

client.list_pii_entities_detection_jobs(
    Filter={
        'JobName': 'string',
        'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED',
        'SubmitTimeBefore': datetime(2015, 1, 1),
        'SubmitTimeAfter': datetime(2015, 1, 1)
    },
    NextToken='string',
    MaxResults=123
)
type Filter

dict

param Filter

Filters the jobs that are returned. You can filter jobs on their name, status, or the date and time that they were submitted. You can only set one filter at a time.

  • JobName (string) --

    Filters on the name of the job.

  • JobStatus (string) --

    Filters the list of jobs based on job status. Returns only jobs with the specified status.

  • SubmitTimeBefore (datetime) --

    Filters the list of jobs based on the time that the job was submitted for processing. Returns only jobs submitted before the specified time. Jobs are returned in ascending order, oldest to newest.

  • SubmitTimeAfter (datetime) --

    Filters the list of jobs based on the time that the job was submitted for processing. Returns only jobs submitted after the specified time. Jobs are returned in descending order, newest to oldest.

type NextToken

string

param NextToken

Identifies the next page of results to return.

type MaxResults

integer

param MaxResults

The maximum number of results to return in each page.

rtype

dict

returns

Response Syntax

{
    'PiiEntitiesDetectionJobPropertiesList': [
        {
            'JobId': 'string',
            'JobArn': 'string',
            'JobName': 'string',
            'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED',
            'Message': 'string',
            'SubmitTime': datetime(2015, 1, 1),
            'EndTime': datetime(2015, 1, 1),
            'InputDataConfig': {
                'S3Uri': 'string',
                'InputFormat': 'ONE_DOC_PER_FILE'|'ONE_DOC_PER_LINE',
                'DocumentReaderConfig': {
                    'DocumentReadAction': 'TEXTRACT_DETECT_DOCUMENT_TEXT'|'TEXTRACT_ANALYZE_DOCUMENT',
                    'DocumentReadMode': 'SERVICE_DEFAULT'|'FORCE_DOCUMENT_READ_ACTION',
                    'FeatureTypes': [
                        'TABLES'|'FORMS',
                    ]
                }
            },
            'OutputDataConfig': {
                'S3Uri': 'string',
                'KmsKeyId': 'string'
            },
            'RedactionConfig': {
                'PiiEntityTypes': [
                    'BANK_ACCOUNT_NUMBER'|'BANK_ROUTING'|'CREDIT_DEBIT_NUMBER'|'CREDIT_DEBIT_CVV'|'CREDIT_DEBIT_EXPIRY'|'PIN'|'EMAIL'|'ADDRESS'|'NAME'|'PHONE'|'SSN'|'DATE_TIME'|'PASSPORT_NUMBER'|'DRIVER_ID'|'URL'|'AGE'|'USERNAME'|'PASSWORD'|'AWS_ACCESS_KEY'|'AWS_SECRET_KEY'|'IP_ADDRESS'|'MAC_ADDRESS'|'ALL'|'LICENSE_PLATE'|'VEHICLE_IDENTIFICATION_NUMBER'|'UK_NATIONAL_INSURANCE_NUMBER'|'CA_SOCIAL_INSURANCE_NUMBER'|'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER'|'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER'|'IN_PERMANENT_ACCOUNT_NUMBER'|'IN_NREGA'|'INTERNATIONAL_BANK_ACCOUNT_NUMBER'|'SWIFT_CODE'|'UK_NATIONAL_HEALTH_SERVICE_NUMBER'|'CA_HEALTH_NUMBER'|'IN_AADHAAR'|'IN_VOTER_NUMBER',
                ],
                'MaskMode': 'MASK'|'REPLACE_WITH_PII_ENTITY_TYPE',
                'MaskCharacter': 'string'
            },
            'LanguageCode': 'en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW',
            'DataAccessRoleArn': 'string',
            'Mode': 'ONLY_REDACTION'|'ONLY_OFFSETS'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • PiiEntitiesDetectionJobPropertiesList (list) --

      A list containing the properties of each job that is returned.

      • (dict) --

        Provides information about a PII entities detection job.

        • JobId (string) --

          The identifier assigned to the PII entities detection job.

        • JobArn (string) --

          The Amazon Resource Name (ARN) of the PII entities detection job. It is a unique, fully qualified identifier for the job. It includes the AWS account, Region, and the job ID. The format of the ARN is as follows:

          arn:<partition>:comprehend:<region>:<account-id>:pii-entities-detection-job/<job-id>

          The following is an example job ARN:

          arn:aws:comprehend:us-west-2:111122223333:pii-entities-detection-job/1234abcd12ab34cd56ef1234567890ab

        • JobName (string) --

          The name that you assigned the PII entities detection job.

        • JobStatus (string) --

          The current status of the PII entities detection job. If the status is FAILED , the Message field shows the reason for the failure.

        • Message (string) --

          A description of the status of a job.

        • SubmitTime (datetime) --

          The time that the PII entities detection job was submitted for processing.

        • EndTime (datetime) --

          The time that the PII entities detection job completed.

        • InputDataConfig (dict) --

          The input properties for a PII entities detection job.

          • S3Uri (string) --

            The Amazon S3 URI for the input data. The URI must be in same region as the API endpoint that you are calling. The URI can point to a single input file or it can provide the prefix for a collection of data files.

            For example, if you use the URI S3://bucketName/prefix , if the prefix is a single file, Amazon Comprehend uses that file as input. If more than one file begins with the prefix, Amazon Comprehend uses all of them as input.

          • InputFormat (string) --

            Specifies how the text in an input file should be processed:

            • ONE_DOC_PER_FILE - Each file is considered a separate document. Use this option when you are processing large documents, such as newspaper articles or scientific papers.

            • ONE_DOC_PER_LINE - Each line in a file is considered a separate document. Use this option when you are processing many short documents, such as text messages.

          • DocumentReaderConfig (dict) --

            The document reader config field applies only for InputDataConfig of StartEntitiesDetectionJob.

            Use DocumentReaderConfig to provide specifications about how you want your inference documents read. Currently it applies for PDF documents in StartEntitiesDetectionJob custom inference.

            • DocumentReadAction (string) --

              This enum field will start with two values which will apply to PDFs:

              • TEXTRACT_DETECT_DOCUMENT_TEXT - The service calls DetectDocumentText for PDF documents per page.

              • TEXTRACT_ANALYZE_DOCUMENT - The service calls AnalyzeDocument for PDF documents per page.

            • DocumentReadMode (string) --

              This enum field provides two values:

              • SERVICE_DEFAULT - use service defaults for Document reading. For Digital PDF it would mean using an internal parser instead of Textract APIs

              • FORCE_DOCUMENT_READ_ACTION - Always use specified action for DocumentReadAction, including Digital PDF.

            • FeatureTypes (list) --

              Specifies how the text in an input file should be processed:

              • (string) --

                A list of the types of analyses to perform. This field specifies what feature types need to be extracted from the document where entity recognition is expected.

                • TABLES - Add TABLES to the list to return information about the tables that are detected in the input document.

                • FORMS - Add FORMS to return detected form data.

        • OutputDataConfig (dict) --

          The output data configuration that you supplied when you created the PII entities detection job.

          • S3Uri (string) --

            When you use the PiiOutputDataConfig object with asynchronous operations, you specify the Amazon S3 location where you want to write the output data.

            For a PII entity detection job, the output file is plain text, not a compressed archive. The output file name is the same as the input file, with .out appended at the end.

          • KmsKeyId (string) --

            ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to encrypt the output results from an analysis job.

        • RedactionConfig (dict) --

          Provides configuration parameters for PII entity redaction.

          This parameter is required if you set the Mode parameter to ONLY_REDACTION . In that case, you must provide a RedactionConfig definition that includes the PiiEntityTypes parameter.

          • PiiEntityTypes (list) --

            An array of the types of PII entities that Amazon Comprehend detects in the input text for your request.

            • (string) --

          • MaskMode (string) --

            Specifies whether the PII entity is redacted with the mask character or the entity type.

          • MaskCharacter (string) --

            A character that replaces each character in the redacted PII entity.

        • LanguageCode (string) --

          The language code of the input documents

        • DataAccessRoleArn (string) --

          The Amazon Resource Name (ARN) that gives Amazon Comprehend read access to your input data.

        • Mode (string) --

          Specifies whether the output provides the locations (offsets) of PII entities or a file in which PII entities are redacted.

    • NextToken (string) --

      Identifies the next page of results to return.

StartPiiEntitiesDetectionJob (updated) Link ¶
Changes (request)
{'RedactionConfig': {'PiiEntityTypes': {'CA_HEALTH_NUMBER',
                                        'CA_SOCIAL_INSURANCE_NUMBER',
                                        'INTERNATIONAL_BANK_ACCOUNT_NUMBER',
                                        'IN_AADHAAR',
                                        'IN_NREGA',
                                        'IN_PERMANENT_ACCOUNT_NUMBER',
                                        'IN_VOTER_NUMBER',
                                        'LICENSE_PLATE',
                                        'SWIFT_CODE',
                                        'UK_NATIONAL_HEALTH_SERVICE_NUMBER',
                                        'UK_NATIONAL_INSURANCE_NUMBER',
                                        'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER',
                                        'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER',
                                        'VEHICLE_IDENTIFICATION_NUMBER'}}}

Starts an asynchronous PII entity detection job for a collection of documents.

See also: AWS API Documentation

Request Syntax

client.start_pii_entities_detection_job(
    InputDataConfig={
        'S3Uri': 'string',
        'InputFormat': 'ONE_DOC_PER_FILE'|'ONE_DOC_PER_LINE',
        'DocumentReaderConfig': {
            'DocumentReadAction': 'TEXTRACT_DETECT_DOCUMENT_TEXT'|'TEXTRACT_ANALYZE_DOCUMENT',
            'DocumentReadMode': 'SERVICE_DEFAULT'|'FORCE_DOCUMENT_READ_ACTION',
            'FeatureTypes': [
                'TABLES'|'FORMS',
            ]
        }
    },
    OutputDataConfig={
        'S3Uri': 'string',
        'KmsKeyId': 'string'
    },
    Mode='ONLY_REDACTION'|'ONLY_OFFSETS',
    RedactionConfig={
        'PiiEntityTypes': [
            'BANK_ACCOUNT_NUMBER'|'BANK_ROUTING'|'CREDIT_DEBIT_NUMBER'|'CREDIT_DEBIT_CVV'|'CREDIT_DEBIT_EXPIRY'|'PIN'|'EMAIL'|'ADDRESS'|'NAME'|'PHONE'|'SSN'|'DATE_TIME'|'PASSPORT_NUMBER'|'DRIVER_ID'|'URL'|'AGE'|'USERNAME'|'PASSWORD'|'AWS_ACCESS_KEY'|'AWS_SECRET_KEY'|'IP_ADDRESS'|'MAC_ADDRESS'|'ALL'|'LICENSE_PLATE'|'VEHICLE_IDENTIFICATION_NUMBER'|'UK_NATIONAL_INSURANCE_NUMBER'|'CA_SOCIAL_INSURANCE_NUMBER'|'US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER'|'UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER'|'IN_PERMANENT_ACCOUNT_NUMBER'|'IN_NREGA'|'INTERNATIONAL_BANK_ACCOUNT_NUMBER'|'SWIFT_CODE'|'UK_NATIONAL_HEALTH_SERVICE_NUMBER'|'CA_HEALTH_NUMBER'|'IN_AADHAAR'|'IN_VOTER_NUMBER',
        ],
        'MaskMode': 'MASK'|'REPLACE_WITH_PII_ENTITY_TYPE',
        'MaskCharacter': 'string'
    },
    DataAccessRoleArn='string',
    JobName='string',
    LanguageCode='en'|'es'|'fr'|'de'|'it'|'pt'|'ar'|'hi'|'ja'|'ko'|'zh'|'zh-TW',
    ClientRequestToken='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type InputDataConfig

dict

param InputDataConfig

[REQUIRED]

The input properties for a PII entities detection job.

  • S3Uri (string) -- [REQUIRED]

    The Amazon S3 URI for the input data. The URI must be in same region as the API endpoint that you are calling. The URI can point to a single input file or it can provide the prefix for a collection of data files.

    For example, if you use the URI S3://bucketName/prefix , if the prefix is a single file, Amazon Comprehend uses that file as input. If more than one file begins with the prefix, Amazon Comprehend uses all of them as input.

  • InputFormat (string) --

    Specifies how the text in an input file should be processed:

    • ONE_DOC_PER_FILE - Each file is considered a separate document. Use this option when you are processing large documents, such as newspaper articles or scientific papers.

    • ONE_DOC_PER_LINE - Each line in a file is considered a separate document. Use this option when you are processing many short documents, such as text messages.

  • DocumentReaderConfig (dict) --

    The document reader config field applies only for InputDataConfig of StartEntitiesDetectionJob.

    Use DocumentReaderConfig to provide specifications about how you want your inference documents read. Currently it applies for PDF documents in StartEntitiesDetectionJob custom inference.

    • DocumentReadAction (string) -- [REQUIRED]

      This enum field will start with two values which will apply to PDFs:

      • TEXTRACT_DETECT_DOCUMENT_TEXT - The service calls DetectDocumentText for PDF documents per page.

      • TEXTRACT_ANALYZE_DOCUMENT - The service calls AnalyzeDocument for PDF documents per page.

    • DocumentReadMode (string) --

      This enum field provides two values:

      • SERVICE_DEFAULT - use service defaults for Document reading. For Digital PDF it would mean using an internal parser instead of Textract APIs

      • FORCE_DOCUMENT_READ_ACTION - Always use specified action for DocumentReadAction, including Digital PDF.

    • FeatureTypes (list) --

      Specifies how the text in an input file should be processed:

      • (string) --

        A list of the types of analyses to perform. This field specifies what feature types need to be extracted from the document where entity recognition is expected.

        • TABLES - Add TABLES to the list to return information about the tables that are detected in the input document.

        • FORMS - Add FORMS to return detected form data.

type OutputDataConfig

dict

param OutputDataConfig

[REQUIRED]

Provides configuration parameters for the output of PII entity detection jobs.

  • S3Uri (string) -- [REQUIRED]

    When you use the OutputDataConfig object with asynchronous operations, you specify the Amazon S3 location where you want to write the output data. The URI must be in the same region as the API endpoint that you are calling. The location is used as the prefix for the actual location of the output file.

    When the topic detection job is finished, the service creates an output file in a directory specific to the job. The S3Uri field contains the location of the output file, called output.tar.gz . It is a compressed archive that contains the ouput of the operation.

    For a PII entity detection job, the output file is plain text, not a compressed archive. The output file name is the same as the input file, with .out appended at the end.

  • KmsKeyId (string) --

    ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to encrypt the output results from an analysis job. The KmsKeyId can be one of the following formats:

    • KMS Key ID: "1234abcd-12ab-34cd-56ef-1234567890ab"

    • Amazon Resource Name (ARN) of a KMS Key: "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"

    • KMS Key Alias: "alias/ExampleAlias"

    • ARN of a KMS Key Alias: "arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias"

type Mode

string

param Mode

[REQUIRED]

Specifies whether the output provides the locations (offsets) of PII entities or a file in which PII entities are redacted.

type RedactionConfig

dict

param RedactionConfig

Provides configuration parameters for PII entity redaction.

This parameter is required if you set the Mode parameter to ONLY_REDACTION . In that case, you must provide a RedactionConfig definition that includes the PiiEntityTypes parameter.

  • PiiEntityTypes (list) --

    An array of the types of PII entities that Amazon Comprehend detects in the input text for your request.

    • (string) --

  • MaskMode (string) --

    Specifies whether the PII entity is redacted with the mask character or the entity type.

  • MaskCharacter (string) --

    A character that replaces each character in the redacted PII entity.

type DataAccessRoleArn

string

param DataAccessRoleArn

[REQUIRED]

The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that grants Amazon Comprehend read access to your input data.

type JobName

string

param JobName

The identifier of the job.

type LanguageCode

string

param LanguageCode

[REQUIRED]

The language of the input documents. Currently, English is the only valid language.

type ClientRequestToken

string

param ClientRequestToken

A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.

This field is autopopulated if not provided.

type Tags

list

param Tags

Tags to be associated with the PII entities detection job. A tag is a key-value pair that adds metadata to a resource used by Amazon Comprehend. For example, a tag with "Sales" as the key might be added to a resource to indicate its use by the sales department.

  • (dict) --

    A key-value pair that adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with the key-value pair ‘Department’:’Sales’ might be added to a resource to indicate its use by a particular department.

    • Key (string) -- [REQUIRED]

      The initial part of a key-value pair that forms a tag associated with a given resource. For instance, if you want to show which resources are used by which departments, you might use “Department” as the key portion of the pair, with multiple possible values such as “sales,” “legal,” and “administration.”

    • Value (string) --

      The second part of a key-value pair that forms a tag associated with a given resource. For instance, if you want to show which resources are used by which departments, you might use “Department” as the initial (key) portion of the pair, with a value of “sales” to indicate the sales department.

rtype

dict

returns

Response Syntax

{
    'JobId': 'string',
    'JobArn': 'string',
    'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED'
}

Response Structure

  • (dict) --

    • JobId (string) --

      The identifier generated for the job.

    • JobArn (string) --

      The Amazon Resource Name (ARN) of the PII entity detection job. It is a unique, fully qualified identifier for the job. It includes the AWS account, Region, and the job ID. The format of the ARN is as follows:

      arn:<partition>:comprehend:<region>:<account-id>:pii-entities-detection-job/<job-id>

      The following is an example job ARN:

      arn:aws:comprehend:us-west-2:111122223333:pii-entities-detection-job/1234abcd12ab34cd56ef1234567890ab

    • JobStatus (string) --

      The status of the job.