roman-kutlak/nlglib

How to create a paragraph?

MaxTran96 opened this issue · 1 comments

How do you create a paragraph using nlglib?

Hi, here is an example.

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


if __name__ == '__main__':
    realise = Realiser(host='nlg.kutlak.info')
    p1 = Paragraph(
        Clause('Roman', VP('write', 'some', 'code')),
        Clause('nlglib', VP('translate', NP('the', 'code'), PP('to', 'XML'))),
        Clause('SimpleNLG', VP('convert', NP('the', 'XML'), PP('to', 'text')))
    )
    print(realise(p1))

>>> Roman writes some code. Nlglib translates the code to XML. SimpleNLG converts the XML to text.

Best,
Roman