Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Text Moderation (V2)

Updated on 2024-03-27 GMT+08:00

Function

Moderation (Text) analyzes and identifies whether the uploaded text contains sensitive information and returns the result to you.

NOTE:
  1. Currently, only Chinese content moderation is supported.
  2. By default, the maximum number of concurrent API calls is 50. To increase concurrency, contact Huawei technical support.
  3. You can configure a custom dictionary to filter and detect specified text content. For details about how to create and use a custom dictionary, see Configuring a Custom Dictionary.

Prerequisites

Before using Text Moderation, you need to apply for the service and complete authentication. For details, see Getting Started with Moderation (Text).

URI

POST /v2/{project_id}/moderation/text

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Indicates the user token.

Used to obtain the permission to operate APIs. For details about how to obtain the token, see Authentication. The value of X-Subject-Token in the response header is the token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

categories

No

Array of strings

Indicates the detection scenario.

Currently, the following scenarios are supported:

  • Default scenarios:
    • porn: indicates pornographic information detection.
    • abuse: indicates offensive content detection.
    • contraband: indicates contraband information detection.
    • flood: indicates the spamming detection. (Spamming refers to one or more digits, characters, or punctuations that appear repeatedly in a text.)
  • Custom scenario: custom blocklist dictionary
    NOTE:
    • In the default scenarios, AI-based text detection technology is used to identify the text you upload. In the custom scenario, you can configure a blocklist library to filter and detect specified text.
    • For details about how to create and use a custom dictionary, see Configuring a Custom Dictionary.
    • The custom allowlist dictionary cannot be used in the flood scenario.

white_glossaries

No

Array of strings

Indicates the enabled whitelists. If this parameter is not set, the whitelist dictionaries created before 16:00:00 on September 2, 2022 are used by default.

The rules for configuring this parameter are as follows:
  • If you set this parameter to an empty list (that is, [ ]), no whitelist dictionary will be used.
  • If you set this parameter to the name of the whitelist dictionary you have created, the dictionary will be used.
    NOTE:

    If you want to use multiple whitelist dictionaries, for example, A, B, and C, set this parameter to ["A", "B", "C"].

For details about how to create and use whitelist dictionaries, see Creating a Custom Allowlist Dictionary.

items

Yes

Array of TextDetectionItemsReq objects

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

Table 4 TextDetectionItemsReq parameters

Parameter

Mandatory

Type

Description

text

Yes

String

Indicates the text to be detected. The text is encoded using UTF-8 and contains 1 to 5,000 characters. If the text contains more than 5,000 characters, only the first 5,000 characters are detected.

type

No

String

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

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

result

result object

Indicates the calling result of a successful API call.

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

Table 6 result parameters

Parameter

Type

Description

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 a manual review is required.

detail

Object

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

  • porn: indicates a list of pornographic 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.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

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.

fail_category

String

Indicates the API calling failure scenario when there are multiple scenarios.

Example Requests

Check whether the asdfasdfasdf text contains sensitive content, including advertisements, abuse, porn, contraband, and spam.

NOTE:

endpoint is the request URL for calling an API. Endpoints vary depending on services and regions. For details, see Endpoints.

For example, the endpoint of the service deployed in the CN-Hong Kong region is moderation.ap-southeast-1.myhuaweicloud.com, the request URL is https://moderation.ap-southeast-1.myhuaweicloud.com/v2/{project_id}/moderation/text, and project_id is the project ID. For details, see Obtaining a Project ID and Name.

POST https://{endpoint}/v2/{project_id}/moderation/text

{
  "categories" : [  "abuse", "porn", "contraband", "flood" ],
  "items" : [ {
    "text" :  "asdfasdfasdf",
    "type" : "content"
  }
 ]
}

Example Responses

Status code: 200

Example of a successful response

{
  "result" : {
    "detail" : {
      "abuse" : [ "fuck" ]
    },
    "suggestion" : "block"
  }
}

Status code: 400

Example of a failed response

{
  "error_code" : "AIS.0005",
  "error_msg" : "The service does not exist."
}

Status Codes

Status Code

Description

200

Example of a successful response

400

Example of a failed response

Error Codes

For details, see Error Codes.

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback