Help Center > > API Reference> APIs> Moderation (Text)> Text Moderation

Text Moderation

Updated at: Mar 30, 2021 GMT+08:00

Function

This API analyzes and identifies whether the uploaded text contains pornographic elements, and returns the result to you.

Prerequisites

  • Before using Text Moderation, you need to apply for the service and complete authentication. For details, see Getting Started with Moderation (Text).
  • By default, the maximum number of concurrent API calls is 50. To increase concurrency, contact Huawei technical support.

URI

URI format

POST /v1.0/moderation/text

Request Message

Table 1 describes the request parameters.

Table 1 Request parameters

Parameter

Mandatory

Type

Description

items

Yes

Array

Indicates the items to be checked. Currently, only one item can be checked each time.

text

Yes

String

Indicates the text to be checked. The encoding format is UTF-8. A maximum of 5,000 characters is allowed. If the number of characters to be checked exceeds the upper limit, only the first 5,000 characters will be checked.

type

No

String

Indicates the text type. The default value is content. Currently, only the content type is supported.

categories

No

Array

Indicates the detection scenario.

Currently, the following scenarios are supported:

  • Default scenarios:
    • porn: indicates pornographic information detection.
    • ad: indicates advertisement detection.
    • abuse: indicates offensive content detection.
    • contraband: indicates contraband information detection.
    • flood: indicates spamming detection.
  • User-defined scenario: custom blacklist dictionary
    NOTE:
    • For details about how to create and use a custom dictionary, see Configuring a Custom Dictionary.
    • The custom whitelist dictionary cannot be used in the flood scenario.

Response Message

Table 2 describes the response parameters.

Table 2 Response parameters

Parameter

Type

Description

result

Object

Indicates the calling result when the API is successfully called.

This parameter is not included when the API fails to be called.

detail

Object

Indicates details about the returned check result. Possible values are as follows:

  • porn: indicates a list of pornographic words.
  • ad: indicates a list of sensitive advertisement words.
  • abuse: indicates a list of offensive words.
  • contraband: indicates a list of words related to contraband.
  • flood: indicates spam, or unwanted content particularly in forums that provide little value to readers.
    NOTE:
    • The spam content contains a maximum of 200 characters.
    • The details about the returned check result of each scenario refer to only the detected words instead of the whole content.

suggestion

String

Indicates whether the check is passed.

block: indicates that sensitive information is detected and the information fails to pass the check.

pass: indicates that no sensitive information is detected and the information passes the check.

review: indicates that the text needs to be manually reviewed.

error_code

String

Indicates the error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Indicates the error message of a failed API call.

This parameter is not included when the API is successfully called.

Examples

  • Example request
    POST https://moderation.ap-southeast-1.myhuaweicloud.co/v1.0/moderation/text
        
    Request Header:      
    Content-Type:application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    Request Body:
    {
       "categories":["ad","abuse","porn","contraband","flood"],
       "items":[
          {
              "text": "asdfasdfasdf",
              "type": "content"
          }
        ]
    }
  • Example successful response
    {
        "result": {
            "detail": {
                "flood": "asdfasdfasdf"
            },
            "suggestion": "block"
        }
    }
      
  • Example failed response
    {
        "error_code": "AIS.0005",
        "error_msg": "The service does not exist."
    }

Status Code

  • Normal

    200

  • Abnormal

    Return Value

    Description

    400

    • The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
    • The request parameter is incorrect.

    401

    The request requires user authentication.

    403

    No operation permission.

    404

    The server has not found anything matching the Request-URI.

    500

    The server encountered an unexpected condition which prevented it from fulfilling the request.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel