2020/09/17 - Amazon Comprehend - 5 new api methods
Changes Amazon Comprehend now supports detecting Personally Identifiable Information (PII) entities in a document.
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 )
dict
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.
string
Identifies the next page of results to return.
integer
The maximum number of results to return in each page.
dict
Response Syntax
{ 'PiiEntitiesDetectionJobPropertiesList': [ { 'JobId': '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' }, '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', ], '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.
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.
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.
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.
Stops a PII entities detection job in progress.
See also: AWS API Documentation
Request Syntax
client.stop_pii_entities_detection_job( JobId='string' )
string
[REQUIRED]
The identifier of the PII entities detection job to stop.
dict
Response Syntax
{ 'JobId': 'string', 'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED' }
Response Structure
(dict) --
JobId (string) --
The identifier of the PII entities detection job to stop.
JobStatus (string) --
The status of the PII entities detection job.
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' )
string
[REQUIRED]
The identifier that Amazon Comprehend generated for the job. The operation returns this identifier in its response.
dict
Response Syntax
{ 'PiiEntitiesDetectionJobProperties': { 'JobId': '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' }, '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', ], '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.
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.
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.
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.
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' )
string
[REQUIRED]
A UTF-8 text string. Each string must contain fewer that 5,000 bytes of UTF-8 encoded characters.
string
[REQUIRED]
The language of the input documents.
dict
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', '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.
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' }, 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', ], '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' )
dict
[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.
dict
[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.
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"
string
[REQUIRED]
Specifies whether the output provides the locations (offsets) of PII entities or a file in which PII entities are redacted.
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.
string
[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.
string
The identifier of the job.
string
[REQUIRED]
The language of the input documents.
string
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.
dict
Response Syntax
{ 'JobId': 'string', 'JobStatus': 'SUBMITTED'|'IN_PROGRESS'|'COMPLETED'|'FAILED'|'STOP_REQUESTED'|'STOPPED' }
Response Structure
(dict) --
JobId (string) --
The identifier generated for the job.
JobStatus (string) --
The status of the job.