Verbs

This is the documentation for 1.5.0 version, which is not the latest version. Consider upgrading to 3.4.0.

A proper NLG system is able to agree things and to make conjugations. Classic structures are subject/verb or subject/verb/adjective.

Supported persons are 3rd person singular & plural only.

Before anything we need to define what subjects can be.

Subjects

A subject has to have a gender and a number. A simple way to define a subject is to use an existing js object and to affect it a gender and a number.

var PRODUCT = {something: 'somehow'};
setRefGender(PRODUCT, 'M');
setRefNumber(PRODUCT, 'P');
in French or German, setRefGender(PRODUCT, 'bague'); will look for bague in the dictionnary and set PRODUCT gender to F. Same as setRefGender(PRODUCT, 'F'); here.

If you don’t want to bother with objects because they don’t exist or are too insignificant to be really created, you can ask the system to provide anonymous subjects:

var subjS = getAnonymous('M', 'S');

getAnonymous(gender, number) will create an anonymous object and record is with the right gender and number.

At last, you can use complex structure like referring expressions to define your subjects.

Conjugate verbs subjectVerb and verb

Use subjectVerb(subject, verb) to agree a verb with a subject. +subjectVerb(PRODUCT, 'shine') will output the ring shines.

verb(subject, verb) will just output the agreed verb but not the subject. +verb(PRODUCT, 'shine') will output shines.

Instead of putting directly a verb (like shine), you can add extra parameters for the verb, typically the tense. +subjectVerb(PRODUCT, {verb:'shine', tense:'PAST'}) will output the ring shined.

subjectVerb and verb also accept a last optional param which is transmitted as is to the subject. For instance, +subjectVerb(PRODUCT, 'shine', {REPRESENTANT: 'refexpr'}) will force the referring expression representation of the product, thus outputting something like it shines.

English support

English conjugations are made with compromise lib. Accepted tenses are:

  • PRESENT which is also the default value

  • PAST

  • FUTURE

German support

Accepted tenses are:

  • Indicativ: PRASENS (default value) PRATERITUM FUTUR1 FUTUR2 PERFEKT PLUSQUAMPERFEKT

  • Konjunktiv1: KONJUNKTIV1_PRASENS KONJUNKTIV1_FUTUR1 KONJUNKTIV1_PERFEKT

  • Konjunktiv2: KONJUNKTIV2_PRATERITUM KONJUNKTIV2_FUTUR1 KONJUNKTIV2_FUTUR2

For somes tenses (FUTUR1 FUTUR2 PERFEKT PLUSQUAMPERFEKT KONJUNKTIV1_FUTUR1 KONJUNKTIV1_PERFEKT KONJUNKTIV2_FUTUR1 KONJUNKTIV2_FUTUR2), the complete verb cannot be generated immediately: a part has to be put at the end of the sentence. Use verbPart to output the infinitive that is automatically stored when using verb. es #[+verb(subjS, {verb: 'aussehen', tense:'FUTUR1' } )] chaotisch #[+verbPart] will generate es wird chaotisch aussehen.

in subjectVerb, you can invert the position of the subject and the verb using invertSubjectVerb. gestern #[+subjectVerb(ER, {verb:'gehen', tense:'PERFEKT', aux:'SEIN'}, {'invertSubjectVerb':true})] in der Schule #[+verbPart] will output gestern ist er in der Schule gegangen.

Pronominal form using pronominal:true: er #[+subjectVerb(getAnonMS(), {verb:'waschen', aux:'HABEN', tense:'FUTUR2', pronominal:true})] die Hände #[+verbPart] will output er wird sich die Hände gewaschen haben.

French support

Any verb of all 3 verb groups are available thanks to lefff derived resource: ils #[+verb(subjMP, 'oindre')] will output ils oignent.

Supported tenses are:

  • PRESENT

  • FUTUR

  • IMPARFAIT

  • PASSE_SIMPLE

  • CONDITIONNEL_PRESENT

  • IMPERATIF_PRESENT

  • SUBJONCTIF_PRESENT

  • SUBJONCTIF_IMPARFAIT

  • PASSE_COMPOSE

  • PLUS_QUE_PARFAIT

For PASSE_COMPOSE and PLUS_QUE_PARFAIT, you have to indicate:

  1. Which auxiliary to use (être or avoir): set aux to AVOIR or ETRE

  2. With what to agree the participle (optional, masculine singular being the default): set agree

  3. NB: when aux is ETRE, the participle is automatically agreed with the subject

For instance:

  • elles #[+verb(getAnonFP(), {verb: 'sortir', tense:'PASSE_COMPOSE', aux:'ETRE', agree: getAnonFP()})] will generate elles sont sorties

  • elles #[+verb(getAnonFP(), {verb: 'sortir', tense:'PASSE_COMPOSE', aux:'AVOIR'})] la poubelle will generate elles ont sorti la poubelle

If the auxiliary is not set, these rules will apply:

  • pronominal verbs always use ETRE

  • there is a short list of verbs that always take ETRE

  • transitive verbs rather take AVOIR

PASSE_COMPOSE can be used to mimic the passive form. elle #[+verb(getAnonFS(), {verb: 'convoquer', tense:'PASSE_COMPOSE', aux:'ETRE', agree:getAnonFS()})] will output elle est convoquée. But elle #[+subjectVerbAdj(getAnonFS(), 'être', 'convoqué')] generates the same output and is much simplier.

Pronominal form using pronominal:true: ils #[+verb(getAnonMP(), {verb: 'immerger', tense:'IMPARFAIT', pronominal:true})] will output ils s’immergeaient.

Italian support

Thanks to a derived resource from [morph-it](https://docs.sslmit.unibo.it/doku.php?id=resources:morph-it) which provides an extensive morphological resource for the Italian language.

Supported tenses are:

  • Indicative: PRESENTE, IMPERFETTO, PASSATO_REMOTO, FUTURO_SEMPLICE, PASSATO_PROSSIMO, TRAPASSATO_PROSSIMO, TRAPASSATO_REMOTO, FUTURO_ANTERIORE

  • Conjonctive: CONG_PRESENTE, CONG_PASSATO, CONG_IMPERFETTO, CONG_TRAPASSATO

  • Conditional: COND_PRESENTE, COND_PASSATO

  • IMPERATIVO

When tense is a composed tense (PASSATO_PROSSIMO, TRAPASSATO_PROSSIMO, TRAPASSATO_REMOTO, FUTURO_ANTERIORE, CONG_PASSATO, CONG_TRAPASSATO, COND_PASSATO), you have to indicate:

  1. Which auxiliary to use (essere or avere): set aux to ESSERE or AVERE

  2. With what to agree the participle (optional, masculine singular being the default): set agree

For instance:

  • #[+verb(getAnonMS(), 'mangiare')] will generate mangia

  • #[+verb(getAnonMP(), {verb:'mangiare', aux:'AVERE', tense:'TRAPASSATO_REMOTO'})] will generate ebbero mangiato

Conjugate verbs and agree adjectives with subjectVerbAdj

Use subjectVerbAdj(subject, verbInfo, adjective) to directly generate a subject, a conjugated verb and an agreed adjective. #[+subjectVerbAdj(PRODUCT, 'être', 'luxueux')] will output la bague est luxueuse.

subjectVerbAdj also accepts a last optional parameter that is transmitted as is to the subject.

Also see agree adjectives.