Text Classification
Introduction
This API is used to automatically classify and determine whether a text is an advertisement.
For details about endpoints, see Endpoints.
Calling NLP APIs will incur fees. NLP packages are classified into the basic and domain-specific editions. When purchasing a package, view the APIs supported by the basic package and domain-specific packages in the Natural Language Processing Price Calculator.
URI
- URI format
POST /v1/{project_id}/nlu/classification - Parameter description
Table 1 URI parameters Parameter
Mandatory
Description
project_id
Yes
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.
Request
Table 2 describes the request parameters.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| content | String | Yes | Text to be analyzed. The text is encoded using UTF-8 and the value contains a maximum of 400 characters. If the value exceeds 400 characters, only the first 400 characters are detected. Only Chinese is currently supported. |
| domain | Integer | No | The default value is 1. Currently, only advertisement detection is supported. 1: Advertisement detection |
Response
Table 3 describes the response parameters.
| Parameter | Type | Description |
|---|---|---|
| result | Result object | Sentiment information returned when the API is successfully called. This parameter is not included when the API call fails. For details, see Table 4. |
| error_code | String | Error code returned when the API fails to be called. The parameter is not included when the API call succeeds. |
| error_msg | String | Error message returned when the API fails to be called. The parameter is not included when the API call succeeds. |
Example
- Example request
POST https://{endpoint}/v1/{project_id}/nlu/classification Request Header: Content-Type: application/json X-Auth-Token:MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "content":"XXX Anti-Dandruff Shampoo, free delivery within the country", "domain":1 }
- Example response
- Successful response example
{ "result": { "content":"XXX Anti-Dandruff Shampoo, free delivery within the country", "label": 1, "confidence": 0.74237967 } } - Failed response example
{ "error_code": "NLP.0101", "error_msg": "Authentication failed. Please verify the token" }
- Successful response example
Status code
For details about status codes, see Status Code.
Error Code
For details about error codes, see Error Code.
Last Article: Sentiment Analysis (Domain-specific Edition)
Next Article: Intent Understanding
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.