Module:da-adj
Apparence
La documentation pour ce module peut être créée à Module:da-adj/Documentation
local bases = require('Module:bases')
local p = {}
function p.getWikitext(frame)
-- Reçoit l'appel du modèle
local args = frame:getParent().args
local title = mw.title.getCurrentTitle()
local pagename = args["mot"] or args[1] or title.text
local forms = p.getForms(pagename, args)
if args.noncomp then
return p.getTable(pagename, forms, args)
end
return p.getTableComp(pagename, forms, args)
end
function p.getForms(pagename, args)
local last_1 = mw.ustring.sub(pagename, -1, -1)
local last_2 = mw.ustring.sub(pagename, -2, -1)
local last_4 = mw.ustring.sub(pagename, -4, -1)
local without_last_1 = mw.ustring.sub(pagename, 1, -2)
local without_last_2 = mw.ustring.sub(pagename, 1, -3)
local without_last_3 = mw.ustring.sub(pagename, 1, -4)
local ends_with_vowel_d = not not mw.ustring.find(last_2, "[aoueiyæøå]d")
local ends_with_consonant_d = not not mw.ustring.find(last_2, "[bcdfghjklmnpqrstvwxz]d")
local ends_with_vowel = not not mw.ustring.find(last_1, "[aoueiyæøå]")
local plural = nil
local neuter = pagename .. "t"
-- Paramètre 'alt'
if args['alt'] or args['e'] then
if last_1 == "m" then -- équivaut à args['raj'] = ""
args['rac'] = pagename
elseif last_1 == "t" then
neuter = pagename
elseif last_4 == "mmen" or last_4 == "nnen" or last_4 == "mmal" then
neuter = last_1 == "n" and without_last_1 .. "t" or neuter
args['rac'] = without_last_3 .. last_1
elseif last_2 == "el" or last_2 == "en" or last_2 == "er" then
neuter = last_1 == "n" and without_last_1 .. "t" or neuter
args['rac'] = without_last_2 .. last_1
elseif last_2 == "dd" then
neuter = without_last_2 .. "tt"
elseif last_2 == "ad" or args['e'] then
neuter = without_last_1 .. "t"
plural = pagename .. "e"
elseif last_2 == "nn" or ends_with_consonant_d then
neuter = without_last_1 .. "t"
end
end
-- Déclinaison régulière
local common = pagename
local masc = (args['rac'] or pagename) .. "e"
local comp = (args['rac'] or pagename) .. "ere"
local attr_sup = (args['rac'] or pagename) .. "este"
local attr_sup_masc = (args['rac'] or pagename) .. "este"
local pred_sup = (args['rac'] or pagename) .. "est"
plural = plural or (args['rac'] or pagename) .. "e"
--
if args['raj'] then
masc = pagename .. args['raj'] .. "e"
plural = pagename .. args['raj'] .. "e"
comp = pagename .. args['raj'] .. "ere"
attr_sup = pagename .. args['raj'] .. "este"
attr_sup_masc = pagename .. args['raj'] .. "este"
pred_sup = pagename .. args['raj'] .. "est"
end
if args['rac-comp'] or args['rac-sup'] then
comp = (args['rac-comp'] .. "re") or comp
attr_sup = (args['rac-sup'] or args['rac-comp']) .. "ste"
attr_sup_masc = (args['rac-sup'] or args['rac-comp']) .. "ste"
pred_sup = (args['rac-sup'] or args['rac-comp']) .. "st"
end
if ends_with_vowel then
neuter = pagename .. "tt"
end
local forms = {}
forms.sing_indef_comm_pos = args[1] or common
forms.sing_indef_neut_pos = args[2] or args['n'] or args['neutre'] or neuter
forms.sing_def_masc_pos = args[3] or args['masc'] or masc
forms.sing_def_aut_pos = args[4] or plural
forms.plur_pos = args[5] or args['pl'] or plural
forms.comp = args['noncomp'] and '' or args[6] or comp
forms.sup_attr_masc = args['noncomp'] and '' or args[7] or attr_sup_masc
forms.sup_attr = args['noncomp'] and '' or args[8] or attr_sup
forms.sup_pred = args['noncomp'] and '' or args[9] or pred_sup
return forms
end
function p.getTableComp(pagename, forms, args)
local m = ''
if args.masc == '' then
m = "—\n| —"
else
m = bases.lien_modele(forms.sing_def_masc_pos, 'da') .. "\n"..
"| " .. bases.lien_modele(forms.sup_attr_masc, 'da')
end
-- Construction du code wikitext du tableau
local txt = '{| class="flextable"\n'..
'! class="invisible" |\n'..
'|-\n'..
"! rowspan=2 colspan=3 |''Déclinaison de " .. pagename .. "''\n"..
"! rowspan=2| Positif\n"..
"! rowspan=2| Comparatif\n"..
"! colspan=2| Superlatif\n"..
"|-\n"..
"! Attributif\n"..
"! Prédicatif\n"..
"|-\n"..
"! rowspan=4| Singulier\n"..
"! rowspan=2| Indéfini\n"..
"! Commun\n"..
"| " .. bases.lien_modele(pagename, 'da') .. "\n"..
"| rowspan=5| " .. bases.lien_modele(forms.comp, 'da') .. "\n"..
"| rowspan=2| —\n"..
"| rowspan=2| " .. bases.lien_modele(forms.sup_pred, 'da') .. "\n"..
"|-\n"..
"! Neutre\n"..
"| " .. bases.lien_modele(forms.sing_indef_neut_pos, 'da') .. "\n"..
"|-\n"..
"! rowspan=2| Défini\n"..
"! Commun\n"..
"| " .. m .. "\n"..
"| rowspan=2| —\n"..
"|-\n"..
"! Neutre\n"..
"| " .. bases.lien_modele(forms.sing_def_aut_pos, 'da') .. "\n"..
"| " .. bases.lien_modele(forms.sup_attr, 'da') .. "\n"..
"|-\n"..
"! colspan=3| Pluriel\n"..
"| " .. bases.lien_modele(forms.plur_pos, 'da') .. "\n"..
"| " .. bases.lien_modele(forms.sup_attr, 'da') .. "\n"..
"| " .. bases.lien_modele(forms.sup_pred, 'da') .. "\n"..
"|}\n"
return txt
end
function p.getTable(pagename, forms, args)
local m = ''
if args.masc == '' then
m = "—"
else
m = bases.lien_modele(forms.sing_def_masc_pos, 'da')
end
-- Construction du code wikitext du tableau
local txt = '{| class="flextable"\n'..
'! class="invisible" |\n'..
'|-\n'..
"! colspan=3 |''Déclinaison de " .. pagename .. "''\n"..
"! Positif\n"..
"|-\n"..
"! rowspan=4| Singulier\n"..
"! rowspan=2| Indéfini\n"..
"! Commun\n"..
"| " .. bases.lien_modele(pagename, 'da') .. "\n"..
"|-\n"..
"! Neutre\n"..
"| " .. bases.lien_modele(forms.sing_indef_neut_pos, 'da') .. "\n"..
"|-\n"..
"! rowspan=2| Défini\n"..
"! Commun\n"..
"| " .. m .. "\n"..
"|-\n"..
"! Neutre\n"..
"| " .. bases.lien_modele(forms.sing_def_aut_pos, 'da') .. "\n"..
"|-\n"..
"! colspan=3| Pluriel\n"..
"| " .. bases.lien_modele(forms.plur_pos, 'da') .. "\n"..
"|}[[Catégorie:Adjectifs incomparables en danois]]\n"
return txt
end
return p