Filter mechanism

After the NLG text is generated by Pug and RosaeNLG, you most often have various small defects in your texts regarding spacing, capitalization and punctuation.

While you could put extra care in your NLG templates to avoid these defects, this is tedious and the cleaning task can be automated. Thus, once the NLG text is generated, a filtering function will automatically clean your texts. See Filter mixins and functions.

Table 1. Filtering examples
Type Original string ⇒ After filtering


bla.blabla. Bla

remove extra spacing

word1 word2word1 word2

remove doubled punctuation


contractions (in French and Italian)

de und’un, de à côtéd’à côté, des lesdes, una europeaun’europea

un / uno, i / gli (in Italian)

un psicologouno psicologo, i europeigli europei

a / an

a applean apple, a houran hour (using compromise lib)