Text Summarization
- Example request
//You are advised to construct and use the client in a singleton pattern to avoid frequent object creation. NlgClient client = new NlgClient(AuthMode.AKSK,authInfo); SummaryReq req = new SummaryReq(); //Text content req.setContent("Almost 600 plant species have been wiped from the planet in the past 250 years," + "more than twice the number of birds," + "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. "); //Optional. Text title req.setTitle("Almost 600 plant species have become extinct in the last 250 years"); //Optional. Length limit of the generated text summarization. If the value is between 0 and 1, the length percentage is close to the value. If the value is greater than 1, the summarization is the one whose text length is closest to the value. req.setLengthLimit(0.3f); //Optional. The default value is zh, indicating Chinese. Only Chinese is currently supported. req.setLang("zh"); try { SummaryResp resp = client.summary(req); } catch (NlpException e) { //A failure is thrown as an exception. For details about exceptions, see section "Exceptions". The client automatically processes exceptions. }
- Table 1 describes SummaryReq parameters.
Table 1 SummaryReq parameters Parameter
Mandatory
Type
Description
content
Yes
String
Text body. Currently, the title is encoded using UTF-8. The text length ranges from 1 to 10,000 characters. (Note: The text language type must be consistent with the value of lang.)
title
No
String
Text title. Currently, the title is encoded using UTF-8. The text length ranges from 0 to 1,000 characters.
lang
No
String
Supported text language type. Currently, Chinese (zh) and English (en) are supported. The default value is zh.
lengthLimit
No
Float
Length limit of the generated summary.
- If the value of length_limit is greater than 1, the returned result is the summary whose length is the closest to the value.
- If the value of length_limit ranges from 0 to 1, the returned result is the summary whose length percentage is closest to the value.
The default value is 0.3.
- Table 2 describes SummaryResp parameters.
Last Article: Calling LG APIs
Next Article: Accessing the Client via HTTP Proxies
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.