本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
ListTopicsDetectionJobs 搭配 AWS SDK 或 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://amzn-s3-demo-bucket", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://amzn-s3-demo-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://amzn-s3-demo-bucket", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://amzn-s3-demo-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://amzn-s3-demo-bucket", "InputFormat": "ONE_DOC_PER_LINE" }, "OutputDataConfig": { "S3Uri": "s3://amzn-s3-demo-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 詳細資訊,請參閱《AWS CLI 命令參考》中的 ListTopicsDetectionJobs
。
-
- Python
-
- 適用於 Python 的 SDK (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 詳細資訊,請參閱《AWS SDK for Python (Boto3) API 參考》中的 ListTopicsDetectionJobs。
-
- SAP ABAP
-
- 適用於 SAP ABAP 的開發套件
-
注意
GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 TRY. oo_result = lo_cpd->listtopicsdetectionjobs( ). MESSAGE 'Topics detection jobs listed.' TYPE 'I'. CATCH /aws1/cx_cpdinvalidrequestex. MESSAGE 'Invalid request.' TYPE 'E'. CATCH /aws1/cx_cpdtoomanyrequestsex. MESSAGE 'Too many requests.' TYPE 'E'. CATCH /aws1/cx_cpdinvalidfilterex. MESSAGE 'Invalid filter.' TYPE 'E'. CATCH /aws1/cx_cpdinternalserverex. MESSAGE 'Internal server error occurred.' TYPE 'E'. ENDTRY.-
如需 API 詳細資訊,請參閱《適用於 AWS SAP ABAP 的 SDK API 參考》中的 ListTopicsDetectionJobs。
-
如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 搭配 SDK 使用 Amazon Comprehend AWS。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。
ListDocumentClassifiers
StartDocumentClassificationJob