Value for Nominal Groups

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

value is used to generate nominal groups: determiners, adjectives, nouns, plurals, etc.

Structure:

  • The first parameter of the tag is always the noun (or a list of nouns, see further)

  • The second parameter is a structured object with many optional keys, like det to indicate a determiner

For instance, \#[+value('homme', {det:'INDEFINITE', adj:'vieux', adjPos:'BEFORE'})] will generate un vieil homme.

If there is only the first parameter (a string), and nothing else, the string will be output as is. In necessary you can protect from inappropriate capitalization and contraction using protectString.

Determiners

Use det key to add a determiner. Available determiners are DEFINITE, INDEFINITE, DEMONSTRATIVE and POSSESSIVE.

Some languages have multiple distance levels for DEMONSTRATIVE. Use the additional key dist:

  • in English and Italian, use NEAR (default) for this/these (in English) and FAR for that/those (in English)

  • in Spanish, use PROXIMAL, MEDIAL or DISTAL

In English, when determiner is DEFINITE and number is plural, it will by default generate no article (machines). To trigger the article, put the useTheWhenPlural to true: \#[+value('machine', {det:'DEFINITE', number:'P', useTheWhenPlural: true})] will output the machines.

In French, when determiner is INDEFINITE and number is plural and there is an adjective before the noun, de will be output instead of des: de bons restaurants. To disable this mechanism, use FORCE_DES: \#[+value('service', {det:'INDEFINITE', adj:'nouveau', adjPos:'BEFORE', number:'P', FORCE_DES: true})] will output des bons restaurants.

In rare cases, you might want to generate only the determiner: \#[+value('', {det:'DEFINITE', gender:'M', number:'S'})].

Adjectives

One or multiple adjectives can be added and agreed automatically.

Apocope and specific cases are managed, like gran árbol in Spanish, vieil homme in French, etc.

One single adjective

If you wish to add only one single adjective, use the adj key. For instance \#[+value('house', { det:'DEFINITE', adj:'white'})] will generate the white house.

In some languages, like English, the adjective is always put before the noun. In some others, like French, it is often placed after (les gâteaux délicieux), but can also be placed before (les bons gâteaux). Set adjPos to BEFORE or AFTER to change the position of the adjective.

Table 1. Adjective position
Language Default Can be changed using adjPos

en_US

before

no

de_DE

before

no

es_ES

after

yes

fr_FR

after

yes

it_IT

after

yes

In French, \#[+value('affaire', {det:'INDEFINITE', adj:'sale', adjPos:'BEFORE', number:'P'})] will generate des sales affaires.

Multiple adjectives

Same structure but with a table e.g. adj:['nice','big']. adjPos remains valid.

Multiple adjectives, some before, some after

When you wish to have some adjectives before the noun and some other adjectives after, you can use the full form with BEFORE and AFTER: in French, \#[+value('vache', {det:'INDEFINITE', adj:{ BEFORE: ['beau', 'intelligent'], AFTER: ['brun'] } })] will generate une belle et intelligente vache brune.

Use SEP_BEFORE and SEP_AFTER to override the default separator between adjectives (defaut is localized and): for instance, in Spanish, \#[+value('árbol', { det:'DEFINITE', adj:{BEFORE:['primero', 'grande'], SEP_BEFORE:''} })] will output el primer gran árbol.

In agreeAdj and subjectVerbAdj mixins, you can also put a list of adjectives, but there is a difference: value will output all the adjectives, while agreeAdj and subjectVerbAdj will randomly choose one.

Possessive adjectives (Italian only)

In Italian, you can add a possessive adjective: \#[+value('gioiello', {det: 'DEFINITE', possessiveAdj:'mio'})]. You could also use adj directly but possessive adjectives are automatically placed properly.

Examples

Case (German only)

In German, use case to indicate the case: NOMINATIVE, ACCUSATIVE, DATIVE or GENITIVE.

\#[+value('Gurke', {case:'GENITIVE', det:'DEFINITE', adj:'alt'})] will output der alten Gurke.

Assign the gender of the word to an object

This is useful when using referring expressions: different words, having potentially a different gender (and sometimes number) can be used to refer to a same concept (in practice an object).

Use represents to assign the gender of the word to the representant.

only useful for languages with a gender, like French, German, Italian, Spanish etc. - not for English.
Table 2. All those 4 constructions do exactly the same thing

Just plain text, and setting gender directly:

| cette bague
- setRefGender(PRODUIT, 'F');

Just plain text, and using the dictionnary to set the gender (French or German):

| cette bague
- setRefGender(PRODUIT, 'bague');

Using value with represents option (and dictionnary lookup):

| cette #[+value('bague', {represents: PRODUIT})]

Using value with represents and det options (and dictionnary lookup):

| #[+value('bague', {represents: PRODUIT, det: 'DEMONSTRATIVE'})]

Number and gender

Number

The determiner, noun and adjectives can be agreed in number. You can set explicitely the number using number:

  • can be directly S or P: \#[+value('affaire', {det:'INDEFINITE', number:'P'})] will output des affaires

  • or you can refer to an existing object that carries a number: \#[+value("tomato", { number: getAnonMP() } )] will output tomatoes

If the gender of the word cannot be determined automatically from the dictionnary (for instance it is a brand name), you can add a gender key.
It indicates the number of the owned object. When using possessives, you might also have to indicate the owner of the object.

Gender

By default the gender is automatically inferred from the word itself, using linguistic resources.

When some words or expressions are not in the dictionnary, you must indicate explicitely the gender. For instance, \#[+value('OnePlus 5T', {represents: PRODUKT2, gender:'N', det: 'DEFINITE'})] will output das OnePlus 5T in German, and also assign N to current gender of PRODUKT2.

Ownership

Use owner to indicate an owner. See third possession.

List of nouns

First parameter is generally a single noun, but you can also put a list. One noun will randomly be chosen.