CfnDocumentClassifierPropsMixin
- class aws_cdk.mixins_preview.aws_comprehend.mixins.CfnDocumentClassifierPropsMixin(props, *, strategy=None)
Bases:
MixinThis resource creates and trains a document classifier to categorize documents.
You provide a set of training documents that are labeled with the categories that you want to identify. After the classifier is trained you can use it to categorize a set of labeled documents into the categories. For more information, see Document Classification in the Comprehend Developer Guide.
- See:
- CloudformationResource:
AWS::Comprehend::DocumentClassifier
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins cfn_document_classifier_props_mixin = comprehend_mixins.CfnDocumentClassifierPropsMixin(comprehend_mixins.CfnDocumentClassifierMixinProps( data_access_role_arn="dataAccessRoleArn", document_classifier_name="documentClassifierName", input_data_config=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierInputDataConfigProperty( augmented_manifests=[comprehend_mixins.CfnDocumentClassifierPropsMixin.AugmentedManifestsListItemProperty( attribute_names=["attributeNames"], s3_uri="s3Uri", split="split" )], data_format="dataFormat", document_reader_config=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentReaderConfigProperty( document_read_action="documentReadAction", document_read_mode="documentReadMode", feature_types=["featureTypes"] ), documents=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierDocumentsProperty( s3_uri="s3Uri", test_s3_uri="testS3Uri" ), document_type="documentType", label_delimiter="labelDelimiter", s3_uri="s3Uri", test_s3_uri="testS3Uri" ), language_code="languageCode", mode="mode", model_kms_key_id="modelKmsKeyId", model_policy="modelPolicy", output_data_config=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierOutputDataConfigProperty( kms_key_id="kmsKeyId", s3_uri="s3Uri" ), tags=[CfnTag( key="key", value="value" )], version_name="versionName", volume_kms_key_id="volumeKmsKeyId", vpc_config=comprehend_mixins.CfnDocumentClassifierPropsMixin.VpcConfigProperty( security_group_ids=["securityGroupIds"], subnets=["subnets"] ) ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::Comprehend::DocumentClassifier.- Parameters:
props (
Union[CfnDocumentClassifierMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['dataAccessRoleArn', 'documentClassifierName', 'inputDataConfig', 'languageCode', 'mode', 'modelKmsKeyId', 'modelPolicy', 'outputDataConfig', 'tags', 'versionName', 'volumeKmsKeyId', 'vpcConfig']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
AugmentedManifestsListItemProperty
- class CfnDocumentClassifierPropsMixin.AugmentedManifestsListItemProperty(*, attribute_names=None, s3_uri=None, split=None)
Bases:
objectAn augmented manifest file that provides training data for your custom model.
An augmented manifest file is a labeled dataset that is produced by Amazon SageMaker Ground Truth.
- Parameters:
attribute_names (
Optional[Sequence[str]]) – The JSON attribute that contains the annotations for your training documents. The number of attribute names that you specify depends on whether your augmented manifest file is the output of a single labeling job or a chained labeling job. If your file is the output of a single labeling job, specify the LabelAttributeName key that was used when the job was created in Ground Truth. If your file is the output of a chained labeling job, specify the LabelAttributeName key for one or more jobs in the chain. Each LabelAttributeName key provides the annotations from an individual job.s3_uri (
Optional[str]) – The Amazon S3 location of the augmented manifest file.split (
Optional[str]) – The purpose of the data you’ve provided in the augmented manifest. You can either train or test this data. If you don’t specify, the default is train. TRAIN - all of the documents in the manifest will be used for training. If no test documents are provided, Amazon Comprehend will automatically reserve a portion of the training documents for testing. TEST - all of the documents in the manifest will be used for testing.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins augmented_manifests_list_item_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.AugmentedManifestsListItemProperty( attribute_names=["attributeNames"], s3_uri="s3Uri", split="split" )
Attributes
- attribute_names
The JSON attribute that contains the annotations for your training documents.
The number of attribute names that you specify depends on whether your augmented manifest file is the output of a single labeling job or a chained labeling job.
If your file is the output of a single labeling job, specify the LabelAttributeName key that was used when the job was created in Ground Truth.
If your file is the output of a chained labeling job, specify the LabelAttributeName key for one or more jobs in the chain. Each LabelAttributeName key provides the annotations from an individual job.
- s3_uri
The Amazon S3 location of the augmented manifest file.
- split
The purpose of the data you’ve provided in the augmented manifest.
You can either train or test this data. If you don’t specify, the default is train.
TRAIN - all of the documents in the manifest will be used for training. If no test documents are provided, Amazon Comprehend will automatically reserve a portion of the training documents for testing.
TEST - all of the documents in the manifest will be used for testing.
DocumentClassifierDocumentsProperty
- class CfnDocumentClassifierPropsMixin.DocumentClassifierDocumentsProperty(*, s3_uri=None, test_s3_uri=None)
Bases:
objectThe location of the training documents.
This parameter is required in a request to create a semi-structured document classification model.
- Parameters:
s3_uri (
Optional[str]) – The S3 URI location of the training documents specified in the S3Uri CSV file.test_s3_uri (
Optional[str]) – The S3 URI location of the test documents included in the TestS3Uri CSV file. This field is not required if you do not specify a test CSV file.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins document_classifier_documents_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierDocumentsProperty( s3_uri="s3Uri", test_s3_uri="testS3Uri" )
Attributes
- s3_uri
The S3 URI location of the training documents specified in the S3Uri CSV file.
- test_s3_uri
The S3 URI location of the test documents included in the TestS3Uri CSV file.
This field is not required if you do not specify a test CSV file.
DocumentClassifierInputDataConfigProperty
- class CfnDocumentClassifierPropsMixin.DocumentClassifierInputDataConfigProperty(*, augmented_manifests=None, data_format=None, document_reader_config=None, documents=None, document_type=None, label_delimiter=None, s3_uri=None, test_s3_uri=None)
Bases:
objectThe input properties for training a document classifier.
For more information on how the input file is formatted, see Preparing training data in the Comprehend Developer Guide.
- Parameters:
augmented_manifests (
Union[IResolvable,Sequence[Union[IResolvable,AugmentedManifestsListItemProperty,Dict[str,Any]]],None]) – A list of augmented manifest files that provide training data for your custom model. An augmented manifest file is a labeled dataset that is produced by Amazon SageMaker Ground Truth. This parameter is required if you setDataFormattoAUGMENTED_MANIFEST.data_format (
Optional[str]) – The format of your training data:. -COMPREHEND_CSV: A two-column CSV file, where labels are provided in the first column, and documents are provided in the second. If you use this value, you must provide theS3Uriparameter in your request. -AUGMENTED_MANIFEST: A labeled dataset that is produced by Amazon SageMaker Ground Truth. This file is in JSON lines format. Each line is a complete JSON object that contains a training document and its associated labels. If you use this value, you must provide theAugmentedManifestsparameter in your request. If you don’t specify a value, Amazon Comprehend usesCOMPREHEND_CSVas the default.document_reader_config (
Union[IResolvable,DocumentReaderConfigProperty,Dict[str,Any],None])documents (
Union[IResolvable,DocumentClassifierDocumentsProperty,Dict[str,Any],None]) – The S3 location of the training documents. This parameter is required in a request to create a native document model.document_type (
Optional[str]) – The type of input documents for training the model. Provide plain-text documents to create a plain-text model, and provide semi-structured documents to create a native document model.label_delimiter (
Optional[str]) – Indicates the delimiter used to separate each label for training a multi-label classifier. The default delimiter between labels is a pipe (|). You can use a different character as a delimiter (if it’s an allowed character) by specifying it under Delimiter for labels. If the training documents use a delimiter other than the default or the delimiter you specify, the labels on that line will be combined to make a single unique label, such as LABELLABELLABEL.s3_uri (
Optional[str]) – The Amazon S3 URI for the input data. The S3 bucket must be in the 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 input files. For example, if you use the URIS3://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. This parameter is required if you setDataFormattoCOMPREHEND_CSV.test_s3_uri (
Optional[str]) – This specifies the Amazon S3 location that contains the test annotations for the document classifier. The URI must be in the same AWS Region as the API endpoint that you are calling.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins document_classifier_input_data_config_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierInputDataConfigProperty( augmented_manifests=[comprehend_mixins.CfnDocumentClassifierPropsMixin.AugmentedManifestsListItemProperty( attribute_names=["attributeNames"], s3_uri="s3Uri", split="split" )], data_format="dataFormat", document_reader_config=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentReaderConfigProperty( document_read_action="documentReadAction", document_read_mode="documentReadMode", feature_types=["featureTypes"] ), documents=comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierDocumentsProperty( s3_uri="s3Uri", test_s3_uri="testS3Uri" ), document_type="documentType", label_delimiter="labelDelimiter", s3_uri="s3Uri", test_s3_uri="testS3Uri" )
Attributes
- augmented_manifests
A list of augmented manifest files that provide training data for your custom model.
An augmented manifest file is a labeled dataset that is produced by Amazon SageMaker Ground Truth.
This parameter is required if you set
DataFormattoAUGMENTED_MANIFEST.
- data_format
.
COMPREHEND_CSV: A two-column CSV file, where labels are provided in the first column, and documents are provided in the second. If you use this value, you must provide theS3Uriparameter in your request.AUGMENTED_MANIFEST: A labeled dataset that is produced by Amazon SageMaker Ground Truth. This file is in JSON lines format. Each line is a complete JSON object that contains a training document and its associated labels.
If you use this value, you must provide the
AugmentedManifestsparameter in your request.If you don’t specify a value, Amazon Comprehend uses
COMPREHEND_CSVas the default.
- document_reader_config
-
- Type:
see
- document_type
The type of input documents for training the model.
Provide plain-text documents to create a plain-text model, and provide semi-structured documents to create a native document model.
- documents
The S3 location of the training documents.
This parameter is required in a request to create a native document model.
- label_delimiter
Indicates the delimiter used to separate each label for training a multi-label classifier.
The default delimiter between labels is a pipe (|). You can use a different character as a delimiter (if it’s an allowed character) by specifying it under Delimiter for labels. If the training documents use a delimiter other than the default or the delimiter you specify, the labels on that line will be combined to make a single unique label, such as LABELLABELLABEL.
- s3_uri
The Amazon S3 URI for the input data.
The S3 bucket must be in the 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 input 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.This parameter is required if you set
DataFormattoCOMPREHEND_CSV.
- test_s3_uri
This specifies the Amazon S3 location that contains the test annotations for the document classifier.
The URI must be in the same AWS Region as the API endpoint that you are calling.
DocumentClassifierOutputDataConfigProperty
- class CfnDocumentClassifierPropsMixin.DocumentClassifierOutputDataConfigProperty(*, kms_key_id=None, s3_uri=None)
Bases:
objectProvide the location for output data from a custom classifier job.
This field is mandatory if you are training a native document model.
- Parameters:
kms_key_id (
Optional[str]) – 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"s3_uri (
Optional[str]) – When you use theOutputDataConfigobject while creating a custom classifier, you specify the Amazon S3 location where you want to write the confusion matrix and other output files. 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 this output file. When the custom classifier job is finished, the service creates the output file in a directory specific to the job. TheS3Urifield contains the location of the output file, calledoutput.tar.gz. It is a compressed archive that contains the confusion matrix.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins document_classifier_output_data_config_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentClassifierOutputDataConfigProperty( kms_key_id="kmsKeyId", s3_uri="s3Uri" )
Attributes
- kms_key_id
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"
- s3_uri
When you use the
OutputDataConfigobject while creating a custom classifier, you specify the Amazon S3 location where you want to write the confusion matrix and other output files.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 this output file.
When the custom classifier job is finished, the service creates the output file in a directory specific to the job. The
S3Urifield contains the location of the output file, calledoutput.tar.gz. It is a compressed archive that contains the confusion matrix.
DocumentReaderConfigProperty
- class CfnDocumentClassifierPropsMixin.DocumentReaderConfigProperty(*, document_read_action=None, document_read_mode=None, feature_types=None)
Bases:
objectProvides configuration parameters to override the default actions for extracting text from PDF documents and image files.
By default, Amazon Comprehend performs the following actions to extract text from files, based on the input file type:
Word files - Amazon Comprehend parser extracts the text.
Digital PDF files - Amazon Comprehend parser extracts the text.
Image files and scanned PDF files - Amazon Comprehend uses the Amazon Textract
DetectDocumentTextAPI to extract the text.
DocumentReaderConfigdoes not apply to plain text files or Word files.For image files and PDF documents, you can override these default actions using the fields listed below. For more information, see Setting text extraction options in the Comprehend Developer Guide.
- Parameters:
document_read_action (
Optional[str]) – This field defines the Amazon Textract API operation that Amazon Comprehend uses to extract text from PDF files and image files. Enter one of the following values: -TEXTRACT_DETECT_DOCUMENT_TEXT- The Amazon Comprehend service uses theDetectDocumentTextAPI operation. -TEXTRACT_ANALYZE_DOCUMENT- The Amazon Comprehend service uses theAnalyzeDocumentAPI operation.document_read_mode (
Optional[str]) – Determines the text extraction actions for PDF files. Enter one of the following values:. -SERVICE_DEFAULT- use the Amazon Comprehend service defaults for PDF files. -FORCE_DOCUMENT_READ_ACTION- Amazon Comprehend uses the Textract API specified by DocumentReadAction for all PDF files, including digital PDF files.feature_types (
Optional[Sequence[str]]) – Specifies the type of Amazon Textract features to apply. If you choseTEXTRACT_ANALYZE_DOCUMENTas the read action, you must specify one or both of the following values: -TABLES- Returns additional information about any tables that are detected in the input document. -FORMS- Returns additional information about any forms that are detected in the input document.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins document_reader_config_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.DocumentReaderConfigProperty( document_read_action="documentReadAction", document_read_mode="documentReadMode", feature_types=["featureTypes"] )
Attributes
- document_read_action
This field defines the Amazon Textract API operation that Amazon Comprehend uses to extract text from PDF files and image files.
Enter one of the following values:
TEXTRACT_DETECT_DOCUMENT_TEXT- The Amazon Comprehend service uses theDetectDocumentTextAPI operation.TEXTRACT_ANALYZE_DOCUMENT- The Amazon Comprehend service uses theAnalyzeDocumentAPI operation.
- document_read_mode
.
SERVICE_DEFAULT- use the Amazon Comprehend service defaults for PDF files.FORCE_DOCUMENT_READ_ACTION- Amazon Comprehend uses the Textract API specified by DocumentReadAction for all PDF files, including digital PDF files.
- See:
- Type:
Determines the text extraction actions for PDF files. Enter one of the following values
- feature_types
Specifies the type of Amazon Textract features to apply.
If you chose
TEXTRACT_ANALYZE_DOCUMENTas the read action, you must specify one or both of the following values:TABLES- Returns additional information about any tables that are detected in the input document.FORMS- Returns additional information about any forms that are detected in the input document.
VpcConfigProperty
- class CfnDocumentClassifierPropsMixin.VpcConfigProperty(*, security_group_ids=None, subnets=None)
Bases:
objectConfiguration parameters for an optional private Virtual Private Cloud (VPC) containing the resources you are using for the job.
For more information, see Amazon VPC .
- Parameters:
security_group_ids (
Optional[Sequence[str]]) – The ID number for a security group on an instance of your private VPC. Security groups on your VPC function serve as a virtual firewall to control inbound and outbound traffic and provides security for the resources that you’ll be accessing on the VPC. This ID number is preceded by “sg-”, for instance: “sg-03b388029b0a285ea”. For more information, see Security Groups for your VPC .subnets (
Optional[Sequence[str]]) – The ID for each subnet being used in your private VPC. This subnet is a subset of the a range of IPv4 addresses used by the VPC and is specific to a given availability zone in the VPC’s Region. This ID number is preceded by “subnet-”, for instance: “subnet-04ccf456919e69055”. For more information, see VPCs and Subnets .
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_comprehend import mixins as comprehend_mixins vpc_config_property = comprehend_mixins.CfnDocumentClassifierPropsMixin.VpcConfigProperty( security_group_ids=["securityGroupIds"], subnets=["subnets"] )
Attributes
- security_group_ids
The ID number for a security group on an instance of your private VPC.
Security groups on your VPC function serve as a virtual firewall to control inbound and outbound traffic and provides security for the resources that you’ll be accessing on the VPC. This ID number is preceded by “sg-”, for instance: “sg-03b388029b0a285ea”. For more information, see Security Groups for your VPC .
- subnets
The ID for each subnet being used in your private VPC.
This subnet is a subset of the a range of IPv4 addresses used by the VPC and is specific to a given availability zone in the VPC’s Region. This ID number is preceded by “subnet-”, for instance: “subnet-04ccf456919e69055”. For more information, see VPCs and Subnets .