Recording what was said for further use: recordSaid
and hasSaid
Sometimes you need to record what you just said to keep that information for the upcoming texts. For instance you mention the brand of the product in some mixin, and you have another mixin which can also trigger the brand: you might only want to output the brand once.
You might wonder why you can not just use global variables to record what was said. The problem is that RosaeNLG needs to go back and forth in the text generation (typically to predict which synonymic alternatives are empty), and this means that you must not use global variables to record what was said, because RosaeNLG will not be able to rollback after a synonym simulation.
Thus you should use recordSaid
and hasSaid
. They basically only are accessors to an internal map, which is properly rollbacked when necessary.
This will only output brand is … once.
You can use recordSaid('BRAND')
or - recordSaid('BRAND');
- it is the same.
You can use dumpHasSaid to see what is in the internal map.
|
All the js functions related to the internal map:
-
recordSaid(key)
: to record that something was said. -
hasSaid(key)
: returns a boolean indicating if something was said. -
deleteSaid(key)
: forget that something was said. -
getFlagValue(params, flag)
: whereashasSaid
andrecordSaid
use the internal map solely to store booleans,getFlagValue
uses it to store any kind of value.