This topic describes the /green/text/scan operation that you can call to moderate text. You can call this operation to moderate text for violations, such as pornographic content, ads, excessive junk content, political content, and abuse.

Operation description

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 structure. You can also select an existing HTTP request. For more information, see SDK overview.

Billing method:

You are charged for calling this operation. For more information about the billing method, see Content Moderation Pricing.

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 text moderation tasks. The JSON array contains one or more elements. Each element is a structure. You can add up to 100 elements to the array. In other words, you can submit up to 100 text entries at a time. For more information about the structure of each element, see task.
Table 1. 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-a5ffe323a7e8 The ID of the moderation object.

The ID can contain letters, digits, underscores (_), hyphens (-), and periods (.)and can be up to 128 characters in length. This ID uniquely identifies your business data.

content String Yes We are a micro-lending company, which provides an unsecured loan on the same day with secure, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. The content of the text to be moderated. 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 HTTP status codes.

msg String OK The message that is returned for the request.
dataId String cfd33235-71a4-468b-8137-a5ffe323a7e8 The ID of the moderation object.
Note If you set the dataId parameter in the moderation request, the dataId parameter is returned in the response.
taskId String txt6HB8NQoEbU@5fosnj2xVEM-1tAokr The ID of the moderation task.
content String We are a micro-lending company, which provides an unsecured loan on the same day with secure, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. The content of the moderated text, which you specify in the moderation request.
filteredContent String We are a **** company, which provides an *** loan on the same day with secure, fast, convenient, and **** services when you apply for a loan on your mobile phone. The text that is returned if the original text hits terms in the custom term library, with the terms being replaced with asterisks (*).
results JSONArray The return results. If HTTP status code 200 is returned after a successful call, the array in the return results contains one or more elements. Each element is a structure. For more information about the structure, see result.
Table 2. result
Parameter Type Example Description
scene String antispam The moderation scenario, which you specify in the moderation request.
suggestion String block The recommended subsequent operation for you to perform. Valid values:
  • pass: The text is normal.
  • review: The text requires human review.
  • block: The text contains violations and can be deleted or blocked.
label String porn The category of the moderation result for the moderated text. Valid values:
  • normal: normal
  • spam: junk content
  • ad: ad
  • politics: political content
  • terrorism: terrorist content
  • abuse: abuse
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • meaningless: meaningless content
  • customized: custom content, such as a custom term
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.
Notice This score is for reference only. We recommend that you do not use this score in your business. 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 that the moderated text hits. A text entry can hit multiple pieces of risky content. For more information about the structure, see detail.
Table 3. detail
Parameter Type Example Description
label String porn The category of the risky content that the moderated text hits. Valid values:
  • spam: junk content
  • ad: ad
  • politics: political content
  • terrorism: terrorist content
  • abuse: abuse
  • porn: pornographic content
  • flood: excessive junk content
  • contraband: prohibited content
  • meaningless: meaningless content
  • customized: custom content, such as a custom term
contexts JSONArray The context information of the risky content that the moderated text hits. For more information about the structure, see context.
hintWords JSONArray The information about the term that the moderated text hits, which is used to indicate the reason for the violation. Multiple terms that the text hits may be returned. For more information about the structure, see hintWord.
Note By default, this parameter is not returned. If you want this parameter to be returned, submit a submit aticket.
Table 4. 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:
  • user_id
  • ip
  • umid
  • content
  • similar_content
  • imei
  • imsi
Table 5. hintWord
Parameter Type Example Description
context String door-to-door The term that the moderated text hits.

Examples

Sample requests
{
     "scenes": [
        "antispam"
    ],
     "tasks": [
          {
               "dataId": "cfd33235-71a4-468b-8137-a5ffe323a7e8",
               "content": "We are a micro-lending company, which provides an unsecured loan on the same day with secure, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone."
        }
    ]
}
Sample success responses
{
  "code": 200,
  "data": [
    {
      "code": 200,
      "content": "We are a micro-lending company, which provides an unsecured loan on the same day with secure, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone.",
      "dataId": "cfd33235-71a4-468b-8137-a5ffe323a7e8",
      "filteredContent": "We are a **** company, which provides an *** loan on the same day with secure, 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-1tAokr"
    }
  ],
  "msg": "OK",
  "requestId": "25711794-BF6D-4F32-A735-09CA21197D32"
}