Poem Generation
Introduction
This API is used to generate a poem according to the user input.
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}/nlg/poem - 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.
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | Yes | Integer | Poem type. The values are as follows:
|
| title | Yes | String | Poem title. Only the Chinese title is supported currently and it is encoded using UTF-8. The text length ranges from 1 to 10 characters. |
| acrostic | No | Boolean | Acrostic. The values are as follows:
The default value is false. |
Response
Table 3 describes the response parameters.
| Parameter | Type | Description |
|---|---|---|
| poem | Array[String] | Poem 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 a poem.
- Example request
POST https://{endpoint}/v1/{project_id}/nlg/poem Request Header: Content-Type: application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "type": 3, "title": "keyword-1", "acrostic":true } - Example response
- Successful example response
{ "poem": [ "keyword-1", "sentence-1", "sentence-2", "sentence-3", "sentence-4" ] } - Failed example response
{ "error_code": "NLP.3104", "error_msg": "poem_type is null or empty." }
- 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 Summarization (Domain-specific Edition)
Next Article: Text Generation
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.