Method: Aws::Textract::Client#start_document_analysis

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

#start_document_analysis(params = {}) ⇒ Types::StartDocumentAnalysisResponse

Starts the asynchronous analysis of an input document for relationships between detected items such as key-value pairs, tables, and selection elements.

‘StartDocumentAnalysis` can analyze text in documents that are in JPEG, PNG, TIFF, and PDF format. The documents are stored in an Amazon S3 bucket. Use DocumentLocation to specify the bucket name and file name of the document.

‘StartDocumentAnalysis` returns a job identifier (`JobId`) that you use to get the results of the operation. When text analysis is finished, Amazon Textract publishes a completion status to the Amazon Simple Notification Service (Amazon SNS) topic that you specify in `NotificationChannel`. To get the results of the text analysis operation, first check that the status value published to the Amazon SNS topic is `SUCCEEDED`. If so, call GetDocumentAnalysis, and pass the job identifier (`JobId`) from the initial call to `StartDocumentAnalysis`.

For more information, see [Document Text Analysis].

[1]: docs.aws.amazon.com/textract/latest/dg/how-it-works-analyzing.html

Examples:

Request syntax with placeholder values


resp = client.start_document_analysis({
  document_location: { # required
    s3_object: {
      bucket: "S3Bucket",
      name: "S3ObjectName",
      version: "S3ObjectVersion",
    },
  },
  feature_types: ["TABLES"], # required, accepts TABLES, FORMS
  client_request_token: "ClientRequestToken",
  job_tag: "JobTag",
  notification_channel: {
    sns_topic_arn: "SNSTopicArn", # required
    role_arn: "RoleArn", # required
  },
  output_config: {
    s3_bucket: "S3Bucket", # required
    s3_prefix: "S3ObjectName",
  },
  kms_key_id: "KMSKeyId",
})

Response structure


resp.job_id #=> String

Parameters:

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

    ({})

Options Hash (params):

  • :document_location (required, Types::DocumentLocation)

    The location of the document to be processed.

  • :feature_types (required, Array<String>)

    A list of the types of analysis to perform. Add TABLES to the list to return information about the tables that are detected in the input document. Add FORMS to return detected form data. To perform both types of analysis, add TABLES and FORMS to ‘FeatureTypes`. All lines and words detected in the document are included in the response (including text that isn’t related to the value of ‘FeatureTypes`).

  • :client_request_token (String)

    The idempotent token that you use to identify the start request. If you use the same token with multiple ‘StartDocumentAnalysis` requests, the same `JobId` is returned. Use `ClientRequestToken` to prevent the same job from being accidentally started more than once. For more information, see [Calling Amazon Textract Asynchronous Operations].

    [1]: docs.aws.amazon.com/textract/latest/dg/api-async.html

  • :job_tag (String)

    An identifier that you specify that’s included in the completion notification published to the Amazon SNS topic. For example, you can use ‘JobTag` to identify the type of document that the completion notification corresponds to (such as a tax form or a receipt).

  • :notification_channel (Types::NotificationChannel)

    The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to.

  • :output_config (Types::OutputConfig)

    Sets if the output will go to a customer defined bucket. By default, Amazon Textract will save the results internally to be accessed by the GetDocumentAnalysis operation.

  • :kms_key_id (String)

    The KMS key used to encrypt the inference results. This can be in either Key ID or Key Alias format. When a KMS key is provided, the KMS key will be used for server-side encryption of the objects in the customer bucket. When this parameter is not enabled, the result will be encrypted server side,using SSE-S3.

Returns:

See Also:



1228
1229
1230
1231
# File 'lib/aws-sdk-textract/client.rb', line 1228

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