Help Center> Natural Language Processing> API Reference> NLP APIs> LG APIs> Text Summarization (Domain-specific Edition)

Text Summarization (Domain-specific Edition)

Introduction

This API is used to train summarization models of a specific field based on corpus of that field, which can improve the text summarization effect.

Basic text summarization and domain-specific text summarization are implemented based on different algorithms, so the results for processing the same text are different. According to the test data, the effect of the domain-specific edition is better than that of the basic edition.

This API is free of charge and can be called twice per second.

URI

  • URI format
    POST /v1/{project_id}/nlg/summarization/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

The following table describes the request parameters.

Table 2 Request parameters

Parameter

Mandatory

Type

Description

lang

No

String

Supported text language type. Currently, Chinese is supported. The default value is zh.

title

No

String

Text title. Currently, the title is encoded using UTF-8. The text length cannot exceed 1,000 characters.

content

Yes

String

Text body. Currently, the title is encoded using UTF-8. The text length cannot exceed 10,000 characters.

length_limit

No

Float

Length limit of the generated summary

  • If the value is greater than 1, it is the number of characters in the summary.
  • If the value is between 0 and 1, it is the percentage of the generated summary to the original length.

The default value is 0.3.

type

No

Integer

Supported domain type. Currently, only general domain is supported. The default value is general.

0: general domain

Response

Table 3 describes the response parameters.

Table 3 Response parameters

Parameter

Type

Description

summary

String

Summary result returned based on the text request body.

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.

Example

The following example shows the generation of summaries from texts.

  • Example request
    POST https://{endpoint}/v1/{project_id}/nlg/summarization/domain
    
    Request Header:
        Content-Type: application/json
        X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
    
    Request Body:
        {
           "length_limit":0.3,
           "title":"Almost 600 plant species have become extinct in the last 250 years",
           "lang": "zh",
           "content":" Almost 600 plant species have been wiped from the planet in the past 250 years, more than twice the number of bird, mammal and amphibian species that have met the same fate, according to a new study.The research -- published Monday in Nature, Ecology & Evolution journal -- found that 571 plant species have disappeared from the wild worldwide, and that plant extinction is occurring up to 500 times faster than the rate it would without human intervention.For comparison, the researchers said animal extinction is occurring at least 1,000 times faster than the normal rate of extinction, however the report notes that researchers believe the plant extinction rate has been underestimated. The Royal Botanic Gardens, Kew and Stockholm University researchers say it's the first time scientists have compiled a global overview of which plants have already become extinct. Most people can name a mammal or bird that has become extinct in recent centuries, but few can name an extinct plant, report co-author Aleys Humphreys said. Plants on islands, in the tropics and in Mediterranean climates had the highest rates of plant extinction, as these were areas home to unique species vulnerable to human activities. The study said the increase in the plant extinction rate could be due to the loss of habitat of species located in a small geographic area. Some examples of plants that have gone extinct in the past two centuries are the aromatic Chile sandalwood and the banded trinity, which has no leaves -- only its flowers are visible above the ground."
          "type":0
        }
  • Example response
    • Successful example response
      {
          "Summary": "Almost 600 plant species have been wiped from the planet in the past 250 years, more than twice the number of bird, mammal and amphibian species that have met the same fate, according to a new study.The research -- published Monday in Nature, Ecology & Evolution journal -- found that 571 plant species have disappeared from the wild worldwide, and that plant extinction is occurring up to 500 times faster than the rate it would without human intervention.For comparison, the researchers said animal extinction is occurring at least 1,000 times faster than the normal rate of extinction, however the report notes that researchers believe the plant extinction rate has been underestimated."
      }
    • Failed example response
      {
          "error_code": "NLP.3104",
          "error_msg": "content is empty."
      }

Status Code

For details about status codes, see Status Code.

Error Code

For details about error codes, see Error Code.