Method: Aws::Comprehend::Client#create_document_classifier

Defined in:
lib/aws-sdk-comprehend/client.rb

#create_document_classifier(params = {}) ⇒ Types::CreateDocumentClassifierResponse

Creates a new document classifier that you can use to categorize documents. To create a classifier, you provide a set of training documents that are labeled with the categories that you want to use. For more information, see [Training classifier models] in the Comprehend Developer Guide.

[1]: docs.aws.amazon.com/comprehend/latest/dg/training-classifier-model.html

Examples:

Request syntax with placeholder values


resp = client.create_document_classifier({
  document_classifier_name: "ComprehendArnName", # required
  version_name: "VersionName",
  data_access_role_arn: "IamRoleArn", # required
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue",
    },
  ],
  input_data_config: { # required
    data_format: "COMPREHEND_CSV", # accepts COMPREHEND_CSV, AUGMENTED_MANIFEST
    s3_uri: "S3Uri",
    test_s3_uri: "S3Uri",
    label_delimiter: "LabelDelimiter",
    augmented_manifests: [
      {
        s3_uri: "S3Uri", # required
        split: "TRAIN", # accepts TRAIN, TEST
        attribute_names: ["AttributeNamesListItem"], # required
        annotation_data_s3_uri: "S3Uri",
        source_documents_s3_uri: "S3Uri",
        document_type: "PLAIN_TEXT_DOCUMENT", # accepts PLAIN_TEXT_DOCUMENT, SEMI_STRUCTURED_DOCUMENT
      },
    ],
    document_type: "PLAIN_TEXT_DOCUMENT", # accepts PLAIN_TEXT_DOCUMENT, SEMI_STRUCTURED_DOCUMENT
    documents: {
      s3_uri: "S3Uri", # required
      test_s3_uri: "S3Uri",
    },
    document_reader_config: {
      document_read_action: "TEXTRACT_DETECT_DOCUMENT_TEXT", # required, accepts TEXTRACT_DETECT_DOCUMENT_TEXT, TEXTRACT_ANALYZE_DOCUMENT
      document_read_mode: "SERVICE_DEFAULT", # accepts SERVICE_DEFAULT, FORCE_DOCUMENT_READ_ACTION
      feature_types: ["TABLES"], # accepts TABLES, FORMS
    },
  },
  output_data_config: {
    s3_uri: "S3Uri",
    kms_key_id: "KmsKeyId",
    flywheel_stats_s3_prefix: "S3Uri",
  },
  client_request_token: "ClientRequestTokenString",
  language_code: "en", # required, accepts en, es, fr, de, it, pt, ar, hi, ja, ko, zh, zh-TW
  volume_kms_key_id: "KmsKeyId",
  vpc_config: {
    security_group_ids: ["SecurityGroupId"], # required
    subnets: ["SubnetId"], # required
  },
  mode: "MULTI_CLASS", # accepts MULTI_CLASS, MULTI_LABEL
  model_kms_key_id: "KmsKeyId",
  model_policy: "Policy",
})

Response structure


resp.document_classifier_arn #=> String

Parameters:

  • params (Hash) (defaults to: {})

    ({})

Options Hash (params):

  • :document_classifier_name (required, String)

    The name of the document classifier.

  • :version_name (String)

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

  • :data_access_role_arn (required, String)

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

  • :tags (Array<Types::Tag>)

    Tags to associate with the document classifier. 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 (required, Types::DocumentClassifierInputDataConfig)

    Specifies the format and location of the input data for the job.

  • :output_data_config (Types::DocumentClassifierOutputDataConfig)

    Specifies the location for the output files from a custom classifier job. This parameter is required for a request that creates a native document model.

  • :client_request_token (String)

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

    **A suitable default value is auto-generated.** You should normally not need to pass this option.**

  • :language_code (required, String)

    The language of the input documents. You can specify any of the languages supported by Amazon Comprehend. All documents must be in the same language.

  • :volume_kms_key_id (String)

    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 (Types::VpcConfig)

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

    [1]: docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html

  • :mode (String)

    Indicates the mode in which the classifier will be trained. The classifier can be trained in multi-class (single-label) mode or multi-label mode. Multi-class mode identifies a single class label for each document and multi-label mode identifies one or more class labels for each document. Multiple labels for an individual document are separated by a delimiter. The default delimiter between labels is a pipe (|).

  • :model_kms_key_id (String)

    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 (String)

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

    Provide your policy as a JSON body that you enter as a UTF-8 encoded string without line breaks. To provide valid JSON, 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:

    ‘“”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:

    ‘’“value”, “attribute”: [“value”]‘`

Returns:

See Also:



1172
1173
1174
1175
# File 'lib/aws-sdk-comprehend/client.rb', line 1172

def create_document_classifier(params = {}, options = {})
  req = build_request(:create_document_classifier, params)
  req.send_request(options)
end