Shows how to use the AWS SDK for Python (Boto3) to work with Amazon Comprehend.
Amazon Comprehend uses natural language processing (NLP) to extract insights about the content of documents without the need of any special preprocessing.
- Running this code might result in charges to your AWS account. For more details, see AWS Pricing and Free Tier.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
For prerequisites, see the README in the python
folder.
Install the packages required by these examples by running the following in a virtual environment:
python -m pip install -r requirements.txt
Code excerpts that show you how to call individual service functions.
- CreateDocumentClassifier
- DeleteDocumentClassifier
- DescribeDocumentClassificationJob
- DescribeDocumentClassifier
- DescribeTopicsDetectionJob
- DetectDominantLanguage
- DetectEntities
- DetectKeyPhrases
- DetectPiiEntities
- DetectSentiment
- DetectSyntax
- ListDocumentClassificationJobs
- ListDocumentClassifiers
- ListTopicsDetectionJobs
- StartDocumentClassificationJob
- StartTopicsDetectionJob
Code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
- Detect document elements
- Run a topic modeling job on sample data
- Train a custom classifier and classify documents
Sample applications that work across multiple AWS services.
This example shows you how to do the following:
- Detect languages, entities, and key phrases in a document.
- Detect personally identifiable information (PII) in a document.
- Detect the sentiment of a document.
- Detect syntax elements in a document.
Start the example by running the following at a command prompt:
python comprehend_detect.py
This example shows you how to do the following:
- Run an Amazon Comprehend topic modeling job on sample data.
- Get information about the job.
- Extract job output data from Amazon S3.
Start the example by running the following at a command prompt:
python comprehend_topic_modeler.py
This example shows you how to do the following:
- Create an Amazon Comprehend multi-label classifier.
- Train the classifier on sample data.
- Run a classification job on a second set of data.
- Extract the job output data from Amazon S3.
Start the example by running the following at a command prompt:
python comprehend_classifier.py
⚠ Running tests might result in charges to your AWS account.
To find instructions for running these tests, see the README
in the python
folder.
- Amazon Comprehend Developer Guide
- Amazon Comprehend API Reference
- SDK for Python Amazon Comprehend reference
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0