Skip to main content

Natural Language Generation library for Python

Project description

Current Status build

This is just a starting point - an alpha version - mainly a wrapper around SimpleNLG.

Although it is possible to go from first order logic to text, there is no sophistication in how things are processed. The library is still missing basics like aggregation or referring expression generation.


Either download the code from the repository and run python install or use pip: pip install nlglib.


NLGlib is a library for natural language generation (NLG) written in Python. It seeks to fill a gap in the NLG field. There are currently no off-the-shelf libraries that one could take and incorporate into other projects. The aim of this library is to be useful for general projects that would like to add a bit of text generation to their capabilities.


The library should be usable by programmers with no prior linguistic knowledge. Given that the aim of the library is language generation, some linguistic knowledge is necessary but you should be able to pick it up from the examples.


The aim of the library is to create a base for NLG system starting from content selection all the way to realisation. The library will cover document structuring tools, lexicalisation, referring expression generation and aggregation. Realisation will be done using other realisation libraries (SimpleNLG or pynlg).


NLGlib started as a part of the EPSRC project Scrutable Autonomous Systems (SAsSy): When the project finished, the code was moved to this repository to create a stand-alone re-usable library.


from nlglib.realisation.simplenlg.realisation import Realiser
from nlglib.microplanning import *

realise_en = Realiser(host='', port=40000)
realise_es = Realiser(host='', port=40001)

def main():
    p = Clause("María", "perseguir", "un mono")
    p['TENSE'] = 'PAST'
    # expected = 'María persigue un mono.'
    p = Clause(NP("la", "rápida", "corredora"), VP("perseguir"), NP("un", "mono"))
    subject = NP("la", "corredora")
    objekt = NP("un", "mono")
    verb = VP("perseguir")
    p.subject = subject
    p.predicate = verb
    p.object = objekt
    # expected = 'La rápida corredora persigue un mono.'
    p = Clause(NP('this', 'example'), VP('show', 'how cool simplenlg is'))
    # expected = This example shows how cool simplenlg is.

if __name__ == '__main__':

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nlglib-0.2.1.tar.gz (55.0 kB view hashes)

Uploaded Source

Built Distribution

nlglib-0.2.1-py3-none-any.whl (3.3 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page