Value mixin

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

The value(obj, params) mixin is the entry point to insert a value in a text. Its behavior depends of the type of obj.

value is the entry point of many RosaeNLG powerful features. Don’t miss it!

Number

When obj is a number, you can indicate how to format it: units, ordinals, cardinals, etc. For instance, #[+value(5500, {'TEXTUAL':true })] will output five thousand five hundred.

Date

When obj is a date, the date-fns lib will be used to format it. You should put a parameter to indicate how to format it. See Value for Dates.

String / noun

When obj is a string, it will either just output the string, or generate a nominal group if more parameters are set. For instance, #[+value('apple', { det:'INDEFINITE', adj:'big' })] will generate a big apple.

There is an alternative Simplified Syntax available for some languages.

Structured object

When obj is a structured object, it will trigger the referring expressions mechanisms.

The first parameter is an object, and there are generally very few additional parameters: for instance, #[+value(PRODUCT)] or #[+value(PRODUCT, {REPRESENTANT: 'ref'})].

You have to define how to transform the structured object into text.

When integrating rosae with typescript, you can also use the additional parameter deprel to pass information about the grammatical function of the object to the referring expressions mixins: for instance, you can restrict the use of the pronoun he or she to the subject of a sentence. The value of this parameter has to be tested in the mixin that generates the text (i.e., there is not automatic underlying behavior).

Value of a mixin

When the first parameter is a mixin, this mixin will be called, and the additional parameters of value will simply be sent to the mixin.