Skip to main content

Sentence Generator

Run in Postman

In this article you will learn how to generate sentences using APIs or CLI commands.

Prerequisites

Make sure to follow Getting Started to log in and install the NeuralSpace Augmentation Service. If you are using APIs, save your authorization token in a variable called AUTHORIZATION_TOKEN before moving ahead.

Generate Sentences

To generate sentences using the CLI, use the command mentioned below. Pass a sample text to be used for generating more sentences in -t and number of sentences required in -n.

neuralspace augmentation parse -t "TEXT TO BE AUGMENTED" -n 3

Generate Sentences with Entities

With this API you can generate upto 10 semantically similar sentences with entity annotations preserved. Imagine the amount of annotated text data you can generate. If you have existing chatbot datasets then you can even 10x your dataset size and make your chatbot more robust.

Simply pass your text in the text attribute, and number of sentences required in exampleCount attribute. entities are the annotations you want to preserve in the generated sentences. Entities have to have a start and an end character index denoting where in the text they occur. Additionally, each entity should have a value attribute which should contain the exact entity value, and an entity attribute denoting the type of entity it is.

Translate with Entities API
curl --location --request POST 'https://platform.neuralspace.ai/api/augmentation/v1/annotated/augment' \
--header 'Accept: application/json, text/plain, */*' \
--header "authorization: ${AUTHORIZATION_TOKEN}" \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "Protesters, led by the South Bengaluru MP, had vandalised CM Arvind Kejriwal’s house last month and clashed with police during a demonstration against the CM’s comments on the movie “The Kashmir Files”",
"exampleCount": 10,
"entities": [
{
"start": 23,
"end": 38,
"value": "South Bengaluru",
"entity": "geo-political-entities"
},
{
"start": 61,
"end": 78,
"entity": "person",
"value": "Arvind Kejriwal’s"
},
{
"start": 155,
"end": 157,
"entity": "organization",
"value": "CM"
},
{
"start": 183,
"end": 200,
"entity": "work-of-art",
"value": "The Kashmir Files"
}
]
}'

The response object looks something like the following. Note that the entities are preserved in the generated sentences. The list of entities correspond to the list of suggested sentences.

{
"success": true,
"message": "Data fetched successfully",
"data": {
"text": "Protesters, led by the South Bengaluru MP, had vandalised CM Arvind Kejriwal’s house last month and clashed with police during a demonstration against the CM’s comments on the movie “The Kashmir Files”",
"augmentation_suggestions": [
"protesters, led by the south bengaluru mp, vandalized cm arvind kejriwal house last month and clashed with police during a protest against the cm 's comments on the movie \" the kashmir files ”",
"protesters, led by bengaluru i south the deputy, had vandalized cm arvind kejriwal's houses last month and clashed with police during a demonstration against cm movie comments ” kashmir files ”",
"opponents, b south bengalru destroys a member of parliament cm arvind kejriwal's at home last month and clashed with police during a protest rally. cm your comments on the film kashmir files ”",
"protesters led by south bengaluru deputy, may sabotage poison arvind kejriwal a house last month they clashed with the police during a demonstration against poison comments on the movie kashmir files \"",
"the protesters led by south bengal mp, was vandalized sm: arvind kejriwali house last month վել clashed with police during a protest rally sm: movie comments: cashmere files »",
"protesters led by south bengal mp, committed vandalism sm arvind kejriwal home last month clashed with police during a protest sm comments about the movie \" kashmir files ”",
"demonstrators, leader south bengaluru mp, he vandalized cm arvind kejriwal-ena house in the last month and clashed with police in a rally against them cm movie comments \" kashmir files ”",
"protesters led by the village south bengaluru mp, vandalism cm arvind kedzhrival house last month and clashed with police during a demonstration against cm comments to the film « kashmiri files ”",
"the protesters led south bangalore mp vandalized cm arvind kejriwal home last month and clashes with police during protests against it cm his comments about the movie \" kashmir file \"",
"protesters, led south bengaluru mp, vandalized cm arvind kejriwal's house last month and clashed with police during a demonstration against cm user comments on film “ kashmir files ”"
],
"entities_output": [
[
{
"start": 22,
"end": 38,
"value": " south bengaluru",
"entity": "geo-political-entities"
},
{
"start": 53,
"end": 56,
"value": " cm",
"entity": "organization"
},
{
"start": 56,
"end": 72,
"value": " arvind kejriwal",
"entity": "person"
},
{
"start": 53,
"end": 56,
"value": " cm",
"entity": "organization"
},
{
"start": 172,
"end": 190,
"value": " the kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 18,
"end": 36,
"value": " bengaluru i south",
"entity": "geo-political-entities"
},
{
"start": 63,
"end": 66,
"value": " cm",
"entity": "organization"
},
{
"start": 66,
"end": 84,
"value": " arvind kejriwal's",
"entity": "person"
},
{
"start": 63,
"end": 66,
"value": " cm",
"entity": "organization"
},
{
"start": 177,
"end": 191,
"value": " kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 12,
"end": 27,
"value": " south bengalru",
"entity": "geo-political-entities"
},
{
"start": 59,
"end": 62,
"value": " cm",
"entity": "organization"
},
{
"start": 62,
"end": 80,
"value": " arvind kejriwal's",
"entity": "person"
},
{
"start": 59,
"end": 62,
"value": " cm",
"entity": "organization"
},
{
"start": 176,
"end": 190,
"value": " kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 17,
"end": 33,
"value": " south bengaluru",
"entity": "geo-political-entities"
},
{
"start": 54,
"end": 61,
"value": " poison",
"entity": "organization"
},
{
"start": 61,
"end": 77,
"value": " arvind kejriwal",
"entity": "person"
},
{
"start": 54,
"end": 61,
"value": " poison",
"entity": "organization"
},
{
"start": 185,
"end": 199,
"value": " kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 21,
"end": 34,
"value": " south bengal",
"entity": "geo-political-entities"
},
{
"start": 53,
"end": 57,
"value": " sm:",
"entity": "organization"
},
{
"start": 57,
"end": 74,
"value": " arvind kejriwali",
"entity": "person"
},
{
"start": 53,
"end": 57,
"value": " sm:",
"entity": "organization"
},
{
"start": 158,
"end": 173,
"value": " cashmere files",
"entity": "work-of-art"
}
],
[
{
"start": 17,
"end": 30,
"value": " south bengal",
"entity": "geo-political-entities"
},
{
"start": 54,
"end": 57,
"value": " sm",
"entity": "organization"
},
{
"start": 57,
"end": 73,
"value": " arvind kejriwal",
"entity": "person"
},
{
"start": 54,
"end": 57,
"value": " sm",
"entity": "organization"
},
{
"start": 156,
"end": 170,
"value": " kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 21,
"end": 37,
"value": " south bengaluru",
"entity": "geo-political-entities"
},
{
"start": 55,
"end": 58,
"value": " cm",
"entity": "organization"
},
{
"start": 58,
"end": 78,
"value": " arvind kejriwal-ena",
"entity": "person"
},
{
"start": 55,
"end": 58,
"value": " cm",
"entity": "organization"
},
{
"start": 170,
"end": 184,
"value": " kashmir files",
"entity": "work-of-art"
}
],
[
{
"start": 29,
"end": 45,
"value": " south bengaluru",
"entity": "geo-political-entities"
},
{
"start": 59,
"end": 62,
"value": " cm",
"entity": "organization"
},
{
"start": 62,
"end": 80,
"value": " arvind kedzhrival",
"entity": "person"
},
{
"start": 59,
"end": 62,
"value": " cm",
"entity": "organization"
},
{
"start": 178,
"end": 193,
"value": " kashmiri files",
"entity": "work-of-art"
}
],
[
{
"start": 18,
"end": 34,
"value": " south bangalore",
"entity": "geo-political-entities"
},
{
"start": 48,
"end": 51,
"value": " cm",
"entity": "organization"
},
{
"start": 51,
"end": 67,
"value": " arvind kejriwal",
"entity": "person"
},
{
"start": 48,
"end": 51,
"value": " cm",
"entity": "organization"
},
{
"start": 168,
"end": 181,
"value": " kashmir file",
"entity": "work-of-art"
}
],
[
{
"start": 15,
"end": 31,
"value": " south bengaluru",
"entity": "geo-political-entities"
},
{
"start": 46,
"end": 49,
"value": " cm",
"entity": "organization"
},
{
"start": 49,
"end": 67,
"value": " arvind kejriwal's",
"entity": "person"
},
{
"start": 46,
"end": 49,
"value": " cm",
"entity": "organization"
},
{
"start": 166,
"end": 180,
"value": " kashmir files",
"entity": "work-of-art"
}
]
]
}
}