Filter mechanism

This is the documentation for 3.0.0 version, which is not the latest version. Consider upgrading to 4.4.0.

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

capitalization

bla.bla ⇒ bla. Bla

remove extra spacing

word1 word2 ⇒ word1 word2

remove doubled punctuation

.. ⇒ .

contractions (in French and Italian)

de un ⇒ d’un, de à côté ⇒ d’à côté, des les ⇒ des, una europea ⇒ un’europea

un / uno, i / gli (in Italian)

un psicologo ⇒ uno psicologo, i europei ⇒ gli europei

a / an

a apple ⇒ an apple, a hour ⇒ an hour (using english-a-an lib)