Aller à ↓ Goto ↓ [FREN]

pyrealb Documentation (Version 3.2.2)

pyrealb est un réalisateur de texte pour l'anglais et le français écrit en Python. Des appels de fonctions Python, rappelant les notations de syntaxe en constituants ou en dépendences, créent une structure qui sera réalisée en appelant la fonction str(), souvent de façon implicite via la fonction print.
Pour l'utiliser, une fois le package Python installé selon les instructions données dans le répertoire GitHub, il suffit d'ajouter la ligne suivante à son programme.

pyrealb is a text realizer for French and English written in Python. Calls to Python functions, similar to the syntactic constituency or dependencies notations create a structure that can be realized with str() , most often implicitely within a print function.
Once installed according to the instructions on the GitHub, using it is only a matter of adding the following line to the program.

from pyrealb import *

pyrealb peut aussi être utilisé pour créer une page web comme celle-ci dans laquelle les exemples ont été réalisés par pyrealb lors de la création de la page.

pyrealb can be used to build web pages such as this one in which all examples were realized using pyrealb when the page was created.

Constituants

Constituents

Terminaux

NomReprésentationExempleRéalisation
NomN(…)N("joueur")joueur
AdjectifA(…)A("grand")grand
PronomPro(…)Pro("je")il
DéterminantD(…)D("le")le
VerbeV(…)V("apprendre")apprend
AdverbeAdv(…)Adv("bien")bien
PrépositionP(…)P("dans")dans
ConjonctionC(…)C("et")et
Date avec options facultativesDT(…)DT()le dimanche 9 mars 2025 à 15 h 50 min 3 s
Nombre avec options facultativesNO(…)NO(2)2
Texte brut"…""Wow"Wow
Texte brut auquel on peut ajouter des optionsQ(…)Q("Bang !").tag("i")Bang !

Terminals

NameRepresentationExampleRealisation
NounN(…)N("player")player
AdjectiveA(…)A("tall")tall
PronounPro(…)Pro("I")it
DeterminerD(…)D("the")the
VerbV(…)V("learn")learns
AdverbAdv(…)Adv("well")well
PrepositionP(…)P("in")in
ConjunctionC(…)C("and")and
Date possibly with optionsDT(…)DT()on Sunday, March 9, 2025 at 3:50:03 p.m.
Number possibly with optionsNO(…)NO(2)2
Raw text"…""Wow"Wow
Raw text to which options can be addedQ(…)Q("Bang !").tag("i")Bang !

Syntagmes

NomReprésentationExempleRéalisation
Syntagme nominalNP(…)NP(D("le"), N("voiture"))la voiture
Syntagme adjectivalAP(…)AP(Adv("très"), A("grand"))très grand
Syntagme adverbialAdvP(…)AdvP(Adv("bien"), Adv("heureusement"))bien heureusement
Syntagme verbalVP(…)VP(V("prendre"), NP(D("le"), N("course")))prend la course
Syntagme PrépositionnelPP(…)PP(P("à"), NP(N("minuit")))à minuit
Syntagme coordonnéCP(…)CP(C("et"), AP(A("vaillant")), AP(A("gentil")), AP(A("serviable")))vaillant, gentil et serviable
 CP sans CCP(…)CP(AP(A("vaillant")), AP(A("gentil")), AP(A("serviable")))vaillant, gentil, serviable
PhraseS(…)S(NP(D("le"),N("homme")), VP(V("dormir")))L'homme dort.
Syntagme subordonnéSP(…)SP(Pro("que"), Pro("je"), VP(V("rencontrer").t("pc")))qu'il a rencontré

Phrases

NameRepresentationExampleRealisation
Noun PhraseNP(…)NP(D("the"), N("car"))the car
Adjective PhraseAP(…)AP(Adv("very"), A("tall"))very tall
Adverbial PhraseAdvP(…)AdvP(Adv("far"), Adv("back"))far back
Verbal PhraseVP(…)VP(V("enjoy"), NP(D("a"), N("meal")))enjoys a meal
Prepositional PhrasePP(…)PP(P("at"), NP(N("midnight")))at midnight
Coordinated PhraseCP(…)CP(C("and"), AP(A("kind")), AP(A("strong")), AP(A("beautiful")))kind, strong and beautiful
 CP with no CCP(…)CP(AP(A("kind")), AP(A("strong")), AP(A("beautiful")))kind, strong, beautiful
SentenceS(…)S(NP(D("the"),N("man")), VP(V("sleep")))The man sleeps.
Subordinated PhraseSP(…)SP(Adv("that"), Pro("I"), VP(V("meet").t("ps")))that it met

Les accords simples sont effectués entre les constituants d'un syntagme. Un constituant est considéré comme la tête avec lequel les autres sont accordés. La tête est déterminée de la façon suivante:

Des options (section suivante) appliquées à une instance de Terminal (e.g. N, V, ...) spécifiant le genre et le nombre l'emportent sur ces accords automatiques.

Simple agreements are dealt with between constituents of a phrase. A constituent is taken as the head with which others agree. The head is found as follows:

Options (next section) applied to an instance of Terminal (e.g. N, V, ...) override these automatic agreements.

Dépendents

NomReprésentationExempleRéalisation
Racine de la phraseroot(…)root(V("aimer"),subj(Pro("lui").c("nom")))Il aime.
Sujetsubj(…)subj(N("enfant").n("p"),det(D("le")))les enfants
Déterminantdet(…)det(D("le"))le
Complément du verbecomp(…)comp(N("fromage"),det(D("le")))le fromage
Modificateurmod(…)mod(A("bon").f("su"))le meilleur
Coordinationcoord(C(…)…)coord(C("et"),subj(N("chat")),subj(N("chien")),subj(N("souris"))).n("p")chats, chiens et souris
Coordination sans Ccoord(Q("")…)coord(Q(""),subj(N("chat")),subj(N("chien")),subj(N("souris"))).n("p")chats, chiens, souris

Dependencies

NameRepresentationExampleRealisation
Root of dependenciesroot(…)root(V("love"),subj(Pro("me").c("nom")))It loves.
Subjectsubj(…)subj(N("child").n("p"),det(D("a")))children
Determinerdet(…)det(D("the"))the
Verb complementcomp(…)comp(N("cheese"),det(D("the")))the cheese
Modifiermod(…)mod(A("good").f("su"))best
Coordinationcoord(C(…)…)coord(C("and"),subj(N("cat")),subj(N("dog")),subj(N("mouse"))).n("p")cats, dogs and mice
Coordination without Ccoord(Q("")…)coord(Q(""),subj(N("cat")),subj(N("dog")),subj(N("mouse"))).n("p")cats, dogs, mice

Le premier paramètre d'une dépendance est un terminal. Les autres paramètres doivent être d'autres dépendances.

coord regroupe des dépendances de même type coordonnées par la conjonction donnée comme terminal. Les dépendents seront séparés par une virgule sauf les deux derniers qui seront séparés par la conjonction. coord sans dépendent sera ignoré à la réalisation. coord avec un seul dépendent apparaitra sans la conjonction. Si le terminal est une chaîne vide, alors tous les éléments seront séparés par une virgule.

Les accords simples sont effectués automatiquement entre les dépendents:

Position des dépendents: det et subj sont réalisées avant le terminal, alors que mod, comp et coord sont réalisées dans l'ordre où elles sont spécifiées. Il est possible de modifier cet ordre en utilisant la méthode .mod("pre") pour forcer une dépendance à apparaître avant, ou .mod("post") pour apparaître après.

The first parameter of a dependency is a terminal. The other parameters must be dependents.

coord combines dependencies of the same type coordinated by the conjunction given as terminal. Dependencies will comma separated except for the last two that will be separated by the conjunction. A coord without dependent will not be realized. A coord with a single dependent will be realized without the conjunction. If the terminal is an empty string, then all dependents will be comma separated.

Simple agreements are realized between dependents:

Dependent position: det et subj are realized before the terminal, while mod, comp et coord are realized after in the order of their specification. This ordering can be changed using .mod("pre") to force a dependent to be realized before, or .mod("post") to be realized after.

Déclinaisons et conjugaisons

Declension and conjugation

NomReprésentationExempleRéalisation
Temps (défaut "p").t(…)
présent.t("p")V("aimer").t("p")aime
infinitif (forme de base).t("b")V("aimer").t("b")aimer
imparfait.t("i")V("aimer").t("i")aimait
passé simple.t("ps")V("aimer").t("ps")aima
futur.t("f")V("aimer").t("f")aimera
impératif présent.t("ip")V("aimer").t("ip").pe(2)aime
conditionnel présent.t("c")V("aimer").t("c")aimerait
participe présent.t("pr")V("aimer").t("pr")aimant
subjonctif présent.t("s")V("aimer").t("s")aime
subjonctif imparfait.t("si")V("aimer").t("si")aimât
participe passé.t("pp")V("aimer").t("pp")aimé
Temps composés (défaut "p").t(…)
passé composé.t("pc")V("aimer").t("pc")a aimé
plus-que-parfait.t("pq")V("aimer").t("pq")avait aimé
conditionnel passé.t("cp")V("aimer").t("cp")aurait aimé
futur antérieur.t("fa")V("aimer").t("fa")aura aimé
passé antérieur.t("pa")V("aimer").t("pa")eut aimé
subjonctif passé.t("spa")V("aimer").t("spa")ait aimé
subjonctif plus-que-parfait.t("spq")V("aimer").t("spq")eût aimé
infinitif passé.t("bp")V("aimer").t("bp")avoir aimé
nombre (défaut "s").n(…)
verbe au singulier.n("s")V("manger").n("s")mange
verbe au pluriel.n("p")V("manger").n("p")mangent
nom au singulier.n("s")N("joueur").n("s")joueur
nom au pluriel.n("p")N("joueur").n("p")joueurs
adjectif au singulier.n("s")A("grand").n("s")grand
adjectif au pluriel.n("p")A("grand").n("p")grands
déterminant au pluriel.n("p")D("le").n("p")les
déterminant au pluriel.n("p")D("un").n("p")des
déterminant possessif au pluriel.n("p")…D("mon").n("p").pe(2)tes
déterminant possessif (sujet au pluriel).n("p")…D("notre").n("p").pe(2)vos
Possessif anglais sur un N ou Q.poss()NP(Q("Maria").poss(),N("car"))Maria's car
Genre (défaut "m").g(…)
nom masculin.g("m")N("joueur").g("m")joueur
nom féminin.g("m")N("joueur").g("f")joueuse
adjectif masculin.g("m")A("grand").g("m")grand
adjectif féminin.g("m")A("grand").g("f")grande
déterminant masculin.g("m")D("le").g("m")le
déterminant féminin.g("m")D("le").g("f")la
personne (défaut 3).pe(…)
1ère personne du singulier.pe(1)V("aimer").pe(1)aime
2e personne du singulier.pe(2)V("aimer").pe(2)aimes
3e personne du singulier.pe(3)V("aimer").pe(3)aime
1ère personne du pluriel.pe(1).n("p")V("aimer").pe(1).n("p")aimons
2e personne du pluriel.pe(2).n("p")V("aimer").pe(2).n("p")aimez
3e personne du pluriel.pe(3).n("p")V("aimer").pe(3).n("p")aiment
déterminant (adjectif possessif) féminin.g("f").p(1)D("mon").g("f").pe(1)ma
Comparaisons.f(…)
comparatif.f("co")A("bon").f("co")meilleur
superlatif.f("su")A("bon").f("su")le meilleur
Changement d'auxiliaire, le défaut est donné par le lexique..aux(…)
par défautV("aller").t("pc")est allé
par défautV("changer").t("pc")a changé
auxiliaire avoir.aux("av")V("aller").t("pc").aux("av")a allé
auxiliaire être.aux("êt")V("changer").t("pc").aux("êt")est changé
Verbe essentiellement réflexif indiqué dans le lexique.
par défautV("enfuir").t("pc")s'est enfui
NameRepresentationExampleRealisation
Tense (default "p").t(…)
present.t("p")V("love").t("p")loves
infinitive (base form).t("b")V("love").t("b")love
infinitive with to.t("b-to")V("love").t("b-to")to love
simple past.t("ps")V("love").t("ps")loved
future.t("f")V("love").t("f")will love
present imperative.t("ip")V("love").t("ip").pe(2)love
conditional.t("c")V("love").t("c")would love
present participle.t("pr")V("love").t("pr")loving
present subjonctive.t("s")V("love").t("s")love
past subjonctive.t("si")V("love").t("si")loved
past participle.t("pp")V("love").t("pp")loved
Compound tenses (see .typ({"perf":True})).t(…)
number (default "s").n(…)
verb singular.n("s")V("eat").n("s")eats
verb plural.n("p")V("eat").n("p")eat
noun singular.n("s")N("player").n("s")player
noun plural.n("p")N("player").n("p")players
adjective singular.n("s")A("big").n("s")big
adjective plural.n("p")A("big").n("p")big
determiner plural.n("p")D("the").n("p")the
determiner plural.n("p")D("a").n("p")
possessive determiner masculine (singular owner).n("p")…D("my").n("p").g("m").ow("s")his
possessive determiner (plural owner).n("p")…D("my").n("p").ow("p")their
English possessive on a N or Q.poss()NP(N("woman").poss(),N("dress"))woman's dress
Gender (default "n").g(…)
person (default 3).pe(…)
first person singular.pe(1)V("be").pe(1)am
second person singular.pe(2)V("be").pe(2)are
third person singular.pe(3)V("be").pe(3)is
first person plural.pe(1).n("p")V("be").pe(1).n("p")are
second person plural.pe(2).n("p")V("be").pe(2).n("p")are
third person plural.pe(3).n("p")V("be").pe(3).n("p")are
Comparison.f(…)
comparative.f("co")A("good").f("co")better
superlative.f("su")A("good").f("su")best
Change of auxiliary (ignored in English).aux(…)
Reflexive verb using .typ({refl:True})
.typ({"refl":True})VP(V("wash")).typ({"refl":True})washes itself

Perfect and continuous tenses for verbs can obtained by setting the sentence type to .typ({perf:true}) or .typ({prog:true})

Pronoms

Pronouns

Les pronoms qui sont dans le lexique sont à la 1ère personne du singulier. Pour obtenir les autres, il faut spécifier la personne, le nombre et éventuellement le genre. Ce mécanisme s'applique aussi pour les pronoms me et moi-même et pour le déterminant mon.

Pronouns in the lexicon are at the first person singular. To get the other forms, the gender, the number and the person must be specified. The same option mechanism can be used for the pronouns mine and myself and for the determiner my.

NomReprésentationExempleRéalisation
Pronom sujet
1ère personne du singulier.pe(1)Pro("je").pe(1)je
2e personne du singulier.pe(2)Pro("je").pe(2)tu
3e personne du masculin singulier.pe(3)Pro("je").pe(3)il
3e personne du féminin singulier.pe(3).g("f")Pro("je").pe(3).g("f")elle
1ère personne du pluriel.pe(1).n("p")Pro("je").pe(1).n("p")nous
2e personne du pluriel.pe(2).n("p")Pro("je").pe(2).n("p")vous
3e personne du pluriel.pe(3).n("p")Pro("je").pe(3).n("p")ils
3e personne du pluriel au féminin.pe(3).n("p").g("f")Pro("je").pe(3).n("p").g("f")elles
'on' invariablePro("on")on
Pronom sujet accentué
1ère personne du singulier.pe(1)Pro("moi").pe(1)moi
2e personne du singulier.pe(2)Pro("moi").pe(2)toi
3e personne du masculin singulier.pe(3)Pro("moi").pe(3)lui
3e personne du féminin singulier.pe(3).g("f")Pro("moi").pe(3).g("f")elle
1ère personne du pluriel.pe(1).n("p")Pro("moi").pe(1).n("p")nous
2e personne du pluriel.pe(2).n("p")Pro("moi").pe(2).n("p")vous
3e personne du pluriel.pe(3).n("p")Pro("moi").pe(3).n("p")eux
3e personne du pluriel au féminin.pe(3).n("p").g("f")Pro("moi").pe(3).n("p").g("f")elles
Autres types de pronoms
Pronom possessif.pe(3).n("s")Pro("mien").pe(3).n("s")sien
À soi.pe(3).n("p")Pro("nôtre").pe(3).n("p")leurs
Moi réflexif.pe(3).n("p")Pro("moi*refl").pe(3).n("p")soi
Me réflexif.pe(3).n("p")Pro("me*refl").pe(3).n("p")se
Me complément d'objet indirect.pe(3).n("p")Pro("me*coi").pe(3).n("p")leur
NameRepresentationExampleRealisation
Pronoun as subject
First person singular.pe(1)Pro("I").pe(1)I
Second person singular.pe(2)Pro("I").pe(2)you
Third person masculine singular.pe(3)Pro("I").pe(3).g("m")he
Third person feminine singular.pe(3).g("f")Pro("I").pe(3).g("f")she
Third person neutral singular.pe(3).g("n")Pro("I").pe(3)it
First person plural.pe(1).n("p")Pro("I").pe(1).n("p")we
Second person plural.pe(2).n("p")Pro("I").pe(2).n("p")you
Third person plural.pe(3).n("p")Pro("I").pe(3).n("p")they
Pronoun as subject itself
First person singular.pe(1)Pro("me").pe(1)me
Second person singular.pe(2)Pro("me").pe(2)you
Third person masculine singular.pe(3)Pro("me").pe(3).g("m")him
Third person feminine singular.pe(3).g("f")Pro("me").pe(3).g("f")her
Third person neutral singular.pe(3).g("n")Pro("me").pe(3)it
First person plural.pe(1).n("p")Pro("me").pe(1).n("p")us
Second person plural.pe(2).n("p")Pro("me").pe(2).n("p")you
Third person plural.pe(3).n("p")Pro("me").pe(3).n("p")them
Other types of pronouns
Singular owner.pe(3).n("s")Pro("mine").pe(3).n("s").ow("s")its
Plural owner.pe(3).n("p")Pro("mine").pe(2).n("p").ow("p")yours
Reflexive.pe(3).n("p")Pro("myself").pe(3).n("p")themselves

Pronoms en modifiant la forme tonique Pronouns from the tonic form

  • la forme tonique .tn(..) avec comme paramètre
    • "": pour la forme tonique elle-même
    • refl pour obtenir la forme réflexive (terminant en -même)
  • la forme clitique .c(..) avec comme paramètre
    • nom pour la forme nominative
    • acc pour la forme accusative (complément d'objet direct)
    • dat pour la forme datif (complément d'objet indirect)
    • refl pour la forme réfléchie

Afin de rester compatible avec la méthode de spécification précédente, les formes clitiques et toniques des pronoms doivent spécifier .pe(1) pour le pronom moi. Il en est de même pour les pronoms possessifs mien et nôtre ainsi que pour les déterminants possessifs mon et notre.

Le tableau suivant présente la forme obtenue au-dessus de la spécification pyrealb.

lemme tonique tonique réfléchi clitique nominatif clitique accusatif clitique datif clitique réfléchi
moi
Pro("moi").g("m").n("s").pe(1)
moi
Pro("moi").tn("").pe(1)
moi-même
Pro("moi").tn("refl").pe(1)
je
Pro("moi").c("nom").pe(1)
me
Pro("moi").c("acc").pe(1)
me
Pro("moi").c("dat").pe(1)
me
Pro("moi").c("refl").pe(1)
toi
Pro("moi").g("m").n("s").pe(2)
toi
Pro("toi").tn("")
toi-même
Pro("toi").tn("refl")
tu
Pro("toi").c("nom")
te
Pro("toi").c("acc")
te
Pro("toi").c("dat")
te
Pro("toi").c("refl")
lui
Pro("moi").g("m").n("s").pe(3)
lui
Pro("lui").tn("")
lui-même
Pro("lui").tn("refl")
il
Pro("lui").c("nom")
le
Pro("lui").c("acc")
lui
Pro("lui").c("dat")
se
Pro("lui").c("refl")
nous
Pro("moi").g("m").n("p").pe(1)
nous
Pro("nous").tn("")
nous-mêmes
Pro("nous").tn("refl")
nous
Pro("nous").c("nom")
nous
Pro("nous").c("acc")
nous
Pro("nous").c("dat")
nous
Pro("nous").c("refl")
vous
Pro("moi").g("m").n("p").pe(2)
vous
Pro("vous").tn("")
vous-mêmes
Pro("vous").tn("refl")
vous
Pro("vous").c("nom")
vous
Pro("vous").c("acc")
vous
Pro("vous").c("dat")
vous
Pro("vous").c("refl")
eux
Pro("moi").g("m").n("p").pe(3)
eux
Pro("eux").tn("")
eux-mêmes
Pro("eux").tn("refl")
ils
Pro("eux").c("nom")
les
Pro("eux").c("acc")
leur
Pro("eux").c("dat")
se
Pro("eux").c("refl")
moi
Pro("moi").g("f").n("s").pe(1)
moi
Pro("moi").tn("")
moi-même
Pro("moi").tn("refl")
je
Pro("moi").c("nom")
me
Pro("moi").c("acc")
me
Pro("moi").c("dat")
me
Pro("moi").c("refl")
toi
Pro("moi").g("f").n("s").pe(2)
toi
Pro("toi").tn("")
toi-même
Pro("toi").tn("refl")
tu
Pro("toi").c("nom")
te
Pro("toi").c("acc")
te
Pro("toi").c("dat")
te
Pro("toi").c("refl")
elle
Pro("moi").g("f").n("s").pe(3)
elle
Pro("elle").tn("")
elle-même
Pro("elle").tn("refl")
elle
Pro("elle").c("nom")
la
Pro("elle").c("acc")
lui
Pro("elle").c("dat")
se
Pro("elle").c("refl")
nous
Pro("moi").g("f").n("p").pe(1)
nous
Pro("nous").tn("")
nous-mêmes
Pro("nous").tn("refl")
nous
Pro("nous").c("nom")
nous
Pro("nous").c("acc")
nous
Pro("nous").c("dat")
nous
Pro("nous").c("refl")
vous
Pro("moi").g("f").n("p").pe(2)
vous
Pro("vous").tn("")
vous-mêmes
Pro("vous").tn("refl")
vous
Pro("vous").c("nom")
vous
Pro("vous").c("acc")
vous
Pro("vous").c("dat")
vous
Pro("vous").c("refl")
elles
Pro("moi").g("f").n("p").pe(3)
elles
Pro("elles").tn("")
elles-mêmes
Pro("elles").tn("refl")
elles
Pro("elles").c("nom")
les
Pro("elles").c("acc")
leur
Pro("elles").c("dat")
se
Pro("elles").c("refl")
on
Pro("on")
soi
Pro("on").tn("")
soi-même
Pro("on").tn("refl")
on
Pro("on").c("nom")
le
Pro("on").c("acc")
soi
Pro("on").c("dat")
se
Pro("on").c("refl")

Le tableau suivant présente la forme obtenue au-dessus de la spécification pyrealb.

lemme masculin singulier féminin singulier masculin pluriel féminin pluriel
mien
Pro("mien").pe(1)
mien
Pro("mien").pe(1).n("s").g("m")
mienne
Pro("mien").pe(1).n("s").g("f")
miens
Pro("mien").pe(1).n("p").g("m")
miennes
Pro("mien").pe(1).n("p").g("f")
tien
Pro("mien").pe(2)
tien
Pro("tien").n("s").g("m")
tienne
Pro("tien").n("s").g("f")
tiens
Pro("tien").n("p").g("m")
tiennes
Pro("tien").n("p").g("f")
sien
Pro("mien").pe(3)
sien
Pro("sien").n("s").g("m")
sienne
Pro("sien").n("s").g("f")
siens
Pro("sien").n("p").g("m")
siennes
Pro("sien").n("p").g("f")
nôtre
Pro("nôtre").pe(1)
nôtre
Pro("nôtre").pe(1).n("s").g("m")
nôtre
Pro("nôtre").pe(1).n("s").g("f")
nôtres
Pro("nôtre").pe(1).n("p").g("m")
nôtres
Pro("nôtre").pe(1).n("p").g("f")
vôtre
Pro("nôtre").pe(2)
vôtre
Pro("vôtre").n("s").g("m")
vôtre
Pro("vôtre").n("s").g("f")
vôtres
Pro("vôtre").n("p").g("m")
vôtres
Pro("vôtre").n("p").g("f")
leur
Pro("nôtre").pe(3)
leur
Pro("leur").n("s").g("m")
leur
Pro("leur").n("s").g("f")
leurs
Pro("leur").n("p").g("m")
leurs
Pro("leur").n("p").g("f")

Les déterminants possessifs varient en genre et en nombre à partir de leur forme de base comme le montre le tableau suivant.

lemme masculin singulier féminin singulier masculin pluriel féminin pluriel
mon
D("mon").pe(1)
mon
D("mon").pe(1).n("s").g("m")
ma
D("mon").pe(1).n("s").g("f")
mes
D("mon").pe(1).n("p").g("m")
mes
D("mon").pe(1).n("p").g("f")
ton
D("mon").pe(2)
ton
D("ton").n("s").g("m")
ta
D("ton").n("s").g("f")
tes
D("ton").n("p").g("m")
tes
D("ton").n("p").g("f")
son
D("mon").pe(3)
son
D("son").n("s").g("m")
sa
D("son").n("s").g("f")
ses
D("son").n("p").g("m")
ses
D("son").n("p").g("f")
notre
D("notre").pe(1)
notre
D("notre").pe(1).n("s").g("m")
notre
D("notre").pe(1).n("s").g("f")
nos
D("notre").pe(1).n("p").g("m")
nos
D("notre").pe(1).n("p").g("f")
votre
D("notre").pe(2)
votre
D("votre").n("s").g("m")
votre
D("votre").n("s").g("f")
vos
D("votre").n("p").g("m")
vos
D("votre").n("p").g("f")
leur
D("notre").pe(3)
leur
D("leur").n("s").g("m")
leur
D("leur").n("s").g("f")
leurs
D("leur").n("p").g("m")
leurs
D("leur").n("p").g("f")
  • tonic form .tn(..) with parameter
    • "": for the tonic form itself
    • refl to get the reflexive form (ending with self)
  • clitic form .c(..) with options:
    • nom for the nominative
    • acc for the accusative (direct object)
    • dat for the dative (indirect object)
    • gen for the genitive (noun complement)

In order to stay compatible with the previous form of specification, when using tonic or clitic form, pe(1) must be specified for the pronoun me.

The following table shows the realized form above the corresponding pyrealb expression.

lemma tonic tonic reflexive clitic nominative clitic accusative clitic dative clitic genitive
me
Pro("me").pe(1).g("m").n("s")
me
Pro("me").tn("").pe(1)
myself
Pro("me").tn("refl").pe(1)
I
Pro("me").c("nom").pe(1)
me
Pro("me").c("acc").pe(1)
me
Pro("me").c("dat").pe(1)
mine
Pro("me").c("gen").pe(1)
us
Pro("me").pe(1).g("m").n("p")
us
Pro("us").tn("")
ourselves
Pro("us").tn("refl")
we
Pro("us").c("nom")
us
Pro("us").c("acc")
us
Pro("us").c("dat")
ours
Pro("us").c("gen")
me
Pro("me").pe(1).g("f").n("s")
her
Pro("me").tn("").g("f")
herself
Pro("me").tn("refl").g("f")
she
Pro("me").c("nom").g("f")
her
Pro("me").c("acc").g("f")
her
Pro("me").c("dat").g("f")
hers
Pro("me").c("gen").g("f")
us
Pro("me").pe(1).g("f").n("p")
us
Pro("us").tn("")
ourselves
Pro("us").tn("refl")
we
Pro("us").c("nom")
us
Pro("us").c("acc")
us
Pro("us").c("dat")
ours
Pro("us").c("gen")
you
Pro("me").pe(2).g("m").n("s")
you
Pro("you").tn("")
yourself
Pro("you").tn("refl")
you
Pro("you").c("nom")
you
Pro("you").c("acc")
you
Pro("you").c("dat")
yours
Pro("you").c("gen")
you
Pro("me").pe(2).g("m").n("p")
you
Pro("you").tn("")
yourself
Pro("you").tn("refl")
you
Pro("you").c("nom")
you
Pro("you").c("acc")
you
Pro("you").c("dat")
yours
Pro("you").c("gen")
you
Pro("me").pe(2).g("f").n("s")
you
Pro("you").tn("")
yourself
Pro("you").tn("refl")
you
Pro("you").c("nom")
you
Pro("you").c("acc")
you
Pro("you").c("dat")
yours
Pro("you").c("gen")
you
Pro("me").pe(2).g("f").n("p")
you
Pro("you").tn("")
yourself
Pro("you").tn("refl")
you
Pro("you").c("nom")
you
Pro("you").c("acc")
you
Pro("you").c("dat")
yours
Pro("you").c("gen")
him
Pro("me").pe(3).g("m").n("s")
him
Pro("him").tn("")
himself
Pro("him").tn("refl")
he
Pro("him").c("nom")
him
Pro("him").c("acc")
him
Pro("him").c("dat")
his
Pro("him").c("gen")
them
Pro("me").pe(3).g("m").n("p")
them
Pro("them").tn("")
themselves
Pro("them").tn("refl")
they
Pro("them").c("nom")
them
Pro("them").c("acc")
them
Pro("them").c("dat")
theirs
Pro("them").c("gen")
her
Pro("me").pe(3).g("f").n("s")
her
Pro("her").tn("")
herself
Pro("her").tn("refl")
she
Pro("her").c("nom")
her
Pro("her").c("acc")
her
Pro("her").c("dat")
hers
Pro("her").c("gen")
them
Pro("me").pe(3).g("f").n("p")
them
Pro("them").tn("")
themselves
Pro("them").tn("refl")
they
Pro("them").c("nom")
them
Pro("them").c("acc")
them
Pro("them").c("dat")
theirs
Pro("them").c("gen")
it
Pro("it")
it
Pro("it").tn("")
itself
Pro("it").tn("refl")
it
Pro("it").c("nom")
it
Pro("it").c("acc")
it
Pro("it").c("dat")
its
Pro("it").c("gen")

Possessive determiners are specified by giving options for the number, the person, the gender (when at the third person) and also if the owner (.ow(..)) is singular or plural. The following table shows the realization above its pyrealb specification.

Possessive determiner
my
D("my").pe(1).ow("s")
your
D("my").pe(2).ow("s")
his
D("my").pe(3).ow("s").g("m")
her
D("my").pe(3).ow("s").g("m").g("f")
its
D("my").pe(3).ow("s").g("m").g("f").g("n")
our
D("my").pe(1).ow("p")
your
D("my").pe(2).ow("p")
their
D("my").pe(3).ow("p")

Mise en forme

Formatting

Si l'ajout avant et/ou après un constituent correspond à un signe de ponctuation défini dans les règles, l'espacement approprié est ajouté avant et après le signe, sinon la chaîne est ajoutée telle quelle sans espacement.

If the content added before and/or a constituent is defined in the language rules, then the appropriate spacing is added before and after the punctuation sign, otherwise the content is added without spacing.

NomReprésentationExempleRéalisation
ajouter avant.b(…)
Ajouter un tiret avant.b("-")N("homme").b("-")-homme
Ajouter une étoile avant.b("*")N("homme").b("*")*homme
ajouter après.a(…)
Ajouter un point après.a(".")N("homme").a(".")homme.
Ajouter point d'exclamation après.a("!")N("homme").a("!")homme!
Ajouter point virgule après.a(";")N("homme").a(";")homme ;
entourer.en(…)
entourer de parenthèses.en("(")N("homme").en("(")(homme)
entourer de crochets.en("[")N("homme").en("[")[homme]
entourer d'étoiles.en("*")N("homme").en("*")*homme*
entourer de plusieurs symboles.en("*").en("(")N("homme").en("*").en("(")( *homme* )
lier par un trait d'union.lier()VP(V("lier").t("ip").pe(2).lier(),Pro("le"))lie-le
Lettres capitales.cap(…)
Mettre la première lettre en majuscule.cap()N("joueur").cap()Joueur
Majuscules de titre (ignoré en français).cap("tit")NP(N("joueur"),P("de"),N("équipe")).cap("tit")joueur d'équipe
balise HTML.tag(…)
italique souligné.tag(nom,{attributs})N("joueur").tag("i",{"style":"text-decoration:underline"})joueur
hyperlienN("joueur").tag("a",{"href":"http://www.google.com"})joueur
combinaison de balisesN("maison").tag("b").tag("i")maison
NameRepresentationExampleRealisation
add before.b(…)
Add a dash before.b("-")N("man").b("-")-man
Add a star before.b("*")N("man").b("*")*man
add after.a(…)
Add a dash before.a(".")N("man").b("-")-man
Add an exclamation point after.a("!")N("man").a("!")man!
Add a semi-colon after.a(";")N("man").a(";")man;
wrap with.en(…)
Wrap within parentheses.en("(")N("man").en("(")(man)
Wrap within brackets.en("[")N("man").en("[")[man]
Wrap within stars.en("*")N("man").en("*")*man*
Wrap within many symbols.en("*").en("(")N("man").en("*").en("(")( *man* )
Combine with a dash.lier()NP(N("mother").lier(),P("in").lier(),N("law"))mother-in-law
Capitalisation.cap(…)
Capitalize first letter.cap()N("player").cap()Player
Title capitalization.cap("tit")NP(N("player"),P("on"),D("the"),N("team")).cap("tit")Player on the Team
HTML tag.tag(…)
underline italics.tag(nom,{attributs})N("player").tag("i",{"style":"text-decoration:underline"})player
hyperlinkN("player").tag("a",{"href":"http://www.google.com"})player
combining tagsN("house").tag("b").tag("i")house

Position et pronominalization

Position and pronominalization

NomReprésentationExempleRéalisation
Placement de l'adjectif ou de l'adverbe (dépendant de la langue)
Adjectif: par défautNP(D("le"),A("petit"),N("jouet"))le petit jouet
Adjectif: par défautNP(D("le"),A("bleu"),N("jouet"))le jouet bleu
Adverbe: par défautVP(V("aller"),Adv("bien")).t("pc")est bien allé
Adjectif:pré-posé.pos("pre")NP(D("le"),A("bleu").pos("pre"),N("jouet"))le bleu jouet
Adjectif:postposé.pos("post")NP(D("le"),A("petit").pos("post"),N("jouet"))le jouet petit
Adverbe:postposé.pos("post")VP(V("aller"),Adv("bien").pos("post")).t("pc")est allé bien
Pronominalisation.pro()
du sujetS(NP(D("le"),N("joueur")).pro(),VP(V("jouer")))Il joue.
de l'objet direct surS(Pro("je").pe(1), VP(V("aimer"),NP(D("le"),N("pomme")).pro()))Je l'aime.
de l'objet indirect sur PPS(Pro("je").pe(1), VP(V("aller"), PP(P("vers"),NP(D("le"),N("maison"))).pro()))J'y vais.
NameRepresentationExampleRealisation
Adjective or adverb position (language dependent)
Adjective: by defaultNP(D("the"),A("small"),N("toy"))the small toy
Adjective: by defaultNP(D("the"),N("toy"),A("blue"))the blue toy
Adverb: by defaultVP(V("perform"),Adv("well")).typ({"perf":True})has well performed
Adverb: postpositive.pos("post")VP(V("perform"),Adv("well").pos("post")).typ({"perf":True})has performed well
Pronominalisation.pro()
of the subjectS(NP(D("the"),N("player")).pro(),VP(V("play")))She plays.
of the direct objectS(Pro("I").pe(1), VP(V("love"),NP(D("a"),N("apple").g("n")).pro()))I love it.
of the indirect objectS(Pro("I").pe(1), VP(V("go"), PP(P("to"),NP(D("a"),N("house").g("n")).pro())))I go to it.

Modification du type de phrase

Sentence type modification

Les phrases sont construites à la forme active, mais il est possible d'en modifier le type pour obtenir des phrases négatives, progressives, interrogatives ou passives. Ces modifications sont de la forme S(...).typ({...}) Il est possible de combiner plusieurs modifications en spécifiant plusieurs paires clés-valeurs dans l'objet paramètre de type. L'utilisation de contractions en anglais telles que I'll pour I will ou can't pour cannot peut aussi être spécifiée de cette manière, mais cet indicateur est ignoré en français.

Sentences are built at the active voice, but their type can be modified in order to get negative, progressive, interrogative or passive sentences. These modifications are indicated by S(...).typ({...}). Modifications can be combined by specifying multiple key value pairs in the object which is the parameter of type. The use of contractions such as I'll for I will or can't for cannot can also be specified in this way. This flag is ignored in French.

NomReprésentationExempleRéalisation
Négation.typ({"neg":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"neg":True})Le chat n'aime pas la souris.
Négation spéciale.typ({"neg":"..."})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"neg":"plus"})Le chat n'aime plus la souris.
Passif.typ({"pas":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"pas":True})La souris est aimée par le chat.
Perfect Ignoré.typ({"perf":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"perf":True})Le chat aime la souris.
Progressif.typ({"prog":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"prog":True})Le chat est en train d'aimer la souris.
Réflexif.typ({"refl":True})S(NP(D("le"),N("chat")), VP(V("laver"))).typ({"refl":True})Le chat se lave.
Exclamatif.typ({"exc":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"exc":True})Le chat aime la souris!
Pluriel de majesté.typ({"maje":True})S(Pro("moi").pe(1).g("f"),VP(V("être"),AP(A("gentil"), PP(P("avec"),NP(D("mon").pe(2),N("soeur"))))) ).typ({"maje":True})Nous sommes gentille avec votre soeur.
Pluriel de majesté, annulé localement pour D ou Pro( .maje(False) ).typ({"maje":True})S(Pro("moi").pe(1).g("f"),VP(V("être"),AP(A("gentil"), PP(P("avec"),NP(D("mon").pe(2).maje(False),N("soeur"))))) ).typ({"maje":True})Nous sommes gentille avec ta soeur.
Contraction (ignorée en français).typ({"contr":True})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ( {"neg":True,"contr":True})Le chat n'aime pas la souris.
Modalité.typ({"mod":"..."})
Possibilité.typ({"mod":"poss"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"mod":"poss"})Le chat peut aimer la souris.
Permission.typ({"mod":"perm"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"mod":"perm"})Le chat peut aimer la souris.
Nécessité.typ({"mod":"nece"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"mod":"nece"})Le chat doit aimer la souris.
Obligation.typ({"mod":"obli"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"mod":"obli"})Le chat doit aimer la souris.
Volonté.typ({"mod":"will"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"mod":"will"})Le chat veut aimer la souris.
Interrogation.typ({"int":"..."})
Interrogative (oui/non).typ({"int":"yon"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"yon"})Le chat aime-t-il la souris?
Interrogative (sujet humain?).typ({"int":"wos"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"wos"})Qui aime la souris?
Interrogative (sujet?).typ({"int":"was"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"was"})Qu'est-ce qui aime la souris?
Interrogative (qui est l'objet).typ({"int":"wod"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"wod"})Qui est-ce que le chat aime?
Interrogative (quoi est l'objet).typ({"int":"wad"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"wad"})Qu'est-ce que le chat aime?
Interrogative (à qui l'objet humain).typ({"int":"woi"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"woi"})À qui le chat aime-t-il la souris?
Interrogative (à qui l'objet).typ({"int":"wai"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"wai"})À quoi le chat aime-t-il la souris?
Interrogative (où est l'action).typ({"int":"whe"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"whe"})Où le chat aime-t-il la souris?
Interrogative (pourquoi).typ({"int":"why"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"why"})Pourquoi le chat aime-t-il la souris?
Interrogative (quand).typ({"int":"whn"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"whn"})Quand le chat aime-t-il la souris?
Interrogative (comment est l'action).typ({"int":"how"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"how"})Comment le chat aime-t-il la souris?
Interrogative (combien est l'action).typ({"int":"muc"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"muc"})Combien le chat aime-t-il la souris?
N'est-ce pas (demande confirmation).typ({"int":"tag"})S(NP(D("le"),N("chat")), VP(V("aimer"),NP(D("le"),N("souris")))).typ({"int":"tag"})Le chat aime la souris, n'est-ce pas?
NameRepresentationExampleRealisation
Negation.typ({"neg":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"neg":True})The cat does not love the mouse.
Passive.typ({"pas":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"pas":True})The mouse is loved by the cat.
Perfect.typ({"perf":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"perf":True})The cat has loved the mouse.
Progressive.typ({"prog":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"prog":True})The cat is loving the mouse.
Reflexive.typ({"refl":True})S(NP(D("the"),N("cat")), VP(V("wash"))).typ({"refl":True})The cat washes itself.
Exclamative.typ({"exc":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"exc":True})The cat loves the mouse!
Majestic plural.typ({"maje":True})S(Pro("me").pe(1).c("nom"), VP(V("love"),NP(D("my").pe(1).ow("s").maje(False),N("mouse"))) ).typ({"maje":True})We love my mouse.
Majestic plural, locally overridden for D or Pro( .maje(False) ).typ({"maje":True})S(Pro("me").pe(1).c("nom"), VP(V("love"),NP(D("my").pe(1).ow("s").maje(False),N("mouse"))) ).typ({"maje":True})We love my mouse.
Contraction.typ({"contr":True})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ( {"neg":True,"contr":True})The cat doesn't love the mouse.
Modality.typ({"mod":"..."})
Possibility.typ({"mod":"poss"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"mod":"poss"})The cat can love the mouse.
Permission.typ({"mod":"perm"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"mod":"perm"})The cat may love the mouse.
Necessity.typ({"mod":"nece"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"mod":"nece"})The cat shall love the mouse.
Obligation.typ({"mod":"obli"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"mod":"obli"})The cat must love the mouse.
Willingness.typ({"mod":"will"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"mod":"will"})The cat will love the mouse.
Interrogation.typ({"int":"..."})
Interrogative (yes/no).typ({"int":"yon"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"yon"})Does the cat love the mouse?
Interrogative (who human?).typ({"int":"wos"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"wos"})Who loves the mouse?
Interrogative (who?).typ({"int":"was"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"was"})What loves the mouse?
Interrogative (who is the object).typ({"int":"wod"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"wod"})Who does the cat love?
Interrogative (what is the object).typ({"int":"wad"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"wad"})What does the cat love?
Interrogative (to whom the object human).typ({"int":"woi"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"woi"})To whom does the cat love the mouse?
Interrogative (to whom the object).typ({"int":"wai"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"wai"})To what does the cat love the mouse?
Interrogative (where is the action).typ({"int":"whe"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"whe"})Where does the cat love the mouse?
Interrogative (why).typ({"int":"why"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"why"})Why does the cat love the mouse?
Interrogative (when).typ({"int":"whn"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"whn"})When does the cat love the mouse?
Interrogative (how is the action).typ({"int":"how"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"how"})How does the cat love the mouse?
Interrogative (how much is the action).typ({"int":"muc"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"muc"})How much does the cat love the mouse?
Question tag (confirmation?).typ({"int":"tag"})S(NP(D("the"),N("cat")), VP(V("love"),NP(D("the"),N("mouse")))).typ({"int":"tag"})The cat loves the mouse, doesn't it?

Date

Date

DT accepte en paramètre soit une date créée par une des fonctions de datetime ou une chaîne de caractères de la forme AAAA-MM-JJ hh:mm:ss. Lorsqu'appelé sans paramètre, on utilise datetime.today().

DT takes as parameter either a date créated by one of functions of datetime or a string corresponding to YYYY-MM-DD hh:mm:ss. When no parameter is given, datetime.today() is used.

Création d'une date

NomReprésentationExempleRéalisation
Date couranteDT()DT()le dimanche 9 mars 2025 à 15 h 50 min 3 s
Date passéeDT("...")DT("2014-11-21 21:00:00")le vendredi 21 novembre 2014 à 21 h
Date sans tempsDT("...")DT("2017-12-31")le dimanche 31 décembre 2017 à minuit
Date à partir de datetimeDT(datetime)DT(datetime.datetime(2014,12,31))le mercredi 31 décembre 2014 à minuit

Date creation

NameRepresentationExampleRealisation
Current dateDT()DT()on Sunday, March 9, 2025 at 3:50:03 p.m.
Date in the pastDT("...")DT("2014-11-21 21:00:00")on Friday, November 21, 2014 at 9 p.m.
Date without time DT("...")DT("2017-12-31")on Sunday, December 31, 2017 at midnight
Date from datetimeDT(datetime)DT(datetime.datetime(2014,12,31))on Wednesday, December 31, 2014 at midnight

Formatage d'une date (défaut .nat())

NomReprésentationExempleRéalisation
en lettres, par défaut.nat()DT()le dimanche 9 mars 2025 à 15 h 50 min 3 s
en chiffres.nat(False)DT().nat(False)dimanche 9/3/2025 15:50:03
Contrôle de l'affichage de chacun des éléments de la date.dOpt({"year": , "month": , "date": , "day": , "hour": , "minute": , "second": , "nat":, "det":, "rtime":})
Heure seulement.dOpt(..)DT().dOpt({"year": False, "month": False, "date": False, "day": False})à 15 h 50 min 3 s
Affichage de l'heure et des minutes (en chiffres){"nat":False}DT().dOpt({"year": False, "month": False, "date": False, "day": False, "second": False, "nat":False})15:50
Non affichage du déterminant de la date{"det":False}DT().dOpt({"det": False})dimanche 9 mars 2025 15 h 50 min 3 s
Date relative par rapport à aujourd'hui{"rtime":True}DT().dOpt({"rtime": True})aujourd'hui à 15 h 50 min 3 s
Date relative après une autre{"rtime":".." or Date}DT("2021-09-01").dOpt({"rtime": "2021-08-27", "hour":False,"minute":False,"second":False})mercredi prochain
Date relative avant une autre date{"rtime":".." or Date}DT("2021-09-01").dOpt({"rtime":datetime.datetime(2021,9,10), "hour":False,"minute":False,"second":False})il y a 9 jours

Date formatting (default .nat())

NameRepresentationExampleRealisation
as words, by default.nat()DT()on Sunday, March 9, 2025 at 3:50:03 p.m.
as digits.nat(False)DT().nat(False)Sunday 3/9/2025 15:50:03 p.m.
Control over the display of date components.dOpt({"year": , "month": , "date": , "day": , "hour": , "minute": , "second": , "nat":, "det":, "rtime":})
Time only.dOpt(..)DT().dOpt({"year": False, "month": False, "date": False, "day": False})at 3:50:03 p.m.
Display hour and minutes as digits{"nat":False}DT().dOpt({"year": False, "month": False, "date": False, "day": False, "second": False, "nat":False})3:50 p.m.
Do not display determiner{"det":False}DT().dOpt({"det": False})Sunday, March 9, 2025 3:50:03 p.m.
Relative date compared with today{"rtime":True}DT().dOpt({"rtime": True})today at 3:50:03 p.m.
Relative date after another one{"rtime":".." or Date}DT("2021-09-01").dOpt({"rtime": "2021-08-27", "hour":False,"minute":False,"second":False})Wednesday
Relative date before another one{"rtime":".." or Date}DT("2021-09-01").dOpt({"rtime":datetime.datetime(2021,9,10), "hour":False,"minute":False,"second":False})9 days ago

Nombres

Numbers

On crée un nombre avec NO(...) dont le paramètre est soit un nombre entier ou réel ou une chaîne qui peut être analysée comme un nombre.

A number is created with NO(...) whose parameter is either a number (integer or real) or a string that can be parsed as a number.

Formatage d'un nombre

NomReprésentationExempleRéalisation
arrondi{"mprecision":..}NO(1.847584).dOpt({"mprecision": 0})2
maximum 4 décimales{"mprecision":..}NO(1.847584).dOpt({"mprecision": 4})1,8476
nombre avec formattage{"raw":False}NO("1.847584").dOpt({"raw": False})1,85
nombre sans formattage{"raw":True}NO("1023.84").dOpt({"raw": True})1023.84
nombre en toutes lettres{"nat":True}NO("125").dOpt({"nat": True})cent vingt-cinq
nombre ordinal{"ord":True}NO("10").dOpt({"ord": True})dixième
nombre romain{"rom":True}NO("267").dOpt({"rom": True})CCLXVII

Number formatting

NameRepresentationExampleRealisation
rounding{"mprecision":..}NO(1.847584).dOpt({"mprecision": 0})2
4 decimal rounding{"mprecision":..}NO(1.847584).dOpt({"mprecision": 4})1.8476
number with formatting{"raw":False}NO("1.847584").dOpt({"raw": False})1.85
raw number without formatting{"raw":True}NO("1023.84").dOpt({"raw": True})1023.84
number in words{"nat":True}NO("125").dOpt({"nat": True})one hundred twenty-five
ordinal number{"ord":True}NO("10").dOpt({"ord": True})tenth
Roman number{"rom":True}NO("267").dOpt({"rom": True})CCLXVII

Accord du nom selon le nombre

NomReprésentationExempleRéalisation
avec zéroNP(NO(0), N("avion"))0 avion
avec un entierNP(NO(1), N("avion"))1 avion
avec un entierNP(NO(2), N("avion"))2 avions
avec un réelNP(NO(0.24), N("livre"))0,24 livre
avec un réelNP(NO(2.94), N("livre"))2,94 livres
avec un ordinalNP(NO(1).dOpt({"ord":True}),N("station"))première station
accord de l'adjectifNP(NO(2),A("rouge"), N("avion"))2 avions rouges

Noun agreement in number

NameRepresentationExampleRealisation
with zeroNP(NO(0), N("plane"))0 planes
with an integerNP(NO(1), N("plane"))1 plane
with an integerNP(NO(2), N("plane"))2 planes
with a realNP(NO(0.24), N("pound"))0.24 pounds
with a realNP(NO(2.94), N("pound"))2.94 pounds
with an ordinalNP(NO(1).dOpt({"ord":True}),N("station"))first station

Programmation

Programming

.add(constituent,position)

Ajout d'un nouveau constituant comme enfant à une Phrase ou Dependent existant. Le paramètre entier position est facultatif et spécifie la position (à partir de 0) dans le syntagme. Par défaut, l'élément est ajouté à la fin.

Add a pyrealb Phrase or Dependent element as a child of an existing Phrase or Dependent. The second optional parameter position is an integer that specifies its position (counting from 0). By default, the element is added as the last child.

Illustration de l'utilisation de .add(..)

NomReprésentationExempleRéalisation
déclarationpomme = NP(D("le"),N("pomme"))
déclarationgars = NP(D("le"),N("garçon"))
ajout à un syntagme videS().add(pomme)La pomme.
ajouts à un syntagme existantCP(C("et"),NP(D("le"),N("fruit"))).add(pomme).add(gars)le fruit, la pomme et le garçon
ajout avec positionS(VP().add(V("aimer")).add(pomme)).add(gars,0)Le garçon aime la pomme.

Simple example of use of .add(..)

NameRepresentationExampleRealisation
declarationapple = NP(D("the"),N("apple"))
declarationboy = NP(D("the"),N("boy"))
add to an empty phraseS().add(apple)The apple.
add to an existing phraseCP(C("and"),NP(D("a"),N("fruit"))).add(apple).add(boy)a fruit, the apple and the boy
add with positionS(VP().add(V("love")).add(apple)).add(boy,0)The boy loves the apple.

.remove(position)

Suppression du constituant à la position spécifiée en comptant à partir de 0.

Remove the constituent at the given position starting from 0.

.nbConstituents()

Retourne le nombre de constituents de la Phrase ou Dependent actuel.

Returns the number of constituents in the current Phrase or Dependent

.constituents()

Retourne la liste de constituents de la Phrase ou Dependent actuel.

Returns the list of constituents in the current Phrase or Dependent

.toSource(indent=-1)

Cette fonction retourne une version chaîne d'une expression pyrealb, ceci peut être utile pour la mise au point d'une expression complexe. En passant un nombre positif ou nul (souvent 0) comme paramètre, on obtient une expression indentée qui fait ressortir la structure de l'expression.

This function returns a string version of a pyrealb expression, this can be useful for debugging complex expressions. When a non negative number (often 0) is given as parameter, the string is indented on multiple lines to highlight the structure of the expression.

Constituent realization

Réalisation d'un Constituent

str(...)
Lancer la reéalisation d'un constituent qui dans certains cas modifie la structure d'un ou plusieurs autres constituents. Dans la majorité des cas, la réalisation est obtenue avec str( ) appelé implicitement par print(..).
.realize()
La réalisation peut aussi être lancée explicitement avec la méthode realize(). Ceci est pratique lors du déboguage dans certains environnement de programation (p.ex. Visual Studio Code ou PyCharm) qui utilisent str(..) pour afficher des valeurs internes pouvant ainsi changer la structure des constituents au cours de la mise au point, un cas typique de Heisenbug. Dans la majorité des cas, pyrealb détecte automatiquement l'exécution dans le cadre d'un environnement de mise au point Python, et change le comportement de str(..) pour qu'il retourne plutôt le source de l'expression (voir .toSource() plus haut) ce qui, à l'usage, s'est avéré être très pratique. La réalisation doit alors être obtenue en appelant .realize(). Pour obtenir ce comportement dans tous les cas, on peut utiliser cette affectation Constituent.debug=True.
+ (opérateur préfixe unaire)
L'opérateur unaire + peut être utilisé devant un Constituent pour imprimer sa réalisation; cette abréviation est surtout utile lors de tests dans une boucle real-eval-print.
str(...)
Launch the realization of a constituent which in some cases modifies the structure of one or more constituents. In the majority of cases, realization is obtained with str( ) called implicitely by print(..)
.realize()
Realization can also be launched explicitly with the realize() method. This is useful when debugging in some programming environments (e.g. Visual Studio Code or PyCharm) in which str(..) is used for displaying internal values and thus risk changing the constituents during debugging, a typical case of Heisenbug. In most cases pyrealb detects its execution within a Python debugger and changes str(..) to return the source of the constituent (see .toSource() above). Realization must then be obtained by calling .realize(). This behavior can be obtained in all cases with the following assignment Constituent.debug=True.
+ (unary prefix operator)
The unary + operator can be used in front of a Constituent to print its realization, a useful abbreviation when testing within a read-eval-print loop.

getLanguage()

Cette fonction retourne le langage courant de réalisation: "fr" pour le français et "en" pour l'anglais.

This function returns the current realization language: "fr" for French and "en" for English.

loadEn(trace), loadFr(trace), load(lang,trace)

Ces fonctions indiquent la langue à utiliser pour les prochaines réalisations. Il est important d'en appeler au mo«ins une avant de débuter la réalisation d'une phrase; lang doit être "en" ou "fr". Si le paramètre trace est true, (il est false par défaut) un message apparaîtra sur la console à la fin du chargement du lexique et de règles du langage.

These functions sets the current realization language; one of them should be called before starting the realization process; lang must be "en" or "fr". If the parameter trace is true, (it is false by default), a message is written on the console after the loading of the lexicon and language rules.

Copie d'une expression

Expression copying

Comme les options modifient un constituant pour toutes les utilisations subséquentes, il est souvent pratique de pouvoir garder la version originale pour la réutiliser et la modifier indépendamment. La façon la plus simple de créer une copie d'une expression exp est d'en faire une fonction à l'aide de lambda:exp. L'appel à cette fonction exp() crée une nouvelle instance de l'expression à chaque appel. Cette approche permet aussi de retarder l'évaluation d'une expression jusqu'au moment où on en a besoin, par exemple une fois le langage approprié a été chargé. Un autre avantage d'une fonction est le fait que l'expression peut être paramétrisée.

As options modify a constituent for all following uses, it is often convenient to keep the original expression intact in order to be able to reuse it and modify it independently. The easiest way to create a copy of expression exp is to make a function of it by adding lambda: in front of it. exp() calls the function and creates a pyrealb instance of the expression at each call. This allows to delay the evaluation of the expression until it is needed, for example once the appropriate language has been loaded. It is also possible to create parameterized expressions.

Fonctions pour la réutilisation d'expression

NomReprésentationExempleRéalisation
définition de fonctionautoF = lambda:NP(D("un"),N("auto"))
appel avec modificationautoF().n("p")des autos
appel originalautoF()une auto
fonction avec paramètrepommeF = lambda n="s": NP(D("un"),N("pomme").n(n))
appel de fonctionpommeF()une pomme
appel paramétrisépommeF("p")des pommes

Functions for expression reuse

NameRepresentationExampleRealisation
function definitioncarF = lambda:NP(D("a"),N("car"))
call with modifcationcarF().n("p")cars
original callcarF()a car
parameterized functionappleF = lambda n="s": NP(D("a"),N("apple").n(n))
function callappleF()an apple
parameterized callappleF("p")apples

Ce document (en anglais) donne plus de détails sur la modification dynamique de constituents en pyrealb.

This document gives more details on the dynamic constituent structure modification with pyrealb.

Gestion des lexiques

Lexicon Management

pyrealb intègre déjà deux lexiques assez détaillés: français (plus de 52 500 entrées) et anglais (plus de 34 200 entrées) qu'il est possible de consulter et de modifier à l'aide des fonctions suivantes. Lorsque lang ("en" ou "fr") est spécifié, la fonction s'applique au lexique de cette langue, sinon au lexique courant, celui du dernier appel à loadEn(), loadFr() ou load().
Plus d'information sur le format du lexique français.

pyrealb provides already two comprehensive lexicons: French (more than 52 500 entries) and English (more than 34 200 entries) that can be queried and modified with the following functions. When lang ("en" or "fr") is specified, the function is applied to the lexicon of this language, otherwise it applies to the current lexicon, the one of the last call to loadEn(), loadFr() or load().
More information about the English lexicon format.

addToLexicon(lemma[,newInfos][,lang])

lemma est l'entrée de base et newInfos est l'information morphologique selon le format interne à pyrealb: un objet indiquant le ou les catégories possibles et pour chaque catégorie, des propriétés et la table de déclinaison ou conjugaison correspondantes. Par exemple, addToLexicon("pyrealb",{"N":{"g":"m", "pe":3, "tab":"nI"}) ajoutera le mot pyrealb comme nom masculin invariable au lexique courant. Cette fonction peut aussi être appelée avec un seul paramètre qui est un objet dont la clé est le lemme. L'exemple précédent peut donc s'écrire: addToLexicon({"pyrealb":{"N":{"g":"m", "pe":3, "tab": "nI"}}).

lemma is the basic form and newInfos is the morphologic information according to the internal pyrealb format: an object indicating one or many possible categories. For each category, properties and declension or conjugation are given. For example, addToLexicon("pyrealb",{"N":{"g":"m", "pe":3, "tab":"nI"}) will add the pyrealb as a masculine invariable word. This function can also be called with a single parameter: an object whose key is the lemma. The previous example could also have been written: addToLexicon({"pyrealb":{"N":{"g":"m", "pe":3, "tab":"nI"}).

getLemma(lemma[,lang])

Retourner les informations du lexique correspondant à lemma.

Return lexicon information to lemma.

getLanguage()

Retourne le langage de réalisation courant.

Returns the current realization language

getLexicon()

Retourne le lexique courant.

Returns the current lexicon.

updateLexicon(newLexicon[,lang])

Fusionner les entrées de newLexicon avec le lexique spécifié. Ceci ajoutera les nouvelles entrées et remplacera les entrées existantes par celles du nouveau lexique. La fusion est effectuée au niveau des entrées, mais non des catégories.

Merge the entries of newLexicon with the specified lexicon. This adds the pyrealb entries and replaces the existing entries by the ones of the pyrealb lexicon. Merging is done at the entry level, not at the category level.

buildLemmataMap(lang)

Créer une table dans laquelle chaque clé est une des formes déclinées ou conjuguées de tous les mots du lexique de la langue spécifiée. La valeur associée à une liste d'instances de Terminal qui sont réalisées par la clé.

Cette table peut être utilisée pour de la génération inverse. Voici quelques appels suivis des résultats après ⇛

    lemmataFr = buildLemmataMap("fr")
    print(", ".join(e.toSource() for e in lemmataFr["finies"])) ⇛ A("fini").g('f').n('p'), V("finir").t('pp').g('f').n('p')
    print(", ".join(e.toSource() for e in lemmataFr["crus"] if e.isA("N"))) ⇛ N('cru').n("p")

Build a dict in which each key is an inflected form of all the entries in the lexicon of the specified language. The associated value is a list of Terminal instances that are realized by the key.

This dict can be used for inverse generation. Here are examples of calls with the result shown after ⇛

    lemmataEn = buildLemmataMap("en")
    print(", ".join(e.toSource() for e in lemmataEn["love"])) ⇛ N('love'), V('love').t("b"), V('love').pe(1), V('love').pe(2), V('love').pe(1).n("p"), V('love').pe(2).n("p"), V('love').n("p")
    print(", ".join(e.toSource() for e in lemmataEn["love"] if e.isA("N"))) ⇛ N('love')

Sélection de variantes

Variant selection

oneOf(e1,e2,...)

ei est est une valeur, choisit un ei au hasard. En pyrealb, ces éléments sont souvent des constructeurs correspondant à des structures de phrases différentes. Si e1 est un tableau alors la sélection est faite dans ce tableau, en ignorant les autres paramètres.

Pour éviter que tous les éléments soient évalués avant la sélection, il suffit de fonctionaliser l'expression en une fonction sans paramètre en la préfixant par lambda. Une fois l'élément choisi, oneOf vérifie si la valeur est une fonction et si c'est le cas, il retourne le résultat de l'appel. Par exemple, oneOf(lambda:N("amour"),lambda:N("amitié")) permet de choisir entre les deux noms sans évaluer les deux constructeurs. Dans ce cas, très simple, il aurait été aussi possible d'écrire N(oneOf("amour","amitié")).

oneOf implante le "mode:once" de RosaeNLG: une alternative est choisie au hasard, mais en essayant de ne pas répéter la précédente. Lorsque toutes les alternatives ont été utilisées, le système recommence avec les alternatives initiales, mais en évitant la dernière utilisée afin de ne pas se répéter.

where ei is a value, selects randomly a ei. In pyrealb, these elements are often constructors corresponding to different phrase structures. If e1 is an array, the selection is performed within this array, ignoring other parameters.

To avoid the evaluation of all elements before the selection, it is possible to functionalize an expression into a function with no formal parameter by prefixing it with lambda. Once the element is selected, oneOf checks if the value is a function and, if it is so, it returns the value of the called function. For exemple, oneOf(lambda:V("love"),lambda:V("like")) allows choosing between the two verbs without evaluating both constructors. In this simplistic case, this could have also been written as V(oneOf("love","like")).

oneOf implements the "mode:once" of RosaeNLG: it selects an alternative randomly, but tries not to repeat the same one. When all alternatives have been triggered, it resets but tries not run the last triggered alternative, avoiding repetitions.

choice(e1,e2,...)

Version de la fonction oneOf qui choisit une alternative sans tenir compte des choix précédents. C'est la méthode classique d'effectuer des choix aléatoires.

Version of oneOf that selects an alternative into account without taking previous choices. This is the classic implementation for making random choices.

mix(e1,e2,...)

permute ses paramètres, ce qui peut être utile pour varier l'ordre des éléments. Si e1 est un tableau alors la sélection est faite dans ce tableau, en ignorant les autres paramètres. Comme pour oneOf(...), pour éviter que tous les éléments soient évalués avant la sélection, il suffit de fonctionaliser l'expression en une fonction sans paramètre en la préfixant par lambda. Pour chaque élément de la liste, mix vérifie si sa valeur est une fonction et si c'est le cas, il le remplace par le résultat de l'appel.

shuffles its parameters, which can be useful to vary the order of elements. If e1 is an array, the selection is performed within this array, ignoring other parameters. As for oneOf(...), to avoid the evaluation of all elements before the selection, it is possible to functionalize a expression into a function with no formal parameter by prefixing it with lambda. For each element of the mixed list, mix checks if the value is a function and, if it is so, it replaces it by the value of the called function.

Traitement en JSON

JSON processing

Pour faciliter l'utilisation de pyrealb en sortie d'un système externe. Il est possible d'utiliser un format d'entrée JSON décrit dans ce document (en anglais) où sont décrites deux API permettant d'appeler un serveur node.js jsRealB depuis un autre programme Python ou Prolog. Il est également possible d"obtenir une expression JSON correspondant à une expression pyrealb.

To simplify the use of pyrealb as output of an external system, a JSON input format has been defined. It is described in this document. in which two APIs are described for calling a pyrealb node.js server from another Python or Prolog. It is also possible to obtain the JSON expression corresponding to a given pyrealb expression.

Informations sur la version

Informations about the version

pyrealb_version

Chaine de caractères indiquant le numéro de version de pyrealb, valeur actuelle: 3.2.2.

String showing the version number of pyrealb, currently: 3.2.2.

pyrealb_datecreated

Date de la création de la version courante de pyrealb valeur actuelle: 2025-03-09.

Creation date of the current pyrealb, currently 2025-03-09.

Constituent.exceptionOnWarning

Si cette variable booléenne est mise à True, une exception sera levée lors de l'émission d'un avertissement

When this boolean variable is et to True, an exception is raised when a warning is emitted.

Relation avec jsRealB

Relation with jsRealB

La version JavaScript de jsRealB en est déjà à sa 3e réécriture. Elle est le résultat de plusieurs années de développement initiées au RALI en 2015. Le choix de JavaScript avait été motivé par le fait qu'on cherchait a produire du texte dans un contexte de pages web dynamiques. Plusieurs systèmes ont ainsi été développés, comme en font foi les multiples démos. Une version node.js permet d'utiliser le réalisateur en lot, en dehors d'un navigateur pour exécuter le JavaScript.

Python étant devenu au fil des années la lingua franca du traitement de la langue, une interface Python a été développée afin d'écrire le traitement des données en Python. On crée ainsi des structures de données en utilisant la même notation que celle utilisée en JavaScript. Ces structures sont ensuite sérialisées pour être envoyées à un serveur HTTP node.js qui en retourne la réalisation.

Cette interface a permis de réaliser plusieurs systèmes, mais cette séparation en deux systèmes en complique l'installation. C'est pourquoi il a été décidé de porter le réalisateur en Python. La traduction a été faite à la main en reprenant la même structure de code avec les mêmes noms de fonctions. Seule la gestion des dates diffère grandement entre les deux versions. Cette traduction a donc forcé une relecture attentive du code JavaScript et, par le fait même, a permis de découvrir quelques erreurs et maladresses qui ont été corrigées dans la version originale.

The JavaScript version of jsRealB is already at its third rewriting. It is the result of many years of developments started at the RALI in 2015. JavaScript was chosen as implementation language because the goal was to produce text in dynamic web pages. Many such systems have been developed as is shown in the many demos. A node.js version allows the realizer to be used in batch outside of a browser to execute the JavaScript.

Python being the lingua franca for natural language processing, a Python interface has been developed so that the data processing can be done in Python. Python data structures are created using the same notation used in the JavaScript version. These structures are then serialized to a node.js HTTP server which returns the realized text.

This interface was used in many systems, but this separation into two systems complicates installation. This is why the realizer was ported to Python. The translation was done manually by keeping the same code structure and function names. Only the date implementation differs between the two versions. This translation process forced a careful review of the original JavaScript code, and by the fact, allowed the discovery of a few errors and awkwardnesses that were corrected in the original.

Informations complémentaires

More information

Contact: Guy Lapalme RALI, Université de Montréal, CANADA. 2025.

2025-03-09 15:50:03