AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或ListTopicsDetectionJobs
一起使用 CLI
以下代码示例演示如何使用 ListTopicsDetectionJobs
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- CLI
-
- AWS CLI
-
列出所有主题检测作业
以下
list-topics-detection-jobs
示例列出所有正在进行和已完成的异步主题检测作业。aws comprehend list-topics-detection-jobs
输出:
{ "TopicsDetectionJobPropertiesList": [ { "JobId": "123456abcdeb0e11022f22a11EXAMPLE", "JobArn": "arn:aws:comprehend:us-west-2:111122223333:topics-detection-job/123456abcdeb0e11022f22a11EXAMPLE", "JobName" "topic-analysis-1" "JobStatus": "IN_PROGRESS", "SubmitTime": "2023-06-09T18:40:35.384000+00:00", "EndTime": "2023-06-09T18:46:41.936000+00:00", "InputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-BUCKET", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-DESTINATION-BUCKET/thefolder/111122223333-TOPICS-123456abcdeb0e11022f22a11EXAMPLE/output/output.tar.gz" }, "NumberOfTopics": 10, "DataAccessRoleArn": "arn:aws:iam::111122223333:role/service-role/AmazonComprehendServiceRole-example-role" }, { "JobId": "123456abcdeb0e11022f22a1EXAMPLE2", "JobArn": "arn:aws:comprehend:us-west-2:111122223333:topics-detection-job/123456abcdeb0e11022f22a1EXAMPLE2", "JobName": "topic-analysis-2", "JobStatus": "COMPLETED", "SubmitTime": "2023-06-09T18:44:43.414000+00:00", "EndTime": "2023-06-09T18:50:50.872000+00:00", "InputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-BUCKET", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-DESTINATION-BUCKET/thefolder/111122223333-TOPICS-123456abcdeb0e11022f22a1EXAMPLE2/output/output.tar.gz" }, "NumberOfTopics": 10, "DataAccessRoleArn": "arn:aws:iam::111122223333:role/service-role/AmazonComprehendServiceRole-example-role" }, { "JobId": "123456abcdeb0e11022f22a1EXAMPLE3", "JobArn": "arn:aws:comprehend:us-west-2:111122223333:topics-detection-job/123456abcdeb0e11022f22a1EXAMPLE3", "JobName": "topic-analysis-2", "JobStatus": "IN_PROGRESS", "SubmitTime": "2023-06-09T18:50:56.737000+00:00", "InputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-BUCKET", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://DOC-EXAMPLE-DESTINATION-BUCKET/thefolder/111122223333-TOPICS-123456abcdeb0e11022f22a1EXAMPLE3/output/output.tar.gz" }, "NumberOfTopics": 10, "DataAccessRoleArn": "arn:aws:iam::111122223333:role/service-role/AmazonComprehendServiceRole-example-role" } ] }
有关更多信息,请参阅《Amazon Comprehend 开发人员指南》中的 Amazon Comprehend 洞察的异步分析。
-
有关API详细信息,请参阅 “ListTopicsDetectionJobs AWS CLI
命令参考”。
-
- Python
-
- SDK适用于 Python (Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 class ComprehendTopicModeler: """Encapsulates a Comprehend topic modeler.""" def __init__(self, comprehend_client): """ :param comprehend_client: A Boto3 Comprehend client. """ self.comprehend_client = comprehend_client def list_jobs(self): """ Lists topic modeling jobs for the current account. :return: The list of jobs. """ try: response = self.comprehend_client.list_topics_detection_jobs() jobs = response["TopicsDetectionJobPropertiesList"] logger.info("Got %s topic detection jobs.", len(jobs)) except ClientError: logger.exception("Couldn't get topic detection jobs.") raise else: return jobs
-
有关API详细信息,请参阅ListTopicsDetectionJobs中的 AWS SDKPython (Boto3) API 参考。
-
ListDocumentClassifiers
StartDocumentClassificationJob