Moderates text. You can call this operation to detect whether the specified text contains undesirable content, such as pornographic content, ad violations, spam, political content, and abuses.
Usage notes
Operation: /green/text/scan
You can call this operation to submit text moderation tasks. For more information about how to construct an HTTP request, see Request syntax. You can also select an existing HTTP request. For more information, see SDK overview.
Billing:
You are charged for calling this operation. For more information about the billing methods, see Content Moderation Pricing.
QPS limit
You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
bizType | String | No | default | The business scenario. You can create a business scenario in the Content Moderation console. For more information, see Customize policies for machine-assisted moderation. |
scenes | StringArray | Yes | ["antispam"] | The moderation scenario. Set the value to antispam, which indicates text moderation. |
tasks | JSONArray | Yes | The list of moderated objects. The JSON array can contain up to 100 elements. Each element is a structure. That is, you can submit up to 100 text entries at a time. If you need to submit more than 100 text entries at a time, contact your account manager to apply for an increase in the concurrency limit. For more information about the structures, see task. |
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
clientInfo | JSONObject | No | The information about the client. For more information, see the "Common request parameters" section of the Common parameters topic. The server determines whether to use the global clientInfo parameter or the clientInfo parameter that is described in this table. Note The clientInfo parameter in this table takes priority over the global one. | |
dataId | String | No | cfd33235-71a4-468b-8137-a5ffe323**** | The ID of the moderated object. The ID can contain letters, digits, underscores (_), hyphens (-), and periods (.). It can be up to 128 characters in length. This ID uniquely identifies your business data. |
content | String | Yes | We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. | The text to moderate. Each text entry can be up to 10,000 characters in length, including punctuation marks. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
code | Integer | 200 | The returned HTTP status code. For more information, see Common error codes. |
msg | String | OK | The message that is returned for the request. |
dataId | String | cfd33235-71a4-468b-8137-a5ffe323**** | The ID of the moderated object. Note If you set the dataId parameter in the moderation request, the value of the dataId request parameter is returned here. |
taskId | String | txt6HB8NQoEbU@5fosnj2xVEM-1t**** | The ID of the moderation task. |
content | String | We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. | The text that you specify in the moderation request. |
filteredContent | String | We are a **** company that provides an *** loan on the same day with reliable, fast, convenient, and **** services when you apply for a loan on your mobile phone. | The text that is returned if the original content hits terms in the custom term library, with the terms being replaced with asterisks (*). You can customize terms by calling the CreateKeywordLib operation or in the Content Moderation console. For more information, see Manage custom text libraries and CreateKeywordLib. |
results | JSONArray | The moderation results. If the call is successful, the HTTP status code 200 and moderation results are returned. The array of moderation results contains one or more elements. Each element is a structure. For more information about the structure of each element, see result. |
Parameter | Type | Example | Description |
---|---|---|---|
scene | String | antispam | The moderation scenario that you specify in the moderation request. |
suggestion | String | block | The recommended subsequent operation. Valid values:
|
label | String | porn | The category of the moderation result for the moderated text. Valid values:
|
rate | Float | 99.91 | The score of the confidence level. Valid values: 0 to 100. A greater value indicates a higher confidence level. If a value of pass is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content is normal. If a value of review or block is returned for the suggestion parameter, a higher confidence level indicates a higher probability that the content contains violations. Important We recommend that you use the values that are returned for the suggestion, label, and sublabel parameters to determine whether the content contains violations. The sublabel parameter is returned by specific operations. |
extras | JSONObject | {"userId":"xxx"} | The additional information. This is an extended parameter. |
details | JSONArray | The details of the risky content hit by the moderated text. A text entry can hit multiple pieces of risky content. For more information about the structure, see detail. |
Parameter | Type | Example | Description |
---|---|---|---|
label | String | porn | The category of the risky content that the moderated text hits. Valid values:
|
contexts | JSONArray | The context information of the risky content that the moderated text hits. For more information about the structure, see context. |
Parameter | Type | Example | Description |
---|---|---|---|
context | String | door-to-door | The term that the moderated text hits. If the text hits a term, the term is returned. If the text hits the algorithmic model, this parameter is not returned. |
positions | JSONArray | [{"startPos":1, "endPos":10}] | The position of the term that the moderated text hits in the original text. |
libName | String | Name of your custom text library | The name of the custom text library. This parameter is returned if the moderated text hits a term in the custom text library. |
libCode | String | 123456 | The code of the custom text library. This parameter is returned if the moderated text hits a term in the custom text library. |
ruleType | String | ip | The behavior rule. This parameter is returned if the moderated text hits the behavior rule. Valid values:
|
Examples
http(s)://[Endpoint]/green/text/scan
&<Common request parameters>
{
"scenes": [
"antispam"
],
"tasks": [
{
"dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
..."content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone."
}
]
}
{
"code": 200,
"data": [
{
"code": 200,
"content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone.",
"dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
"filteredContent": "We are a **** company that provides an *** loan on the same day with reliable, fast, convenient, and **** services when you apply for a loan on your mobile phone.",
"msg": "OK",
"results": [
{
"details": [
{
"contexts": [
{
"context": "unsecured",
"positions": [
{
"endPos": 19,
"startPos": 16
}
]
},
{
"context": "micro-lending",
"positions": [
{
"endPos": 6,
"startPos": 2
}
]
}
],
"label": "spam"
},
{
"contexts": [
{
"context": "door-to-door",
"libCode": "123456",
"libName": "Name of your custom text library",
"positions": [
{
"endPos": 34,
"startPos": 30
}
]
}
],
"label": "porn"
}
],
"label": "porn",
"rate": 99.91,
"scene": "antispam",
"suggestion": "block"
}
],
"taskId": "txt6HB8NQoEbU@5fosnj2xVEM-1t****"
}
],
"msg": "OK",
"requestId": "25711794-BF6D-4F32-A735-09CA21197D32"
}