There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListDocumentClassificationJobs
with an AWS SDK or CLI
The following code examples show how to use ListDocumentClassificationJobs
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- CLI
-
- AWS CLI
-
To list of all document classification jobs
The following
list-document-classification-jobs
example lists all document classification jobs.aws comprehend list-document-classification-jobs
Output:
{ "DocumentClassificationJobPropertiesList": [ { "JobId": "123456abcdeb0e11022f22a11EXAMPLE", "JobArn": "arn:aws:comprehend:us-west-2:1234567890101:document-classification-job/123456abcdeb0e11022f22a11EXAMPLE", "JobName": "exampleclassificationjob", "JobStatus": "COMPLETED", "SubmitTime": "2023-06-14T17:09:51.788000+00:00", "EndTime": "2023-06-14T17:15:58.582000+00:00", "DocumentClassifierArn": "arn:aws:comprehend:us-west-2:1234567890101:document-classifier/mymodel/version/12", "InputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-BUCKET/jobdata/", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-DESTINATION-BUCKET/thefolder/1234567890101-CLN-e758dd56b824aa717ceab551f11749fb/output/output.tar.gz" }, "DataAccessRoleArn": "arn:aws:iam::1234567890101:role/service-role/AmazonComprehendServiceRole-example-role" }, { "JobId": "123456abcdeb0e11022f22a1EXAMPLE2", "JobArn": "arn:aws:comprehend:us-west-2:1234567890101:document-classification-job/123456abcdeb0e11022f22a1EXAMPLE2", "JobName": "exampleclassificationjob2", "JobStatus": "COMPLETED", "SubmitTime": "2023-06-14T17:22:39.829000+00:00", "EndTime": "2023-06-14T17:28:46.107000+00:00", "DocumentClassifierArn": "arn:aws:comprehend:us-west-2:1234567890101:document-classifier/mymodel/version/12", "InputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-BUCKET/jobdata/", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-DESTINATION-BUCKET/thefolder/1234567890101-CLN-123456abcdeb0e11022f22a1EXAMPLE2/output/output.tar.gz" }, "DataAccessRoleArn": "arn:aws:iam::1234567890101:role/service-role/AmazonComprehendServiceRole-example-role" } ] }
For more information, see Custom Classification in the Amazon Comprehend Developer Guide.
-
For API details, see ListDocumentClassificationJobs
in AWS CLI Command Reference.
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. class ComprehendClassifier: """Encapsulates an Amazon Comprehend custom classifier.""" def __init__(self, comprehend_client): """ :param comprehend_client: A Boto3 Comprehend client. """ self.comprehend_client = comprehend_client self.classifier_arn = None def list_jobs(self): """ Lists the classification jobs for the current account. :return: The list of jobs. """ try: response = self.comprehend_client.list_document_classification_jobs() jobs = response["DocumentClassificationJobPropertiesList"] logger.info("Got %s document classification jobs.", len(jobs)) except ClientError: logger.exception( "Couldn't get document classification jobs.", ) raise else: return jobs
-
For API details, see ListDocumentClassificationJobs in AWS SDK for Python (Boto3) API Reference.
-