Integration in Observable HQ

Observable is an online dataviz platform. As it is JavaScript based, RosaeNLG can easily be used.

Basic integration

In a cell, you can put the following code:

  const rosaenlg = await require('');

  const version = rosaenlg.getRosaeNlgVersion();

  const template = `
| he #[+verb(getAnonMS(), {verb: 'eat', tense: 'PAST'})]
itemz { separator: ', ', last_separator: 'and', end:'.' }
    | a orange
    | a pear
    | #[+value('apple', { det:'INDEFINITE', adj: {BEFORE:['big', 'red'], SEP_BEFORE: ''} })]
| his favorite fruits are
eachz fruit in fruits with { separator: ', ', last_separator: 'and also', end:'.' }
  | #[+value(fruit, {number:'P'})]

  const rendered = rosaenlg.render(template, {
    language: 'en_US',
    fruits: ['avocado', 'mango', 'pear']
  return html`<b>${rendered}</b>`

will output: He ate an orange, a pear and a big red apple. His favorite fruits are avocados, mangoes and also pears.

note the await on the require line.
basic integration

Cleaner integration

You may split the different cells like in this example.