Async analysis for targeted sentiment - Amazon Comprehend

Async analysis for targeted sentiment

Amazon Comprehend provides the following API operations for analyzing targeted sentiment:

Before you start

Before you start, make sure that you have:

  • Input and output buckets—Identify the Amazon S3 buckets that you want to use for input and output. The buckets must be in the same region as the API that you are calling.

  • IAM service role—You must have an IAM service role with permission to access your input and output buckets. For more information, see Role-based permissions required for asynchronous operations.

Analyzing targeted sentiment using the AWS CLI

The following example demonstrates using the StartTargetedSentimentDetectionJob operation with the AWS CLI. This example specifies the language of the input text.

The example is formatted for Unix, Linux, and macOS. For Windows, replace the backslash (\) Unix continuation character at the end of each line with a caret (^).

aws comprehend start-targeted-sentiment-detection-job \ --job-name "job name" \ --language-code "en" \ --cli-input-json file://path to JSON input file

For the cli-input-json parameter you supply the path to a JSON file that contains the request data, as shown in the following example.

{ "InputDataConfig": { "S3Uri": "s3://input bucket/input path", "InputFormat": "ONE_DOC_PER_FILE" }, "OutputDataConfig": { "S3Uri": "s3://output bucket/output path" }, "DataAccessRoleArn": "arn:aws:iam::account ID:role/data access role" }

If the request to start the job was successful, you will receive the following response:

{ "JobStatus": "SUBMITTED", "JobArn": "job ARN" "JobId": "job ID" }