NER (Basic Edition)

Introduction

This API is used for named entity recognition (NER). Currently, it can be called to identify and analyze person names, locations, time, and organization names in the text.

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
  • 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.

Table 2 Request parameters

Parameter

Type

Mandatory

Description

text

String

Yes

Text to be analyzed. The text is encoded using UTF-8. Chinese text contains 1 to 512 characters and English and Spanish text contains 1 to 2,000 characters.

lang

String

No

Supported text language type. Currently, Chinese (zh), English (en), and Spanish (es) are supported. The default value is zh.

Response

Table 3 describes the response parameters.

Table 3 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.

Table 4 Data structure description of named_entity

Parameter

Type

Description

word

String

Entity text.

tag

String

Entity type

  • Currently, Chinese text supports nr (person name), ns (location name), nt (organization name), and t (time) tags.
  • English text supports per (person name), loc (location name), and org (organization name) tags.
  • Currently, Spanish text supports per (person name), loc (location name), org (organization name), and t (time) tags.

offset

Integer

Starting position of the entity text in the text to be analyzed.

len

Integer

Entity text length

Example

  • Example request
    POST https://{endpoint}/v1/{project_id}/nlp-fundamental/ner
    
    Request Header:
        Content-Type: application/json
        X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    
    Request Body:
        {
        "text":"Text for NER",
            "lang":"zh"
        }
  • Example response
    • Successful response example
      {
          "named_entities": [
              {
                  "word": "word-1",
                  "tag": "t",
                  "offset": 0,
                  "len": 2
              },
              {
                  "word": "word-2",
                  "tag": "nr",
                  "offset": 5,
                  "len": 3
              },
              {
                  "word": "word-3",
                  "tag": "ns",
                  "offset": 10,
                  "len": 2
              }
          ]
      }
    • Failed response example
      {
          "error_code": "NLP.0301",
          "error_msg": "The length of text should be in the range of 1-512."
      }

Status code

For details about status codes, see Status Code.

Error Code

For details about error codes, see Error Code.