NER (Domain-specific Edition)
Introduction
This API is used to identify named entities of text. Currently, NER is supported in the general, business, and entertainment domains.
- General domain: includes entities such as person name, location, organization, time point, date, percentage, currency, ordinal number, quantifier, nationality, occupation, email address, country, and festival.
- Business domain: includes entities such as company name, brand, job, position, email address, mobile number, telephone number, IP address, ID card number, and website.
- Entertainment domain: includes entities such as movie name, animation name, book name, Internet-related entity, song name, product name, drama name, and TV program name.
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}/nlp-fundamental/ner/domain
- 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 |
|---|---|---|---|
| text | String | Yes | Text to be analyzed. The text is encoded using UTF-8 and contains 1 to 512 characters. |
| lang | String | No | Supported language type. Currently, only Chinese is supported. The default value is zh. |
| domain | String | No | Supported domain type. The value can be general, business, or entertainment. The default value is general. |
Response
Table 3 describes the response parameters.
| Parameter | Type | Description |
|---|---|---|
| named_entities | Array of named_entity objects | NER result. For details, see Table 4. |
| error_code | String | Error code when the API fails to be called. For details, see Error Code. 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 |
|---|---|---|
| word | String | Entity text |
| tag | String | Entity type
|
| offset | Integer | Start position of the entity text in the text to be analyzed |
| len | Integer | Length of an entity text |
Example 1
- Example request
POST https://{endpoint}/v1/{project_id}/nlp-fundamental/ner/domain Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "text":"Text for NER", "lang":"zh", "domain":"general" } - Example response
- Successful example response
{ "named_entities": [ { "len": 2, "offset": 0, "tag": "day", "word": "word-1" }, { "len": 3, "offset": 2, "tag": "job", "word": "word-2" }, { "len": 3, "offset": 5, "tag": "nr", "word": "word-3" }, { "len": 2, "offset": 10, "tag": "ns", "word": "word-4" }, { "len": 2, "offset": 32, "tag": "ord", "word": "word-5" } ] } - Failed example response
{ "error_code": "NLP.0301", "error_msg": "The length of text should be in the range of 1-512." }
- Successful example response
Example 2
- Example request
POST https://{endpoint}/v1/{project_id}/nlp-fundamental/ner/domain Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "text":"Programmer Xiaoming is a Huawei employee. His email address is xiaoming@xx.com and phone number is 12345678.", "lang":"zh", "domain":"business" } - Example response
- Successful example response
{ "named_entities": [ { "len": 3, "offset": 0, "tag": "job", "word": "word-2" }, { "len": 2, "offset": 6, "tag": "com", "word": "Huawei" }, { "len": 15, "offset": 15, "tag": "email", "word": "xiaoming@xx.com" }, { "len": 8, "offset": 33, "tag": "tele", "word": "12345678" } ] } - Failed example response
{ "error_code": "NLP.0301", "error_msg": "The length of text should be in the range of 1-512." }
- Successful example response
Example 3
- Example request
POST https://{endpoint}/v1/{project_id}/nlp-fundamental/ner/domain Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "text": "Text for NER", "lang":"zh", "domain":"entertainment" } - Example response
- Successful example response
{ "named_entities": [ { "len": 3, "offset": 8, "tag": "anime", "word": "word-1" }, { "len": 2, "offset": 18, "tag": "song", "word": "word-2" }, { "len": 4, "offset": 25, "tag": "pro", "word": "word-3" }, { "len": 3, "offset": 31, "tag": "dra", "word": "word-4" } ] } - Failed example response
{ "error_code": "NLP.0301", "error_msg": "The length of text should be in the range of 1-512." }
- 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: NER (Basic Edition)
Next Article: Text Similarity (Basic Edition)
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.