Skip to content

create_entity_recognizer

create_entity_recognizer(
    recognizer_name: ComprehendArnName,
    data_access_role_arn: IamRoleArn,
    input_data_config: EntityRecognizerInputDataConfig,
    language_code: LanguageCode,
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
    version_name: Optional[VersionName] = None,
    tags: Optional[TagList] = None,
    client_request_token: Optional[ClientRequestTokenString] = None,
    volume_kms_key_id: Optional[KmsKeyId] = None,
    vpc_config: Optional[VpcConfig] = None,
    model_kms_key_id: Optional[KmsKeyId] = None,
    model_policy: Optional[Policy] = None,
) -> CreateEntityRecognizerResponse

Creates an entity recognizer using submitted files. After your CreateEntityRecognizer request is submitted, you can check job status using the DescribeEntityRecognizer API.

Parameters:

  • recognizer_name (ComprehendArnName) –

    The name given to the newly created recognizer. Recognizer names can be a maximum of 256 characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The name must be unique in the account/Region.

  • version_name (Optional[VersionName], default: None ) –

    The version name given to the newly created recognizer. Version names can be a maximum of 256 characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The version name must be unique among all models with the same recognizer name in the account/Region.

  • data_access_role_arn (IamRoleArn) –

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

  • tags (Optional[TagList], default: None ) –

    Tags to associate with the entity recognizer. A tag is a key-value pair that adds as a 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.

  • input_data_config (EntityRecognizerInputDataConfig) –

    Specifies the format and location of the input data. The S3 bucket containing the input data must be located in the same Region as the entity recognizer being created.

  • client_request_token (Optional[ClientRequestTokenString], default: None ) –

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

  • language_code (LanguageCode) –

    You can specify any of the following languages: English ("en"), Spanish ("es"), French ("fr"), Italian ("it"), German ("de"), or Portuguese ("pt"). If you plan to use this entity recognizer with PDF, Word, or image input files, you must specify English as the language. All training documents must be in the same language.

  • volume_kms_key_id (Optional[KmsKeyId], default: None ) –

    ID for the Amazon Web Services Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on the storage volume attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId can be either 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"

  • vpc_config (Optional[VpcConfig], default: None ) –

    Configuration parameters for an optional private Virtual Private Cloud (VPC) containing the resources you are using for your custom entity recognizer. For more information, see Amazon VPC.

  • model_kms_key_id (Optional[KmsKeyId], default: None ) –

    ID for the KMS key that Amazon Comprehend uses to encrypt trained custom models. The ModelKmsKeyId can be either 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"

  • model_policy (Optional[Policy], default: None ) –

    The JSON resource-based policy to attach to your custom entity recognizer model. You can use this policy to allow another Amazon Web Services account to import your custom model.

    Provide your JSON as a UTF-8 encoded string without line breaks. To provide valid JSON for your policy, enclose the attribute names and values in double quotes. If the JSON body is also enclosed in double quotes, then you must escape the double quotes that are inside the policy:

    "{\"attribute\": \"value\", \"attribute\": [\"value\"]}"

    To avoid escaping quotes, you can use single quotes to enclose the policy and double quotes to enclose the JSON names and values:

    '{"attribute": "value", "attribute": ["value"]}'

Raises:

Source code in docs_src/capo_comprehend/_services/comprehend.py
def create_entity_recognizer(
    self,
    recognizer_name: "capo_comprehend.types.comprehend_arn_name.ComprehendArnName",
    data_access_role_arn: "capo_comprehend.types.iam_role_arn.IamRoleArn",
    input_data_config: "capo_comprehend.types.entity_recognizer_input_data_config.EntityRecognizerInputDataConfig",
    language_code: "capo_comprehend.types.language_code.LanguageCode",
    *,
    config_overrides: Optional[ComprehendClientConfig] = None,
    version_name: Optional["capo_comprehend.types.version_name.VersionName"] = None,
    tags: Optional["capo_comprehend.types.tag_list.TagList"] = None,
    client_request_token: Optional[
        "capo_comprehend.types.client_request_token_string.ClientRequestTokenString"
    ] = None,
    volume_kms_key_id: Optional["capo_comprehend.types.kms_key_id.KmsKeyId"] = None,
    vpc_config: Optional["capo_comprehend.types.vpc_config.VpcConfig"] = None,
    model_kms_key_id: Optional["capo_comprehend.types.kms_key_id.KmsKeyId"] = None,
    model_policy: Optional["capo_comprehend.types.policy.Policy"] = None,
) -> "capo_comprehend.types.create_entity_recognizer_response.CreateEntityRecognizerResponse":
    r"""<p>Creates an entity recognizer using submitted files. After your <code>CreateEntityRecognizer</code> request is submitted, you can check job status using the <code>DescribeEntityRecognizer</code> API. </p>

    Args:
        recognizer_name: <p>The name given to the newly created recognizer. Recognizer names can be a maximum of 256 characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The name must be unique in the account/Region.</p>
        version_name: <p>The version name given to the newly created recognizer. Version names can be a maximum of 256 characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The version name must be unique among all models with the same recognizer name in the account/Region.</p>
        data_access_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend read access to your input data.</p>
        tags: <p>Tags to associate with the entity recognizer. A tag is a key-value pair that adds as a 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. </p>
        input_data_config: <p>Specifies the format and location of the input data. The S3 bucket containing the input data must be located in the same Region as the entity recognizer being created. </p>
        client_request_token: <p> A unique identifier for the request. If you don't set the client request token, Amazon Comprehend generates one.</p>
        language_code: <p> You can specify any of the following languages: English ("en"), Spanish ("es"), French ("fr"), Italian ("it"), German ("de"), or Portuguese ("pt"). If you plan to use this entity recognizer with PDF, Word, or image input files, you must specify English as the language. All training documents must be in the same language.</p>
        volume_kms_key_id: <p>ID for the Amazon Web Services Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on the storage volume attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId can be either of the following formats:</p> <ul> <li> <p>KMS Key ID: <code>"1234abcd-12ab-34cd-56ef-1234567890ab"</code> </p> </li> <li> <p>Amazon Resource Name (ARN) of a KMS Key: <code>"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"</code> </p> </li> </ul>
        vpc_config: <p>Configuration parameters for an optional private Virtual Private Cloud (VPC) containing the resources you are using for your custom entity recognizer. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html">Amazon VPC</a>. </p>
        model_kms_key_id: <p>ID for the KMS key that Amazon Comprehend uses to encrypt trained custom models. The ModelKmsKeyId can be either of the following formats:</p> <ul> <li> <p>KMS Key ID: <code>"1234abcd-12ab-34cd-56ef-1234567890ab"</code> </p> </li> <li> <p>Amazon Resource Name (ARN) of a KMS Key: <code>"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"</code> </p> </li> </ul>
        model_policy: <p>The JSON resource-based policy to attach to your custom entity recognizer model. You can use this policy to allow another Amazon Web Services account to import your custom model.</p> <p>Provide your JSON as a UTF-8 encoded string without line breaks. To provide valid JSON for your policy, enclose the attribute names and values in double quotes. If the JSON body is also enclosed in double quotes, then you must escape the double quotes that are inside the policy:</p> <p> <code>"{\"attribute\": \"value\", \"attribute\": [\"value\"]}"</code> </p> <p>To avoid escaping quotes, you can use single quotes to enclose the policy and double quotes to enclose the JSON names and values:</p> <p> <code>'{"attribute": "value", "attribute": ["value"]}'</code> </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.kms_key_validation_exception.KmsKeyValidationException: <p>The KMS customer managed key (CMK) entered cannot be validated. Verify the key and re-enter it.</p>
        capo_comprehend.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource name is already in use. Use a different name and try your request again.</p>
        capo_comprehend.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>The maximum number of resources per account has been exceeded. Review the resources, and then try your request again.</p>
        capo_comprehend.errors.too_many_requests_exception.TooManyRequestsException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_comprehend.errors.too_many_tags_exception.TooManyTagsException: <p>The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request. </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.create_entity_recognizer_request.CreateEntityRecognizerRequest]",
    ) -> OperationResponse[
        "capo_comprehend.types.create_entity_recognizer_response.CreateEntityRecognizerResponse"
    ]:
        import capo_comprehend._operations.comprehend_20171127.create_entity_recognizer

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEntityRecognizer")
    )
    input_: capo_comprehend.types.create_entity_recognizer_request.CreateEntityRecognizerRequest = {
        "recognizer_name": recognizer_name,
        "data_access_role_arn": data_access_role_arn,
        "input_data_config": input_data_config,
        "language_code": language_code,
    }
    if version_name is not None:
        input_["version_name"] = version_name
    if tags is not None:
        input_["tags"] = tags
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if volume_kms_key_id is not None:
        input_["volume_kms_key_id"] = volume_kms_key_id
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if model_kms_key_id is not None:
        input_["model_kms_key_id"] = model_kms_key_id
    if model_policy is not None:
        input_["model_policy"] = model_policy

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