-- Gollic verb module
local p = {}
----------------------------------------------------------------
-- ENDINGS
----------------------------------------------------------------
local endings = {
pres_part = "ne",
past_part = "er",
pres_1s = "e",
pres_2s = "et",
pres_3s = "uis",
pres_1p = "ie",
pres_2p = "ee",
pres_3p = "uise",
imperf_1s = "ois",
imperf_2s = "is",
imperf_3s = "ent",
imperf_1p = "oise",
imperf_2p = "ise",
imperf_3p = "ente",
past_1s = "ir",
past_2s = "ind",
past_3s = "it",
past_1p = "ire",
past_2p = "ind",
past_3p = "ie",
fut_1s = "an",
fut_2s = "and",
fut_3s = "ant",
fut_1p = "ance",
fut_2p = "ande",
fut_3p = "ante",
Spres_1s = "uit",
Spres_2s = "ans",
Spres_3s = "oix",
Spres_1p = "ue",
Spres_2p = "anse",
Spres_3p = "oie",
Simperf_1s = "et",
Simperf_2s = "ou",
Simperf_3s = "t",
Simperf_1p = "ue",
Simperf_2p = "ue",
Simperf_3p = "e",
IMP_2s = "s",
IMP_1p = "ue",
IMP_2p = "se"
}
----------------------------------------------------------------
-- IRREGULAR VERBS
----------------------------------------------------------------
local irregulars = {
["vuitaine"] = {
pres_part = "vine",
pres_1s = "v'ye",
pres_2s = "v'yet",
pres_3s = "vuis",
pres_2p = "v'yee",
pres_3p = "vuise",
imperf_2s = "vuis",
imperf_2p = "vuise",
past_1s = "vuir",
past_2s = "vind",
past_3s = "vuit",
past_1p = "vuire",
past_2p = "vind",
past_3p = "vuite",
fut_1s = "v'yan",
fut_2s = "v'yand",
fut_3s = "v'yant",
fut_1p = "v'yance",
fut_2p = "v'yandé",
fut_3p = "v'yante",
Spres_1s = "vuit",
Spres_2s = "v'yans",
Spres_2p = "v'yanse",
Simperf_1s = "vuit",
}
}
----------------------------------------------------------------
-- STEM
----------------------------------------------------------------
local function get_stem(title)
return mw.ustring.gsub(title, "aine$", "")
end
local function get_i_stem(stem)
if mw.ustring.match(stem, "y$") then
return mw.ustring.gsub(stem, "y$", "i")
end
return stem
end
----------------------------------------------------------------
-- DISPLAY HELPERS
----------------------------------------------------------------
local function make_cell(form, prefix)
if not form then return "—" end
if prefix then form = prefix .. " " .. form end
return "<div style='text-align:center;'>"
.. "[[Contionary:" .. form .. "|" .. form .. "]]"
.. "</div>"
end
local function make_pronoun(text)
return text
end
local function empty_cell()
return "<div style='text-align:center;'>—</div>"
end
----------------------------------------------------------------
-- COMBINE
----------------------------------------------------------------
local function combine(stem, ending)
local form = stem .. ending
----------------------------------------------------------------
-- PHONOLOGICAL RULES
----------------------------------------------------------------
-- y is deleted before i
form = mw.ustring.gsub(form, "yi", "i")
-- i becomes y after vowel and before é
form = mw.ustring.gsub(form, "([aeiou])ié", "%1yé")
-- ei and éi become oi
form = mw.ustring.gsub(form, "([e])i", "oi")
-- ts simplification
form = mw.ustring.gsub(form, "ts", "ss")
-- final ss simplification
form = mw.ustring.gsub(form, "ss$", "s")
-- final tt simplification
form = mw.ustring.gsub(form, "tt$", "t")
-- s-loss before sonorants with circumflexing
form = mw.ustring.gsub(form, "([aeiou])s([mnrt])", function(vowel, cons)
local circum = {
a = "â",
e = "ê",
i = "î",
o = "ô",
u = "û"
}
return (circum[vowel] or vowel) .. cons
end)
form = mw.ustring.gsub(form, "([âêîôû])s([mnrt])", "%1%2")
return form
end
----------------------------------------------------------------
-- MAIN FUNCTION
----------------------------------------------------------------
function p.show(frame)
local args = frame:getParent().args
local title = mw.title.getCurrentTitle().text
local stem = get_stem(title)
local i_stem = get_i_stem(stem)
local use_oi = (args.oi and args.oi ~= "" and args.oi ~= "0")
local forms = {}
for slot, ending in pairs(endings) do
if args[slot] and args[slot] ~= "" then
forms[slot] = args[slot]
elseif irregulars[title] and irregulars[title][slot] then
forms[slot] = irregulars[title][slot]
else
local currentStem = stem
-- i-stem usage
if slot == "pres_part"
or slot == "past_part"
or slot == "Simperf_3s"
or slot == "IMP_2s"
or slot == "IMP_2p"
then
currentStem = i_stem
end
-- STEM ALTERNATION
if use_oi then
local oi_slots = {
pres_1s = true,
pres_2s = true,
pres_3s = true,
imperf_3s = true,
past_1s = true,
past_2s = true,
past_3s = true,
Simperf_2s = true,
IMP_2s = true
}
if oi_slots[slot] then
currentStem = mw.ustring.gsub(currentStem, "e", "oi")
end
end
forms[slot] = combine(currentStem, ending)
end
end
----------------------------------------------------------------
-- TABLE OUTPUT
----------------------------------------------------------------
local t = {}
table.insert(t,
'{| class="wikitable mw-collapsible mw-collapsed"\n'
.. '|+ Conjugation of [[Contionary:' .. title .. '|' .. title .. ']]\n'
)
table.insert(t,
'|-\n'
.. '! colspan="5" style="background:#ebe8b9;" | Infinitive\n'
.. '| colspan="3" | ' .. make_cell(title) .. '\n'
)
table.insert(t,
'|-\n'
.. '! colspan="5" style="background:#ebe8b9;" | Present Participle\n'
.. '| colspan="3" | ' .. make_cell(forms.pres_part or "—") .. '\n'
)
table.insert(t,
'|-\n'
.. '! colspan="5" style="background:#ebe8b9;" | Past Participle\n'
.. '| colspan="3" | ' .. make_cell(forms.past_part or "—") .. '\n'
)
table.insert(t,
'|-\n'
.. '! colspan="2" rowspan="2" style="background:#cfcfcf;" | !! colspan="3" style="background:#cfcfcf;" | Singular !! colspan="3" style="background:#cfcfcf;" | Plural\n'
)
table.insert(t,
'|-\n'
.. '! style="background:#cfcfcf;" | 1st !! style="background:#cfcfcf;" | 2nd !! style="background:#cfcfcf;" | 3rd !! style="background:#cfcfcf;" | 1st !! style="background:#cfcfcf;" | 2nd !! style="background:#cfcfcf;" | 3rd\n'
)
table.insert(t,
'|-\n'
.. '! rowspan="5" style="background:#bbd0fa;" | Indicative\n'
.. '! \n'
.. '! ' .. make_pronoun("vie")
.. ' !! ' .. make_pronoun("tife")
.. ' !! ' .. make_pronoun("vois/liv/ceu")
.. ' !! ' .. make_pronoun("vie")
.. ' !! ' .. make_pronoun("tifee")
.. ' !! ' .. make_pronoun("voise")
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Present\n'
.. '| ' .. make_cell(forms.pres_1s)
.. ' || ' .. make_cell(forms.pres_2s)
.. ' || ' .. make_cell(forms.pres_3s)
.. ' || ' .. make_cell(forms.pres_1p)
.. ' || ' .. make_cell(forms.pres_2p)
.. ' || ' .. make_cell(forms.pres_3p)
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Imperfect\n'
.. '| ' .. make_cell(forms.imperf_1s)
.. ' || ' .. make_cell(forms.imperf_2s)
.. ' || ' .. make_cell(forms.imperf_3s)
.. ' || ' .. make_cell(forms.imperf_1p)
.. ' || ' .. make_cell(forms.imperf_2p)
.. ' || ' .. make_cell(forms.imperf_3p)
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Past\n'
.. '| ' .. make_cell(forms.past_1s)
.. ' || ' .. make_cell(forms.past_2s)
.. ' || ' .. make_cell(forms.past_3s)
.. ' || ' .. make_cell(forms.past_1p)
.. ' || ' .. make_cell(forms.past_2p)
.. ' || ' .. make_cell(forms.past_3p)
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Future\n'
.. '| ' .. make_cell(forms.fut_1s)
.. ' || ' .. make_cell(forms.fut_2s)
.. ' || ' .. make_cell(forms.fut_3s)
.. ' || ' .. make_cell(forms.fut_1p)
.. ' || ' .. make_cell(forms.fut_2p)
.. ' || ' .. make_cell(forms.fut_3p)
.. '\n'
.. '|-\n'
.. '| colspan="8" style="background:#cfcfcf; height:6px; padding:0;" | \n'
)
table.insert(t,
'|-\n'
.. '! rowspan="3" style="background:#b3da9d;" | Subjunctive\n'
.. '! \n'
.. '! ' .. make_pronoun("vie")
.. ' !! ' .. make_pronoun("tife")
.. ' !! ' .. make_pronoun("vois/liv/ceu")
.. ' !! ' .. make_pronoun("vie")
.. ' !! ' .. make_pronoun("tifee")
.. ' !! ' .. make_pronoun("voise")
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Present\n'
.. '| ' .. make_cell(forms.Spres_1s)
.. ' || ' .. make_cell(forms.Spres_2s)
.. ' || ' .. make_cell(forms.Spres_3s)
.. ' || ' .. make_cell(forms.Spres_1p)
.. ' || ' .. make_cell(forms.Spres_2p)
.. ' || ' .. make_cell(forms.Spres_3p)
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Imperfect\n'
.. '| ' .. make_cell(forms.Simperf_1s)
.. ' || ' .. make_cell(forms.Simperf_2s)
.. ' || ' .. make_cell(forms.Simperf_3s)
.. ' || ' .. make_cell(forms.Simperf_1p)
.. ' || ' .. make_cell(forms.Simperf_2p)
.. ' || ' .. make_cell(forms.Simperf_3p)
.. '\n'
.. '|-\n'
.. '| colspan="8" style="background:#cfcfcf; height:6px; padding:0;" | \n'
)
table.insert(t,
'|-\n'
.. '! rowspan="3" style="background:#e8cc8f;" | Imperative\n'
.. '! \n'
.. '! —'
.. ' !! ' .. make_pronoun("tife")
.. ' !! —'
.. ' !! ' .. make_pronoun("vie")
.. ' !! ' .. make_pronoun("tifee")
.. ' !! —'
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Affirmative\n'
.. '| ' .. empty_cell()
.. ' || ' .. make_cell(forms.IMP_2s)
.. ' || ' .. empty_cell()
.. ' || ' .. make_cell(forms.IMP_1p)
.. ' || ' .. make_cell(forms.IMP_2p)
.. ' || ' .. empty_cell()
.. '\n'
)
table.insert(t,
'|-\n'
.. '! Negative\n'
.. '| ' .. empty_cell()
.. ' || ' .. make_cell(forms.IMP_2s, "ne")
.. ' || ' .. empty_cell()
.. ' || ' .. make_cell(forms.IMP_1p, "ne")
.. ' || ' .. make_cell(forms.IMP_2p, "ne")
.. ' || ' .. empty_cell()
.. '\n'
)
table.insert(t, '|}')
return table.concat(t)
end
return p