RosaeNLG node.js project generator

This is the documentation for 4.2.0 version, which is not the latest version. Consider upgrading to 4.3.0.

Use yeoman along with RosaeNLG generator to bootstrap automatically a new standard node.js RosaeNLG project.

It follows (my) best practices so that you can quickly start your own RosaeNLG project.

It is based on the content of the English tutorial.

Generate a project

  • install yeoman: npm install -g yo

  • install RosaeNLG generator for yeoman: run npm install -g generator-rosaenlg

  • create a folder to will contain your project, and go in that folder

  • run yo rosaenlg

This will create a blank standard RosaeNLG projet. If you have existing templates in json file, use unpack option: e.g. yo rosaenlg --unpack chanson.json.

yeoman

Generating texts

First create a dist folder. Then just use gulp texts to generate the texts in dist folder.

Data load and pre processing

At some point you have to load into data and also pre process it. You can use init.js for that.

Templates organisation

One possible organization for your templates:

  • phoneForHtml.pug and phoneForJson.pug are technical entrypoints: they are almost the same, and mainly call the phone mixin

  • includes.pug centralizes all your includes: this is handy when you refactor

  • phones.pug is the real entrypoint for NLG: it generates the text for a phone

  • phone_refexpr.pug contains the reference and referring expressions for phones. Create one file per object you describe (car_refexpr.pug) etc.

  • sentences (most of the textual content) are in sentences:

    • one file per sentence: colors.pug generates the sentence about the colors, intro.pug is the introduction sentence etc.

    • If you have longer sentences and paragraphs you should create a more sophisticated hierarchy, but I recommend to keep 1 file per sentence.

Testing

You should (really) have some regression testing on your texts. It just compares texts with reference texts previously generated.

  • Use gulp nonreg to regenerate the reference file in tests/phonesNonreg.json. It contains texts along with the random seed (the same random seed has to be used when running the tests).

  • Run the tests using npm run test or mocha