This topic describes how to call an operation to submit text moderation tasks. It intends to help you construct an HTTP call request. You can call the /green/text/scan operation to moderate text for violations, such as the pornographic content, ads, spam, political content, and abuse.

  • 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.

Description

Operation: /green/text/scan

Request parameters

Parameter Type Required Description
bizType String No The business scenario. You can customize content moderation policies to apply different moderation standards or algorithm policies to different business scenarios. You can create a business scenario by specifying bizType in the Alibaba Cloud Content Moderation console. Alternatively, you can submit a ticket to ask Alibaba Cloud engineers to help you create a business scenario.
scenes String array Yes The moderation scenario. Set the value to antispam.
tasks JSON array Yes The list of text moderation tasks. It is a JSON array that contains one or more elements. Each element is a structure. You can add up to 100 elements to the array, which means that you can moderate 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 Description
clientInfo JSON structure No The information about the client. For more information, see the common query parameters in Common request parameters.
The server determines whether to use the global clientInfo parameter or the clientInfo parameter described in this table.
Note The clientInfo parameter described in this table takes a higher priority.
dataId String No The ID of the text to be moderated. Make sure that each ID is unique in a request.
content String Yes The content of the text to be moderated. Each text entry can be up to 10,000 characters in length.

Response parameters

Parameter Type Required Description
code Integer Yes The HTTP status code returned for the text moderation task.
msg String Yes The message returned for the text moderation task.
dataId String No The ID of the moderation object.
Note If you specify the dataId parameter in the request, the dataId parameter is returned in the response.
taskId String Yes The ID of the text moderation task.
content String No The content of the moderated text, which you specify in the moderation request.
filteredContent String No The text returned if the original text contains one or more terms in the custom term library, with the terms being replaced with asterisks (*).
results Array No The return results of the text moderation task. If HTTP status code 200 is returned, indicating a successful call, the array in the return results may contain one or more elements. Each element is a structure. For more information about the structure of each element, see result.
Table 2. result
Parameter Type Required Description
scene String Yes The moderation scenario of the moderated text, which you specify in the moderation request.
suggestion String Yes The machine-assisted moderation result of the moderated text. 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 Yes The category of moderation results for the moderated text in the specified moderation scenario. Valid values:
  • normal: The text is normal.
  • spam: The text contains junk content.
  • ad: The text contains ads.
  • politics: The text contains political content.
  • terrorism: The text contains terrorist content.
  • abuse: The text contains abuse.
  • porn: The text contains pornographic content.
  • flood: The text contains spam.
  • contraband: The text contains prohibited content.
  • meaningless: The text contains meaningless content.
  • customized: The text contains custom content. For example, the text contains a custom term.
rate Floating point Yes The probability that the moderated text falls into the category indicated by the label parameter. Valid values: 0.00 to 100.00. A larger value indicates a higher probability that the text falls into the category.
Note The value is only for reference. Pay attention to the label and suggestion parameters.
extras JSON object No The additional information about the moderated text.
details Array No 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 of each piece of risky content, see detail.
Table 3. detail
Parameter Type Required Description
label String Yes The category of the risky content that the moderated text hits in the specified moderation scenario. Valid values:
  • spam: The text contains junk content.
  • ad: The text contains ads.
  • politics: The text contains political content.
  • terrorism: The text contains terrorist content.
  • abuse: The text contains abuse.
  • porn: The text contains pornographic content.
  • flood: The text contains spam.
  • contraband: The text contains prohibited content.
  • meaningless: The text contains meaningless content.
  • customized: The text contains custom content. For example, the text contains a custom term.
contexts Array No The context information of the risky content that the moderated text hits. For more information about the structure of each piece of context information, see context.
hintWords JSON array No 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 of each term, see hintWord.
Note By default, the value of this parameter is not returned. If you need the value, submit a ticket.
Table 4. context
Parameter Type Required Description
context String Yes The context of the risky content that the moderated text hits. If the text hits a term or text pattern in your custom text library, the term or text pattern is returned.
libName String No The name of the custom text library returned if the moderated text hits a term or text pattern in the library.
libCode String No The code of the custom text library returned if the moderated text hits a term or text pattern in the library.
ruleType String No The type of the behavior rule 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 Required Description
context String Yes The term that the moderated text hits.

Examples

Sample requests
{
     "scenes": [
        "antispam"
    ],
     "tasks": [
          {
               "dataId": "xxxx$rdBjUC1C-1rd9Ah",
               "content": "Obama met with Trump in the White House yesterday."
        }
    ]
}
Sample success responses
{
      "msg": "OK",
      "code": 200,
      "data": [
            {
                  "msg": "OK",
                  "code": 200,
                  "dataId": "xxxx$rdBjUC1C-1rd9Ah",
                  "results": [
                        {
                              "rate": 50.0,
                              "suggestion": "review",
                              "details": [
                                    {
                                          "hintWords": [
                                                {
                                                      "context": "Obama"
                                }
                            ],
                                          "contexts": [
                                                {
                                                      "libCode": "123456",
                                                      "libName": "Name of your custom text library",
                                                      "context": "Trump"
                                }
                            ],
                                          "label": "politics"
                        }
                    ],
                              "label": "politics",
                              "scene": "antispam"
                }
            ],
                  "content": "Obama met with Trump in the White House yesterday.",
                  "filteredContent": "*** met with Trump in the White House yesterday.",
                  "taskId": "xxxxxxyyyyyy-xxxx"
        }
    ],
      "requestId": "yyyyyyyy-862F-4BAE-8B4E-xxxxxxx"
}