API | Description |
Submits text moderation job. | |
Queries the result of specified text moderation job. |
TextAuditingResponse createAuditingTextJobs(TextAuditingRequest request);
//1. Create a job request objectTextAuditingRequest request = new TextAuditingRequest();//2. Add request parameters as detailed in the API documentationrequest.setBucketName("examplebucket-12500000008");//2.1.1 Set the object address//request.getInput().setObject("1.txt");//2.1.2 Or, directly set the request content, i.e., Base64-encoded text contentrequest.getInput().setContent("Base64Str");//2.2 Set the moderation type parameterrequest.getConf().setDetectType("all");//2.3 Set the moderation template (optional)//request.getConf().setBizType("aa3e9d84a6a079556b0109a935c*****");//3. Call the API to get the job response objectTextAuditingResponse response = client.createAuditingTextJobs(request);
Request
has the following sub-nodes:Node Name (Keyword) | Parent Node | Description | Type | Required |
Request | None | Text moderation configuration. | Container | Yes |
Request
has the following sub-nodes:Node Name (Keyword) | Parent Node | Description | Type | Required |
Input | Request | Content to be moderated. | Container | Yes |
Conf | Request | Moderation rule configuration. | Container | Yes |
Input
has the following sub-nodes:Node Name (Keyword) | Parent Node | Description | Type | Required |
Object | Request.Input | Name of the text file stored in the current COS bucket; for example, if the file is test.txt in the test directory, then the filename is test/test.txt . Only text files in UTF-8 and GBK encodings are supported, and the file size cannot exceed 1 MB. | String | No |
Content | Request.Input | When the input content is plain text, it needs to be Base64-encoded first. The length of the original text before encoding cannot exceed 10,000 UTF-8 characters. If the length limit is exceeded, the API will report an error. | String | No |
Object
and Content
cannot be entered at the same time.Object
is selected, the moderation result will be returned asynchronously, which can be obtained through the API for querying text moderation job result.Content
is selected, the moderation result will be returned synchronously, which can be viewed in the response body.Conf
has the following sub-nodes:Node Name (Keyword) | Parent Node | Description | Type | Required |
BizType | Request.Conf | Moderation policy. If this parameter is not specified, the default policy will be used. The policy can be configured in the console. For more information, see Setting Moderation Policy. | String | No |
DetectType | Request.Conf | The scene to be moderated, such as Porn (pornography), Ads (advertising), Illegal (illegal), and Abuse (abusive). You can pass in multiple types and separate them by comma, such as Porn,Ads . | String | No |
Callback | Request.Conf | The moderation result can be sent to your callback address in the form of a callback. Addresses starting with http:// or https:// are supported, such as http://www.callback.com . | String | No |
TextAuditingResponse
text moderation job result object is returned upon success.CosClientException
or CosServiceException
exception. For more information, see Troubleshooting.TextAuditingResponse describeAuditingTextJob(TextAuditingRequest request);
//1. Create a job request objectTextAuditingRequest request = new TextAuditingRequest();//2. Add request parameters as detailed in the API documentationrequest.setBucketName("examplebucket-1250000000");request.setJobId("st68d08596f35011eb9324525400*****");//3. Call the API to get the job response objectTextAuditingResponse response = client.describeAuditingTextJob(request);
Parameter | Description | Type | Required |
bucketName | String | Yes | |
jobId | ID of the job to be queried. | String | Yes |
TextAuditingResponse
moderation job result object is returned.CosClientException
or CosServiceException
exception will be reported. For more information, see Troubleshooting.
Apakah halaman ini membantu?