Ce module définit la fonction conj
qui permet de générer les tableaux de conjugaison des verbes en français.
La documentation détaillée de l’utilisation de la fonction conj
est disponible sur la page du modèle {{fr-conjugaison}}.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis la page Module:conjugaisons/Documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local m_bases = require("Module:bases")
local m_params = require("Module:paramètres")
local m_table = require("Module:table")
local m_model = require("Module:conjugaisons/data-model")
local m_gen = require("Module:conjugaisons/tense-generators")
local p = {}
local GRAY_STYLE = "color: gray; font-style: italic"
--- Generate a wikicode link with a #fr anchor for the given page title.
--- @param title string The title of the page to link to.
--- @return string The link.
local function link(title)
return mw.ustring.format("]", title, title)
end
--- Create an HTML table element with a width of 100%, center-aligned text and collapsed borders.
--- @return html The table element.
local function createTable()
return mw.html.create("table")
:attr("style", "width: 100%; text-align: center; border-collapse: collapse")
end
--- Format a title.
--- @param base string The base title.
--- @param tenseOrMode VerbTense|VerbMode The verb tense/mode this title represents.
--- @return string The formatted header.
local function formatTitle(base, tenseOrMode)
local state = tenseOrMode:getStatus()
if state then
local text
if state == m_model.DISABLED then
text = "défectif"
elseif state == m_model.RARE then
text = "rare"
elseif state == m_model.UNATTESTED then
text = "inattesté"
else
error("État invalide : " .. tostring(state))
end
return base .. mw.ustring.format(" (%s)", text)
end
return base
end
--- Add an HTML TR tag to the given header.
--- @param headerRow html The parent tag.
--- @param tense VerbTense The tense this header represents.
--- @param title string The header’s title.
--- @param color string The header’s background color.
--- @param width number The header’s width in %.
--- @param colspan number Optional. The header’s "colspan", defaults to 2.
local function createTenseTableHeader(headerRow, tense, title, color, width, colspan)
local style = mw.ustring.format("width: %d%%; background-color: %s;", width, color)
if tense:isGray() then
style = style .. GRAY_STYLE
end
local element = headerRow
:tag("th")
:attr("scope", colspan > 2 and "colgroup" or "col")
:attr("style", style)
:wikitext(formatTitle(title, tense))
if colspan > 1 then
element = element:attr("colspan", tostring(colspan))
end
return element
end
--- Format the given verb form.
--- @param verbForm VerbForm The verb form to format.
--- @param asLink boolean Whether to wrap the verb form inside a link.
--- @return string The formatted verb form.
local function formatVerbForm(verbForm, asLink)
local form = verbForm:getForm()
if not form then
return "—"
end
return asLink and link(form) or form
end
--- Generate the table for all impersonal tenses for the given verb.
--- @param verb Verb A Verb object.
--- @return string The generated table.
local function generateImpersonalTable(verb)
local tableElement = createTable()
local headerRow = tableElement:tag("tr")
headerRow:tag("th")
:attr("scope", "col")
:attr("style", "width: 8%; background-color: #ffddaa")
:wikitext("]")
headerRow:tag("th")
:attr("colspan", "2")
:attr("scope", "colgroup")
:attr("style", "width: 46%; background-color: #ffeebb")
:wikitext("]")
headerRow:tag("th")
:attr("colspan", "2")
:attr("scope", "colgroup")
:attr("style", "width: 46%; background-color: #ffeebb")
:wikitext("]")
local infinitifPresent = verb.modes.tenses.forms
local infinitifPasse = verb.modes.tenses.forms
local gerondifPresent = verb.modes.tenses.forms
local gerondifPasse = verb.modes.tenses.forms
local participePresent = verb.modes.tenses.forms
local participePasse = verb.modes.tenses.forms
local infinitiveRow = tableElement:tag("tr")
infinitiveRow:tag("th")
:attr("scope", "row")
:wikitext("]")
infinitiveRow:tag("td")
:attr("style", "width: 23%; text-align: right; padding-right: 0")
:wikitext(infinitifPresent:getPronoun() or "")
infinitiveRow:tag("td")
:attr("style", "width: 23%; text-align: left; padding-left: 0")
:wikitext(formatVerbForm(infinitifPresent, true))
infinitiveRow:tag("td")
:attr("style", "width: 23%; text-align: right; padding-right: 0;" .. (infinitifPasse:isGray() and GRAY_STYLE or ""))
:wikitext(infinitifPasse:getPronoun() or "")
infinitiveRow:tag("td")
:attr("style", "width: 23%; text-align: left; padding-left: 0;" .. (infinitifPasse:isGray() and GRAY_STYLE or ""))
:wikitext(formatVerbForm(infinitifPasse))
local gerundRow = tableElement:tag("tr")
gerundRow:tag("th")
:attr("scope", "row")
:wikitext("]")
gerundRow:tag("td")
:attr("style", "text-align: right; padding-right: 0;" .. (gerondifPresent:isGray() and GRAY_STYLE or ""))
:wikitext(gerondifPresent:getPronoun() or "")
gerundRow:tag("td")
:attr("style", "text-align: left; padding-left: 0;" .. (gerondifPresent:isGray() and GRAY_STYLE or ""))
:wikitext(formatVerbForm(gerondifPresent))
gerundRow:tag("td")
:attr("style", "text-align: right; padding-right: 0;" .. (gerondifPasse:isGray() and GRAY_STYLE or ""))
:wikitext(gerondifPasse:getPronoun() or "")
gerundRow:tag("td")
:attr("style", "text-align: left; padding-left: 0;" .. (gerondifPasse:isGray() and GRAY_STYLE or ""))
:wikitext(formatVerbForm(gerondifPasse))
local participleRow = tableElement:tag("tr")
participleRow:tag("th")
:attr("scope", "row")
:wikitext("]")
participleRow:tag("td")
participleRow:tag("td")
:attr("style", "text-align: left;" .. (participePresent:isGray() and GRAY_STYLE or ""))
:wikitext(formatVerbForm(participePresent, true))
participleRow:tag("td")
participleRow:tag("td")
:attr("style", "text-align: left;" .. (participePasse:isGray() and GRAY_STYLE or ""))
:wikitext(formatVerbForm(participePasse, true))
return tostring(tableElement)
end
--- Create a table row for a single person of simple and compound tenses.
--- @param tableElement html The table to add the row to.
--- @param simpleTense VerbTense The simple tense.
--- @param compoundTense VerbTense The compound tense.
--- @param colsNb number The number of columns for each tense.
--- @param formIndex number The index of verb form to add.
local function createRow(tableElement, simpleTense, compoundTense, colsNb, formIndex)
local row = tableElement:tag("tr")
local simpleForm = simpleTense.forms
local compoundForm = compoundTense.forms
local simpleStyle = simpleForm:isGray() and GRAY_STYLE or ""
local compoundStyle = compoundForm:isGray() and GRAY_STYLE or ""
local formattedSimpleForm = simpleTense:getStatus() == m_model.DISABLED and formIndex > 1 and "" or formatVerbForm(simpleForm, true)
local formattedCompoundForm = compoundTense:getStatus() == m_model.DISABLED and formIndex > 1 and "" or formatVerbForm(compoundForm)
if colsNb == 2 then
local simplePronoun = simpleForm:getPronoun() or ""
local compoundPronoun = compoundForm:getPronoun() or ""
local reversedPronouns = simpleTense.mode.reversedPronouns
row:tag("td")
:attr("style", "width: 25%; text-align: right; padding-right: 0;" .. simpleStyle)
:wikitext(reversedPronouns and formattedSimpleForm or simplePronoun)
row:tag("td")
:attr("style", "width: 25%; text-align: left; padding-left: 0;" .. simpleStyle)
:wikitext(reversedPronouns and simplePronoun or formattedSimpleForm)
row:tag("td")
:attr("style", "width: 25%; text-align: right; padding-right: 0;" .. compoundStyle)
:wikitext(reversedPronouns and formattedCompoundForm or compoundPronoun)
row:tag("td")
:attr("style", "width: 25%; text-align: left; padding-left: 0;" .. compoundStyle)
:wikitext(reversedPronouns and compoundPronoun or formattedCompoundForm)
else
row:tag("td")
:attr("style", simpleStyle)
:wikitext(formattedSimpleForm)
row:tag("td")
:attr("style", compoundStyle)
:wikitext(formattedCompoundForm)
end
end
--- Generate the rows for the given simple tense and its corresponding compound tense.
--- @param tableElement html The table element to add the generated rows to.
--- @param verb Verb An array containing the flexions of the verb.
--- @param mode string The key of the mode.
--- @param simpleTenseName string The key of the simple tense.
--- @param title1 string Title for the simple tense.
--- @param compoundTenseName string The key of the compound tense.
--- @param title2 string Title for the compound tense.
local function generateTensesRows(tableElement, verb, mode, simpleTenseName, title1, color1, compoundTenseName, title2, color2)
local headerRow = tableElement:tag("tr")
local simpleTense = verb.modes.tenses
local compoundTense = verb.modes.tenses
local reversedPronouns = simpleTense.mode.reversedPronouns
local colsNb = reversedPronouns and not verb.spec.pronominal and 1 or 2
createTenseTableHeader(headerRow, simpleTense, title1, color1, 50, colsNb)
createTenseTableHeader(headerRow, compoundTense, title2, color2, 50, colsNb)
local simpleDef = simpleTense:getStatus() == m_model.DISABLED
local compoundDef = compoundTense:getStatus() == m_model.DISABLED
for i = 1, (simpleDef and compoundDef and 1 or #simpleTense.forms) do
local impersonal = verb.spec.impersonal
if impersonal and #simpleTense.forms == 6 then
local j = m_model.STRUCT.tenses
if j == 3 or impersonal == m_model.IMPERS and j == 6 then
createRow(tableElement, simpleTense, compoundTense, colsNb, i)
end
else
createRow(tableElement, simpleTense, compoundTense, colsNb, i)
end
end
end
--- Generate the table for the indicative tenses of the given verb.
--- @param verb Verb A Verb object.
--- @return string The generated table.
local function generateIndicativeTable(verb)
local tableElement = createTable()
generateTensesRows(tableElement, verb, "indicatif", "present", "Présent", "#ddd", "passeCompose", "Passé composé", "#ececff")
generateTensesRows(tableElement, verb, "indicatif", "imparfait", "Imparfait", "#ddd", "plusQueParfait", "Plus-que-parfait", "#ececff")
generateTensesRows(tableElement, verb, "indicatif", "passeSimple", "Passé simple", "#ddd", "passeAnterieur", "Passé antérieur", "#ececff")
generateTensesRows(tableElement, verb, "indicatif", "futur", "Futur simple", "#ddd", "futurAnterieur", "Futur antérieur", "#ececff")
return tostring(tableElement)
end
--- Generate the table for the subjunctive tenses of the given verb.
--- @param verb Verb A Verb object.
--- @return string The generated table.
local function generateSubjunctiveTable(verb)
local tableElement = createTable()
generateTensesRows(tableElement, verb, "subjonctif", "present", "Présent", "#ddd", "passe", "Passé", "#fec")
generateTensesRows(tableElement, verb, "subjonctif", "imparfait", "Imparfait", "#ddd", "plusQueParfait", "Plus-que-parfait", "#fec")
return tostring(tableElement)
end
--- Generate the table for the conditional tenses of the given verb.
--- @param verb Verb A Verb object.
--- @return string The generated table.
local function generateConditionalTable(verb)
local tableElement = createTable()
generateTensesRows(tableElement, verb, "conditionnel", "present", "Présent", "#ddd", "passe", "Passé", "#cfc")
return tostring(tableElement)
end
--- Generate the table for the imperative tenses of the given verb.
--- @param verb Verb A Verb object.
--- @return string The generated table.
local function generateImperativeTable(verb)
local tableElement = createTable()
generateTensesRows(tableElement, verb, "imperatif", "present", "Présent", "#ffe5e5", "passe", "Passé", "#ffe5e5")
return tostring(tableElement)
end
--- Format the given verb group as a link.
--- Throws an error if the group is different than 1, 2 or 3.
--- @param group number The verb group.
--- @return string The generated link.
local function formatGroup(group)
local res = "[[Conjugaison:français/"
if group == 1 then
res = res .. "Premier groupe|1<sup>er</sup>"
elseif group == 2 then
res = res .. "Deuxième groupe|2<sup>e</sup>"
elseif group == 3 then
res = res .. "Troisième groupe|3<sup>e</sup>"
else
error("Groupe invalide : " .. tostring(group))
end
return res .. " groupe]]"
end
--- Render the full page for the given verb.
--- @param verb Verb A Verb object.
--- @param group number|nil The verb’s group, either 1, 2 or 3.
--- @param templateVerb string|nil The verb the specified one is conjugated like.
--- @param num number A number to append to section IDs.
--- @return string The generated wikicode.
local function renderPage(verb, group, templateVerb, num)
local page = mw.html.create()
local idSuffix = num and ("-" .. tostring(num)) or ""
-- Links to modes sections
local small = page:tag("small")
small:wikitext(mw.ustring.format("]", idSuffix))
small:wikitext(" – ")
small:wikitext(mw.ustring.format("]", idSuffix))
small:wikitext(" – ")
small:wikitext(mw.ustring.format("]", idSuffix))
small:wikitext(" – ")
small:wikitext(mw.ustring.format("]", idSuffix))
small:wikitext(" – ")
small:wikitext(mw.ustring.format("]", idSuffix))
small:wikitext("\n\n")
local inf = verb.modes.tenses.forms
local introText = mw.ustring.format("Conjugaison de '''%s''', verbe ", link((inf:getPronoun() or "") .. inf:getForm()))
if verb.spec.pronominal then
introText = introText .. "pronominal "
end
if verb.spec.impersonal then
introText = introText .. "impersonnel "
end
if group then
introText = introText .. "du " .. formatGroup(group)
else
introText = introText .. "sans groupe"
end
introText = introText .. mw.ustring.format(
", conjugé avec l’auxiliaire %s.",
link(verb.spec.auxEtre and "être" or "avoir")
)
if group == 3 then
if templateVerb then
local templateInf = templateVerb
if mw.ustring.find(templateVerb, "-", 1, true) then
templateInf = mw.text.split(templateInf, "-", true)
templateVerb = mw.ustring.gsub(templateVerb, "%-", " (", 1) .. ")"
end
if templateInf ~= verb.modes.tenses.forms:getForm() then
-- Don’t show anything if the template is the verb itself
introText = introText .. mw.ustring.format(" Conjugué comme ].", templateInf, templateVerb)
end
else
introText = introText .. " Conjugué comme aucun autre verbe."
end
end
page:wikitext(introText)
page:tag("h3")
:tag("span")
:attr("id", "mode-impersonnel" .. idSuffix)
:wikitext("Modes impersonnels")
page:tag("div")
:attr("style", "margin: 0.5em 2em")
:wikitext(generateImpersonalTable(verb))
local mode = verb.modes
page:tag("h3")
:tag("span")
:attr("id", "mode-indicatif" .. idSuffix)
:attr("style", mode:isGray() and GRAY_STYLE or "")
:wikitext(formatTitle("Indicatif", mode))
page:tag("div")
:attr("style", "margin: 0.5em 2em")
:wikitext(generateIndicativeTable(verb))
mode = verb.modes
page:tag("h3")
:tag("span")
:attr("id", "mode-subjonctif" .. idSuffix)
:attr("style", mode:isGray() and GRAY_STYLE or "")
:wikitext(formatTitle("Subjonctif", mode))
page:tag("div")
:attr("style", "margin: 0.5em 2em")
:wikitext(generateSubjunctiveTable(verb))
mode = verb.modes
page:tag("h3")
:tag("span")
:attr("id", "mode-conditionnel" .. idSuffix)
:attr("style", mode:isGray() and GRAY_STYLE or "")
:wikitext(formatTitle("Conditionnel", mode))
page:tag("div")
:attr("style", "margin: 0.5em 2em")
:wikitext(generateConditionalTable(verb))
mode = verb.modes
page:tag("h3")
:tag("span")
:attr("id", "mode-impératif" .. idSuffix)
:attr("style", mode:isGray() and GRAY_STYLE or "")
:wikitext(formatTitle("Impératif", mode))
page:tag("div")
:attr("style", "margin: 0.5em 2em")
:wikitext(generateImperativeTable(verb))
return tostring(page)
end
local modeAbbreviations = {
part = "participe",
ind = "indicatif",
subj = "subjonctif",
cond = "conditionnel",
imp = "imperatif",
}
local tenseAbbreviations = {
pr = "present",
p = "passe",
i = "imparfait",
ps = "passeSimple",
f = "futur",
pc = "passeCompose",
pa = "passeAnterieur",
pqp = "plusQueParfait",
fa = "futurAnterieur",
}
--- Parse the arguments of the form "<mode>.<tense>" and "<mode>].état".
--- @param aspiratedH boolean Whether the initial "h" of the verb should prevent a liaison.
--- @param pronominal boolean Whether the verb is pronominal.
--- @param auxEtre boolean Whether the verb should use the verb "être" instead of "avoir" as its auxiliary.
--- @param impersonal string Whether the verb is impersonal.
--- @param args table The parsed frame arguments.
--- @return (VerbSpec, boolean) A VerbSpec object and a boolean indicating whether any form has been specified manually or any form/tense/mode has been marked as non-existent.
local function parseSpecs(aspiratedH, pronominal, auxEtre, impersonal, args)
local function personToIndex(mode, person)
if mode == "imp" then
if person == "2s" then
return 1
elseif person == "1p" then
return 2
elseif person == "2p" then
return 3
end
end
return tonumber(mw.ustring.sub(person, 1, 1))
+ (mw.ustring.sub(person, 2, 2) == "s" and 0 or 3)
end
--- @type VerbSpec
local spec = m_model.newVerbSpec(aspiratedH, pronominal, auxEtre, impersonal)
local manuallySpecified = false
for k, v in pairs(args) do
if mw.ustring.find(k, ".", 1, true) then
local parts = mw.text.split(k, ".", true)
local nb = #parts
if parts == "état" then
table.remove(parts, nb)
nb = nb - 1
local node = spec
for i, part in ipairs(parts) do
if i < nb then
if i == 1 then
node = node.modeSpecs]
else
node = node.tenseSpecs]
end
end
end
if mw.ustring.match(parts, "") then
node.formSpecs, parts)].status = v
else
if modeAbbreviations] then
node.modeSpecs]].status = v
else
node.tenseSpecs]].status = v
end
manuallySpecified = true
end
else
local node = spec
for i, part in ipairs(parts) do
if i < nb then
if i == 1 then
node = node.modeSpecs]
else
node = node.tenseSpecs]
end
end
end
if mw.ustring.match(parts, "") then
node.formSpecs, parts)].form = v
else
node.tenseSpecs]].formSpecs.form = v
end
manuallySpecified = true
end
end
end
if impersonal then
manuallySpecified = true
for modeName, mode in pairs(spec.modeSpecs) do
for tenseName, tense in pairs(mode.tenseSpecs) do
if #tense.formSpecs ~= 1 then
for i, form in ipairs(tense.formSpecs) do
local j = m_model.STRUCT.tenses
if j ~= 3 and (impersonal == m_model.IMPERS and j ~= 6 or impersonal == m_model.IMPERS_SING) then
form.status = m_model.DISABLED
end
end
end
end
end
end
return spec, manuallySpecified
end
--- Render the conjugation tables for the given verb.
--- Parameters:
--- frame.args (string): The verb in its infinitive present form.
--- frame.args (boolean): Optional. If true, use the “être” auxiliary instead of “avoir”.
--- frame.args (boolean): Optional. If true, the verb will be classified as belonging to group 3.
--- frame.args (string): Optional. The type of mutation to apply to the verb’s root instead of the default one.
--- frame.args (string): Optional. For group-3 verbs, the verb to use as a template instead of the detected one.
--- frame.args (boolean): Optional. If true, contracted pronoun forms will be used where relevant.
--- frame.args (string): Optional. If specified, the verb is considered impersonal.
--- frame.args (boolean): Optional. Whether the verb is compound.
--- frame.args (string): Optional. If "composé" is specified, the character to split the verb with. Defaults to "-".
--- frame.args (integer): Optional. A number to append to modes sections’ IDs when this function is called multiple times on the same page.
--- @return string The generated wikicode.
--- @see ] For a detailled explanation of frame arguments.
function p.conj(frame)
local templates = m_table.keysToList(m_gen.group3Templates)
table.insert(templates, "-")
local flexionStates = m_model.STATES
-- Attempt to extract the verb from the page’s title if it is in the "Conjugaison" namespace
-- and use it as the default value for argument 1.
-- Otherwise, mark the argument as required.
local title = mw.title.getCurrentTitle()
local pageNamespace = title.namespace
local pageTitle = title.text
local verbParamConfig
if pageNamespace == m_bases.NS_CONJUGAISON.id and mw.ustring.find(pageTitle, "/", 1, true) then
verbParamConfig = { default = mw.text.split(pageTitle, "/", true) }
else
verbParamConfig = { required = true }
end
local args = m_params.process(frame:getParent().args, {
= verbParamConfig,
= { type = m_params.BOOLEAN, default = false },
= { type = m_params.BOOLEAN, default = false },
= { type = m_params.BOOLEAN, default = false },
= { type = m_params.BOOLEAN, default = false },
= { enum = m_gen.mutationTypes },
= { enum = m_gen.mutationTypes },
= { enum = m_gen.mutationTypes },
= { enum = templates },
= { enum = templates },
= { enum = templates },
= { type = m_params.BOOLEAN, default = false },
= { enum = m_model.IMPERSONAL_STATES },
= { type = m_model.BOOLEAN, default = false },
= { default = "-" },
= { type = m_params.INT, checker = function(num)
return num >= 1
end },
-- Full forms and defective tenses
-- Participes
= { enum = flexionStates },
-- Participe présent
= {},
= { enum = flexionStates },
-- Participe passé
= {},
= { enum = flexionStates },
-- Indicatif
= { enum = flexionStates },
-- Indicatif présent
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif imparfait
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif passé simple
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif futur
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif passé composé
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif passé antérieur
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif plus-que-parfait
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Indicatif futur antérieur
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Subjonctif
= { enum = flexionStates },
-- Subjonctif présent
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Subjonctif imparfait
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Subjonctif passé
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Subjonctif plus-que-parfait
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Conditionnel
= { enum = flexionStates },
-- Conditionnel présent
= {},
= {},
= {},
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Conditionnel passé
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Impératif
= { enum = flexionStates },
-- Impératif présent
= {},
= {},
= {},
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
-- Impératif passé
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
= { enum = flexionStates },
})
local infinitive = args
local pronominal = false
if mw.ustring.match(infinitive, "^se ") then
pronominal = true
infinitive = mw.ustring.sub(infinitive, 4)
elseif mw.ustring.match(infinitive, "^s’") then
pronominal = true
infinitive = mw.ustring.sub(infinitive, 3)
end
local auxEtre = pronominal or args
local aspiratedH = args
local impersonal = args
local compound = args
local splitChar = args
if compound and not mw.ustring.find(infinitive, splitChar, 1, true) then
error(mw.ustring.format('Le caractère "%s" n’est pas dans "%s"', splitChar, infinitive))
end
local num = args
if aspiratedH and mw.ustring.sub(infinitive, 1, 1) ~= "h" then
error(mw.ustring.format('Le verbe "%s" ne commence pas par un "h"', infinitive))
end
-- TODO wrap errors
local spec, manuallySpecified = parseSpecs(aspiratedH, pronominal, auxEtre, impersonal, args)
local verb, group, templateVerb
if compound then
local parts = mw.text.split(infinitive, splitChar, true)
local infinitives = {}
local group3s = {}
local mutationTypes = {}
local verbTemplates = {}
for i, part in ipairs(parts) do
local index = i > 1 and "-" .. tostring(i) or ""
table.insert(infinitives, part)
table.insert(group3s, args or m_gen.NULL)
table.insert(mutationTypes, args or m_gen.NULL)
table.insert(verbTemplates, args or m_gen.NULL)
end
verb, group, templateVerb = m_gen.generateFlexions(infinitives, group3s, mutationTypes, verbTemplates, spec, splitChar)
else
verb, group, templateVerb = m_gen.generateFlexions({ infinitive }, { args }, { args }, { args }, spec)
end
if manuallySpecified then
templateVerb = nil
end
return renderPage(verb, group, templateVerb, num)
end
return p