Intent Understanding
Introduction
This API is used to identify user's intent in content related to weather, time, news, joke, translation, note, alarm and music. It identifies a specific domain from user's questions and statements and extracts entities contained in the domain.
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/semantic-parser - Parameter description
| 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 |
|---|---|---|---|
| text | String | Yes | Text list to be analyzed. The text is encoded using UTF-8 and the value contains a maximum of 32 characters. If the value exceeds 32 characters, only the first 32 characters are detected. |
| lang | String | No | Supported language type. Currently, only Chinese is supported. The default value is zh. |
Response
| Parameter | Type | Description |
|---|---|---|
| result | Result object | Intent information returned when the API is successfully called. This parameter is not included when the API fails to be called. 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. |
| Parameter | Type | Description |
|---|---|---|
| text | String | Text to be analyzed |
| label | String | Intent label of the text to be analyzed. Labels are classified into the following types: weather, time, news, joke, translation, notification, alarm, music, and others. |
| confidence | Float | Confidence level of a label |
| slots | Array of slot | Data structure of slots. For details, see Table 5. |
| Parameter | Type | Description |
|---|---|---|
| word | String | Entity text |
| tag | String | Entity type. The entity types supported by each intent category are: weather: date, time, location time: location, timezone news: genre joke: genre translation: content notification: content, date, time, singer alarm: date, time music: singer, song, content |
| offset | Integer | Start position of the entity text in the text to be analyzed |
| length | Integer | Length of an entity text |
| normalized_word | String | Synonym or other normalized word. The default value is the original word. |
Examples
- Example request
POST https://{endpoint}/v1/{project_id}/nlu/semantic-parser Request Header: Content-Type: application/json X-Auth-Token:MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "text":"Text for analysis", "lang":"zh" }
- Example response
- Successful example response
{ "result": { "confidence": 1, "label": "music", "slots": [ { "length": 3, "normalized_word": "word-1", "offset": 3, "tag": "singer", "word": "word-1", }, { "length": 3, "normalized_word": "word-2", "offset": 7, "tag": "song", "word": "word-2" } ], "text": "Response" } } - Failed example response
{ "error_code": "NLP.0101", "error_msg": "Authentication failed. Please verify the token" }
- Successful example response
Status Code
For details about status codes, see Status Code.
Error Code
For details about error codes, see Error Code.
Last Article: Text Classification
Next Article: MT APIs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.