Sentence Generating API

Overview

An API for generating English sentences for a given input.

How to use Linguatools Sentence Generating API

The API can realise simple sentences given a subject, a verb and an object. Optional additional parameters allow to specify features like tense, number, voice, sentence type. The following table shows example request parameters and their outputs.

request parametersgenerated sentence
subject=police&verb=arrest&object=thiefThe police arrests a thief.
subject=police&verb=arrest&object=thief&tense=pastThe police arrested a thief.
subject=police&verb=arrest&object=thief&tense=past&passive=passiveA thief was arrested by the police.
subject=police&verb=arrest&object=thief&objmod=suspected&perfect=perfect&objnum=plural&objdet=theThe police has arrested the suspected thieves.
subject=police&verb=arrest&object=thief&objmod=suspected&perfect=perfect&objnum=plural&objdet=the&sentencetype=yesnoHas the police arrested the suspected thieves?

Connect to API

Endpoint

You can test the API and develop your own application – for free, with

  1. our test translate API on Heroku OR
  2. after sign up in RapidAPI  

1. Heroku

For testing, the following endpoint can be used with HTTP method GET:
https://lt-nlgservice.herokuapp.com/rest/english/realise

Query example: https://lt-nlgservice.herokuapp.com/rest/english/realise?subject=dog&verb=eat&object=watter&tense=past&progressive=progressive&festesmerkmal=tense,progressive

Important note (!):
The initial API call might take up to 30 seconds because the heroku dyno falls asleep after 30 minutes of inactivity. (The test API runs on a free heroku dyno.)

2. RapidAPI

https://rapidapi.com/petapro/api/linguatools-sentence-generating

Query parameters

parameterdescriptionparameter value
subjectrequiredany noun, any pronoun
subjdetoptional
specifies the subject’s determiner. Default is „the“. Use subjdet=- to generate a subject without determiner.
a, the, –
subjnumoptional
specifies the subject’s number. Default is singular. A value of plural is overridden by subjdet=a.
singular, plural
verbrequiredany verb, including phrasal verbs like „start out“
objectrequired
If the object is a pronoun set objdet=- and use the base form of the pronoun (e.g. she instead of her). Possible base forms are: I, you, he, she, it, we, they. This will be automatically replaced by me, you, him, her, it, us, them.
Set objnum=plural to get the plural forms (e. g. object=he and objdet=- and objnum=plural yields them).
any noun or pronoun
objdetoptional
specifies the object’s determiner. Default is „a“. Use objdet=- to generate an object without determiner.
a, the, –
objnumoptional
specifies the object’s number. Default is singular. A value of plural is overridden by objdet=a.
singular, plural
objmodoptional
specifies an adjective modifying the object
any adjective
tenseoptional
specifies the verb’s tense. Default is „present“
present, past, future
progressiveoptional
&progressive=progressive sets the progressive (continuous) tense
progressive
perfectoptional
&perfect=perfect sets the perfect tense
perfect
negatedoptional
&negated=negated generates a negated sentence
negated
passiveoptional
&passive=passive generates a sentence in passive voice. The object is set as subject and the subject becomes the by-object.
passive
modaloptional
specifies a modal verb modifying the verb. Only allowed for present tense. If tense=past or tense=future is set then the parameter modal will be ignored.
can, may, must, ought, shall, should, would
sentencetypeoptional
specifies the sentence type. Default is a declarative sentence. &sentencetype=yesno generates a yes/no-question, whatobj generates a WH-question for the object, whosubj generates a WH-question for the subject
yesno, whatobj, whosubj

Response

If successful, the response body contains a JSON object with the generated sentence:

If there was an error the response status is 400 and the response body contains a JSON object with an error message:

Licensing conditions

The API/data package can be used in any number of private and commercial projects of the purchaser:
E. g. in a website application, in a smartphone app etc.

Redistribution is not allowed.

If you want to use the API/data package in your project please contact peter.kolb@linguatools.org
The prices for the API start at 0 € per month for the BASIC plan.

Pricing

Demo

The sentence generator  https://gramomat.com/ is based on the Sentence Generating API.