local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local export = {}
local lang = require("Module:languages").getByCode("fi")
-- Functions that do the actual inflecting by creating the forms of a basic term.
local inflections = {}
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local infl_type = frame.args or error("Inflection type has not been specified. Please pass parameter 1 to the module invocation")
local args = frame:getParent().args
if not inflections then
error("Unknown inflection type '" .. infl_type .. "'")
end
local data = {forms = {}, title = nil, categories = {}}
-- Generate the forms
inflections(args, data)
-- Postprocess
postprocess(args, data)
if args then
table.insert(data.categories, "fi-decl with nocheck")
end
if args then
table.insert(data.categories, "fi-decl with nosg")
end
if args then
table.insert(data.categories, "fi-decl with nopl")
end
if args then
table.insert(data.categories, "fi-decl with type")
end
return make_table(data) .. m_utilities.format_categories(data.categories, lang)
.. require("Module:TemplateStyles")("Module:fi-nominals/style.css")
end
function get_params(args, num, invert_grades)
local params = {}
if num == 5 then
params.base = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{1}}}"); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end
params.strong = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}"); if not params.strong then error("Parameter 2 (nominative grade) may not be omitted.") end
params.weak = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}"); if not params.weak then error("Parameter 3 (genitive grade) may not be omitted.") end
params.final = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{4}}}"); if not params.final or params.final == "" then error("Parameter 4 (final letter(s)) may not be empty.") end
params.a = args or (mw.title.getCurrentTitle().nsText == "Template" and "a"); if params.a ~= "a" and params.a ~= "ä" then error("Parameter 5 must be \"a\" or \"ä\".") end
elseif num == 4 then
params.base = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{1}}}"); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end
params.strong = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{2}}}"); if not params.strong then error("Parameter 2 (nominative grade) may not be omitted.") end
params.weak = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{3}}}"); if not params.weak then error("Parameter 3 (genitive grade) may not be omitted.") end
params.a = args or (mw.title.getCurrentTitle().nsText == "Template" and "a"); if params.a ~= "a" and params.a ~= "ä" then error("Parameter 4 must be \"a\" or \"ä\".") end
elseif num == 2 then
params.base = args or (mw.title.getCurrentTitle().nsText == "Template" and "{{{1}}}"); if not params.base or params.base == "" then error("Parameter 1 (base stem) may not be empty.") end
params.a = args or (mw.title.getCurrentTitle().nsText == "Template" and "a"); if params.a ~= "a" and params.a ~= "ä" then error("Parameter 2 must be \"a\" or \"ä\".") end
elseif num == 1 then
params.base = args or ""
end
-- Swap the grades
if invert_grades then
params.strong, params.weak = params.weak, params.strong
end
if params.a then
params.o = params.a == "ä" and "ö" or "o"
params.u = params.a == "ä" and "y" or "u"
end
return params
end
local make_weak = require("Module:fi-utilities").make_weak
--[=[
Inflection functions
]=]--
local stem_endings = {}
stem_endings = {
= "",
}
stem_endings = {
= "na",
}
stem_endings = {
= "n",
= "ssa",
= "sta",
= "lla",
= "lta",
= "lle",
= "ksi",
= "n",
= "tta",
= "t",
}
stem_endings = {
= "a",
}
stem_endings = {
= "Vn",
}
stem_endings = {
= "na",
= "ne",
}
stem_endings = {
= "ssa",
= "sta",
= "lla",
= "lta",
= "lle",
= "ksi",
= "n",
= "tta",
}
stem_endings = {
= "a",
}
stem_endings = {
= "en",
}
stem_endings = {
= "Vn",
}
-- Make a copy of the endings, with front vowels
stem_endings = { = stem_endings, = mw.clone(stem_endings)}
for stem_key, endings in pairs(stem_endings) do
for key, ending in pairs(endings) do
endings = mw.ustring.gsub(endings, "()", { = "ä", = "ö", = "y"})
end
end
-- Create any stems that were not given
local function make_stems(data, stems)
if not stems and stems then
stems = mw.clone(stems)
end
if not stems and stems then
stems = mw.clone(stems)
end
if not stems and stems then
stems = {}
for _, stem in ipairs(stems) do
-- If the stem ends in a long vowel or diphthong, then add -h
if mw.ustring.find(stem, "()%1$") or mw.ustring.find(stem, "$") then
table.insert(stems, stem .. "h")
else
table.insert(stems, stem)
end
end
end
if not stems and stems then
stems = {}
for _, stem in ipairs(stems) do
table.insert(stems, stem)
end
end
if not stems and stems then
stems = {}
for _, stem in ipairs(stems) do
-- If the partitive plural stem ends in -it, then replace the t with d or tt
if mw.ustring.find(stem, "it$") then
table.insert(stems, (mw.ustring.gsub(stem, "t$", "d")))
table.insert(stems, stem .. "t")
else
table.insert(stems, stem)
end
end
end
if not stems and stems then
stems = {}
for _, stem in ipairs(stems) do
table.insert(stems, stem)
end
end
end
-- Create forms based on each stem, by adding endings to it
local function process_stems(data, stems, vh)
if not stems and stems then
stems = mw.clone(stems)
end
if not stems and stems then
stems = mw.clone(stems)
end
-- Go through each of the stems given
for stem_key, substems in pairs(stems) do
for _, stem in ipairs(substems) do
-- Attach the endings to the stem
for form_key, ending in pairs(stem_endings) do
if not data.forms then
data.forms = {}
end
-- "V" is a copy of the last vowel in the stem
if mw.ustring.find(ending, "V") then
local vowel = mw.ustring.match(stem, "()*$")
ending = mw.ustring.gsub(ending, "V", vowel or "?")
end
table.insert(data.forms, stem .. ending)
end
end
end
data = stems
end
inflections = function(args, data)
data.title = "] type 1/]"
table.insert(data.categories, "Finnish valo-type nominals")
local params = get_params(args, 5)
make_weak(params.base, params.strong, params.final, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local wk_sg = params.weak
local wk_pl = params.weak
if mw.ustring.sub(params.base, -1) == params.final then
if wk_sg == "" and (mw.ustring.find(params.base, "$") or mw.ustring.find(params.base, "$")) then
wk_sg = "’"
end
if wk_pl == "" then
wk_pl = "’"
end
end
local stems = {}
stems = {params.base .. params.strong .. params.final}
stems = {params.base .. wk_sg .. params.final}
stems = {params.base .. params.strong .. params.final .. "i"}
stems = {params.base .. wk_pl .. params.final .. "i"}
stems = {params.base .. params.strong .. params.final .. "j"}
stems = {params.base .. params.strong .. params.final .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 2/], no gradation"
table.insert(data.categories, "Finnish palvelu-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base}
stems = {params.base .. "i"}
stems = {params.base .. "j", params.base .. "it"}
stems = {params.base .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 3/], no gradation"
table.insert(data.categories, "Finnish valtio-type nominals")
local params = get_params(args, 2)
local final = mw.ustring.sub(params.base, -1)
local stems = {}
stems = {params.base}
stems = {params.base .. "t"}
stems = {params.base .. "i"}
stems = {params.base .. "it"}
stems = {params.base .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 4/]"
table.insert(data.categories, "Finnish laatikko-type nominals")
local params = get_params(args, 5, false, "kk", "k", "o")
make_weak(params.base, params.strong, params.final, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.strong .. params.final}
stems = {params.base .. params.weak .. params.final}
stems = {params.base .. params.strong .. params.final .. "i"}
stems = {params.base .. params.weak .. params.final .. "i"}
stems = {params.base .. params.strong .. params.final .. "j", params.base .. params.weak .. params.final .. "it"}
stems = {params.base .. params.strong .. params.final .. "ih", params.base .. params.weak .. params.final .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 5/]"
table.insert(data.categories, "Finnish risti-type nominals")
local params = get_params(args, 4)
local i = args; if i == "0" then i = "" else i = "i" end
make_weak(params.base, params.strong, "i", params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.strong .. i}
stems = {params.base .. params.strong .. "i"}
stems = {params.base .. params.weak .. "i"}
stems = {params.base .. params.strong .. "ei"}
stems = {params.base .. params.weak .. "ei"}
stems = {params.base .. params.strong .. "i"}
stems = {params.base .. params.strong .. "ej"}
stems = {params.base .. params.strong .. "eih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 6/], no gradation"
table.insert(data.categories, "Finnish paperi-type nominals")
local params = get_params(args, 2)
local i = args; if i == "0" then i = "" else i = "i" end
local stems = {}
stems = {params.base .. i}
stems = {params.base .. "i"}
stems = {params.base .. "ei"}
stems = {params.base .. "eit", params.base .. "ej"}
stems = {params.base .. "i", params.base .. "eid", params.base .. "eitt"}
stems = {params.base .. "eih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 7/]"
table.insert(data.categories, "Finnish ovi-type nominals")
local params = get_params(args, 4)
local nom_sg = args; if nom_sg == "" then nom_sg = nil end
make_weak(params.base, params.strong, "e", params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {nom_sg or params.base .. params.strong .. "i"}
stems = {params.base .. params.strong .. "e"}
stems = {params.base .. params.weak .. "e"}
stems = {params.base .. params.strong .. "i"}
stems = {params.base .. params.weak .. "i"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 8/]"
table.insert(data.categories, "Finnish nalle-type nominals")
local params = get_params(args, 4)
make_weak(params.base, params.strong, "e", params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.strong .. "e"}
stems = {params.base .. params.weak .. "e"}
stems = {params.base .. params.strong .. "ei"}
stems = {params.base .. params.weak .. "ei"}
stems = {params.base .. params.strong .. "ej"}
stems = {params.base .. params.strong .. "eih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.strong .. "ein"}
end
inflections = function(args, data)
data.title = "] type 9/]"
table.insert(data.categories, "Finnish kala-type nominals")
local params = get_params(args, 4)
make_weak(params.base, params.strong, params.a, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local wk_sg = params.weak
if wk_sg == "" and mw.ustring.sub(params.base, -2) == params.a .. params.a then
wk_sg = "’"
end
local stems = {}
stems = {params.base .. params.strong .. params.a}
stems = {params.base .. wk_sg .. params.a}
stems = {params.base .. params.strong .. params.o .. "i"}
stems = {params.base .. params.weak .. params.o .. "i"}
stems = {params.base .. params.strong .. params.o .. "j"}
stems = {params.base .. params.strong .. params.o .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.strong .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 10/]"
table.insert(data.categories, "Finnish koira-type nominals")
local params = get_params(args, 4)
local nom_sg = args; if nom_sg == "" then nom_sg = nil end
make_weak(params.base, params.strong, params.a, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local wk_sg = params.weak
local wk_pl = params.weak
if wk_sg == "" and mw.ustring.sub(params.base, -2) == params.a .. params.a then
wk_sg = "’"
end
if wk_pl == "" and mw.ustring.sub(params.base, -1) == "i" then
wk_pl = "’"
end
local stems = {}
stems = {nom_sg or params.base .. params.strong .. params.a}
stems = {params.base .. params.strong .. params.a}
stems = {params.base .. wk_sg .. params.a}
stems = {params.base .. params.strong .. "i"}
stems = {params.base .. wk_pl .. "i"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.strong .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 11/], no gradation"
table.insert(data.categories, "Finnish omena-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. params.a}
stems = {params.base .. params.o .. "i", params.base .. "i"}
stems = {params.base .. "i", params.base .. params.o .. "it"}
stems = {params.base .. "i", params.base .. params.o .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.o .. "jen", params.base .. params.a .. "in"}
data.forms.rare = {params.base .. params.o .. "j" .. params.a}
end
inflections = function(args, data)
data.title = "] type 12/], no gradation"
table.insert(data.categories, "Finnish kulkija-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. params.a}
stems = {params.base .. params.o .. "i"}
stems = {params.base .. params.o .. "it"}
stems = {params.base .. params.o .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 13/], no gradation"
table.insert(data.categories, "Finnish katiska-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. params.a}
stems = {params.base .. params.o .. "i"}
stems = {params.base .. params.o .. "it", params.base .. params.o .. "j"}
stems = {params.base .. params.o .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 14/]"
table.insert(data.categories, "Finnish solakka-type nominals")
local params = get_params(args, 4)
make_weak(params.base, params.strong, params.a, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.strong .. params.a}
stems = {params.base .. params.weak .. params.a}
stems = {params.base .. params.strong .. params.o .. "i"}
stems = {params.base .. params.weak .. params.o .. "i"}
stems = {params.base .. params.weak .. params.o .. "it", params.base .. params.strong .. params.o .. "j"}
stems = {params.base .. params.weak .. params.o .. "ih", params.base .. params.strong .. params.o .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.strong .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 15/], no gradation"
table.insert(data.categories, "Finnish korkea-type nominals")
local params = get_params(args, 2)
local final = mw.ustring.sub(params.base, -1)
local stems = {}
stems = {params.base .. params.a}
stems = {params.base .. params.a, params.base .. params.a .. "t"}
stems = {params.base .. "i"}
stems = {params.base .. "it"}
stems = {params.base .. "isi", params.base .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 16/], ''mp-mm'' gradation"
table.insert(data.categories, "Finnish vanhempi-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "mpi"}
stems = {params.base .. "mp" .. params.a}
stems = {params.base .. "mm" .. params.a}
stems = {params.base .. "mpi"}
stems = {params.base .. "mmi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "mp" .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 17/], no gradation"
table.insert(data.categories, "Finnish vapaa-type nominals")
local params = get_params(args, 2)
local final = mw.ustring.sub(params.base, -1)
local stems = {}
stems = {params.base .. final}
stems = {params.base .. final .. "t"}
stems = {params.base .. final .. "se"}
stems = {params.base .. "i"}
stems = {params.base .. "it"}
stems = {params.base .. "isi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "ihin"}
end
inflections = function(args, data)
data.title = "] type 18/], no gradation"
table.insert(data.categories, "Finnish maa-type nominals")
local params = get_params(args, 2)
local nom_sg = args; if nom_sg == "" then nom_sg = nil end
local pl_stem = mw.ustring.sub(params.base, 1, -2)
local stems = {}
stems = {nom_sg or params.base}
stems = {params.base}
stems = {params.base .. "t"}
stems = {pl_stem .. "i"}
stems = {pl_stem .. "it"}
stems = {pl_stem .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 19/], no gradation"
table.insert(data.categories, "Finnish suo-type nominals")
local params = get_params(args, 2)
local final = mw.ustring.sub(params.base, -1)
local plural = mw.ustring.sub(params.base, 1, -3) .. final
local stems = {}
stems = {params.base}
stems = {params.base .. "t"}
stems = {params.base .. "h"}
stems = {plural .. "i"}
stems = {plural .. "it"}
stems = {plural .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 20/], no gradation"
table.insert(data.categories, "Finnish filee-type nominals")
local params = get_params(args, 2)
local pl_stem = mw.ustring.sub(params.base, 1, -2)
local stems = {}
stems = {params.base}
stems = {params.base .. "t"}
stems = {params.base .. "h", params.base .. "se"}
stems = {pl_stem .. "i"}
stems = {pl_stem .. "it"}
stems = {pl_stem .. "ih", pl_stem .. "isi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 21/], no gradation"
table.insert(data.categories, "Finnish rosé-type nominals")
local params = get_params(args, 2)
local ill_sg_vowel = args; if ill_sg_vowel == "" then error("Parameter \"ill_sg_vowel=\" cannot be empty.") end
local ill_sg_vowel2 = args; if ill_sg_vowel2 == "" then error("Parameter \"ill_sg_vowel2=\" cannot be empty.") end
local stems = {}
stems = {params.base}
stems = {params.base .. "t"}
stems = {params.base .. "h"}
stems = {params.base .. "i"}
stems = {params.base .. "it"}
stems = {params.base .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
if ill_sg_vowel then
data.forms = {params.base .. "h" .. ill_sg_vowel .. "n"}
end
if ill_sg_vowel2 then
table.insert(data.forms, params.base .. "h" .. ill_sg_vowel2 .. "n")
end
end
inflections = function(args, data)
data.title = "] type 22/], no gradation"
table.insert(data.categories, "Finnish parfait-type nominals")
local params = get_params(args, 2)
local ill_sg_vowel = args or (mw.title.getCurrentTitle().nsText == "Template" and "e"); if not ill_sg_vowel or ill_sg_vowel == "" then error("Parameter \"ill_sg_vowel=\" is missing.") end
local ill_sg_vowel2 = args; if ill_sg_vowel2 == "" then error("Parameter \"ill_sg_vowel2=\" cannot be empty.") end
local stems = {}
stems = {params.base}
stems = {params.base .. "’"}
stems = {params.base .. "’t"}
stems = {params.base .. "’i"}
stems = {params.base .. "’it"}
stems = {params.base .. "’ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms = {params.base .. "’h" .. ill_sg_vowel .. "n"}
if ill_sg_vowel2 then
table.insert(data.forms, params.base .. "h" .. ill_sg_vowel2 .. "n")
end
end
inflections = function(args, data)
data.title = "] type 23/], no gradation"
table.insert(data.categories, "Finnish tiili-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "i"}
stems = {params.base .. "e"}
stems = {params.base .. "t"}
stems = {params.base .. "i"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 24/], no gradation"
table.insert(data.categories, "Finnish uni-type nominals")
local params = get_params(args, 2)
local par_sg_a = args; if par_sg_a and par_sg_a ~= "a" and par_sg_a ~= "ä" then error("Parameter \"par_sg_a=\" must be \"a\" or \"ä\".") end
local stems = {}
stems = {params.base .. "i"}
stems = {params.base .. "e"}
stems = {params.base .. "t"}
stems = {params.base .. "i"}
stems = {params.base .. "i", params.base .. "t"}
make_stems(data, stems)
process_stems(data, stems, params.a)
if par_sg_a then
data.forms = {}
for _, stem in ipairs(stems) do
table.insert(data.forms, stem .. par_sg_a)
end
end
end
inflections = function(args, data)
data.title = "] type 25/], no gradation"
table.insert(data.categories, "Finnish toimi-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "mi"}
stems = {params.base .. "me"}
stems = {params.base .. "nt", params.base .. "me"}
stems = {params.base .. "mi"}
stems = {params.base .. "mi", params.base .. "nt"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 26/], no gradation"
table.insert(data.categories, "Finnish pieni-type nominals")
local params = get_params(args, 2)
local par_sg_a = args; if par_sg_a and par_sg_a ~= "a" and par_sg_a ~= "ä" then error("Parameter \"par_sg_a=\" must be \"a\" or \"ä\".") end
local stems = {}
stems = {params.base .. "i"}
stems = {params.base .. "e"}
stems = {params.base .. "t"}
stems = {params.base .. "i"}
stems = {params.base .. "t", params.base .. "i"}
make_stems(data, stems)
process_stems(data, stems, params.a)
if par_sg_a then
data.forms = {}
for _, stem in ipairs(stems) do
table.insert(data.forms, stem .. par_sg_a)
end
end
end
inflections = function(args, data)
data.title = "] type 27/], ''t-d'' gradation"
table.insert(data.categories, "Finnish käsi-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "si"}
stems = {params.base .. "te"}
stems = {params.base .. "de"}
stems = {params.base .. "tt"}
stems = {params.base .. "si"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "tten"}
end
inflections = function(args, data)
data.title = "] type 28/]"
table.insert(data.categories, "Finnish kynsi-type nominals")
local params = get_params(args, 2, false, "n")
local cons = mw.ustring.match(params.base, "(?)$")
if mw.title.getCurrentTitle().nsText ~= "Template" and cons == "" then
error("Stem must end in \"l\", \"n\" or \"r\".")
end
data.title = data.title .. ", ''" .. cons .. "t-" .. cons .. cons .. "'' gradation"
local stems = {}
stems = {params.base .. "si"}
stems = {params.base .. "te"}
stems = {params.base .. cons .. "e"}
stems = {params.base .. "tt"}
stems = {params.base .. "si"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "tten"}
end
inflections = function(args, data)
data.title = "] type 29/], no gradation"
table.insert(data.categories, "Finnish lapsi-type nominals")
local params = get_params(args, 2, false, "p")
local syncopated_stem, cons = mw.ustring.match(params.base, "^(.-)(?)$")
if mw.title.getCurrentTitle().nsText ~= "Template" and cons == "" then
error("Stem must end in \"k\" or \"p\".")
end
local stems = {}
stems = {params.base .. "si"}
stems = {params.base .. "se"}
stems = {syncopated_stem .. "st"}
stems = {params.base .. "si"}
stems = {params.base .. "si", syncopated_stem .. "st"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 30/], no gradation"
table.insert(data.categories, "Finnish veitsi-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "tsi"}
stems = {params.base .. "tse"}
stems = {params.base .. "st"}
stems = {params.base .. "tsi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "sten"}
end
inflections = function(args, data)
data.title = "] type 31/], ''t-d'' gradation"
table.insert(data.categories, "Finnish kaksi-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "ksi"}
stems = {params.base .. "hte"}
stems = {params.base .. "hde"}
stems = {params.base .. "ht"}
stems = {params.base .. "ksi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 32/]"
table.insert(data.categories, "Finnish sisar-type nominals")
local params = get_params(args, 5, true)
local nom_sg = args; if nom_sg == "" then nom_sg = nil end
make_weak(params.base, params.strong, params.final, params.weak)
if params.strong == params.weak then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {nom_sg or params.base .. params.weak .. params.final}
stems = {params.base .. params.strong .. params.final .. "e"}
stems = {params.base .. params.weak .. params.final .. "t"}
stems = {params.base .. params.strong .. params.final .. "i"}
stems = {params.base .. params.strong .. params.final .. "i", params.base .. params.weak .. params.final .. "t"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 33/]"
table.insert(data.categories, "Finnish kytkin-type nominals")
local params = get_params(args, 5, true)
make_weak(params.base, params.strong, params.final, params.weak)
if params.weak == params.strong then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.weak .. params.final .. "n"}
stems = {params.base .. params.strong .. params.final .. "me"}
stems = {params.base .. params.weak .. params.final .. "nt"}
stems = {params.base .. params.strong .. params.final .. "mi"}
stems = {params.base .. params.strong .. params.final .. "mi", params.base .. params.weak .. params.final .. "nt"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 34/], ''tt-t'' gradation"
table.insert(data.categories, "Finnish onneton-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "t" .. params.o .. "n"}
stems = {params.base .. "tt" .. params.o .. "m" .. params.a}
stems = {params.base .. "t" .. params.o .. "nt"}
stems = {params.base .. "tt" .. params.o .. "mi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "t" .. params.o .. "nten"}
end
inflections = function(args, data)
data.title = "] type 35/], ''mp-mm'' gradation"
table.insert(data.categories, "Finnish lämmin-type nominals")
local params = get_params(args, 1)
params.base = params.base .. "lä"
params.a = "ä"
local stems = {}
stems = {params.base .. "mmin"}
stems = {params.base .. "mpim" .. params.a}
stems = {params.base .. "mmint"}
stems = {params.base .. "mpimi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "mpim" .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 36/], ''mp-mm'' gradation"
table.insert(data.categories, "Finnish sisin-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "in"}
stems = {params.base .. "imp" .. params.a}
stems = {params.base .. "imm" .. params.a}
stems = {params.base .. "int"}
stems = {params.base .. "impi"}
stems = {params.base .. "immi"}
stems = {params.base .. "impi", params.base .. "int"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "imp" .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 37/], ''mp-mm'' gradation"
table.insert(data.categories, "Finnish vasen-type nominals")
local params = get_params(args, 1)
params.base = params.base .. "vase"
params.a = "a"
local stems = {}
stems = {params.base .. "n"}
stems = {params.base .. "mp" .. params.a}
stems = {params.base .. "mm" .. params.a}
stems = {params.base .. "nt", params.base .. "mp" .. params.a}
stems = {params.base .. "mpi"}
stems = {params.base .. "mmi"}
stems = {params.base .. "mpi", params.base .. "nt"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "mp" .. params.a .. "in"}
end
inflections = function(args, data)
data.title = "] type 38/], no gradation"
table.insert(data.categories, "Finnish nainen-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "nen"}
stems = {params.base .. "se"}
stems = {params.base .. "st"}
stems = {params.base .. "si"}
stems = {params.base .. "st", params.base .. "si"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 39/], no gradation"
table.insert(data.categories, "Finnish vastaus-type nominals")
local params = get_params(args, 2)
local nom_sg = args; if nom_sg == "" then nom_sg = nil end
local stems = {}
stems = {nom_sg or params.base .. "s"}
stems = {params.base .. "kse"}
stems = {params.base .. "st"}
stems = {params.base .. "ksi"}
stems = {params.base .. "st", params.base .. "ksi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 40/], ''t-d'' gradation"
table.insert(data.categories, "Finnish kalleus-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "s"}
stems = {params.base .. "te"}
stems = {params.base .. "de"}
stems = {params.base .. "tt"}
stems = {params.base .. "ksi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 41/]"
table.insert(data.categories, "Finnish vieras-type nominals")
local params = get_params(args, 5, true)
make_weak(params.base, params.strong, params.final, params.weak)
if params.weak == params.strong then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.weak .. params.final .. "s"}
stems = {params.base .. params.strong .. params.final .. params.final}
stems = {params.base .. params.weak .. params.final .. "st"}
stems = {params.base .. params.strong .. params.final .. params.final .. "se"}
stems = {params.base .. params.strong .. params.final .. "i"}
stems = {params.base .. params.strong .. params.final .. "it"}
stems = {params.base .. params.strong .. params.final .. "isi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. params.strong .. params.final .. "ihin"}
end
inflections = function(args, data)
data.title = "] type 42/], no gradation"
table.insert(data.categories, "Finnish mies-type nominals")
local params = get_params(args, 1)
params.base = params.base .. "mie"
params.a = "ä"
local stems = {}
stems = {params.base .. "s"}
stems = {params.base .. "he"}
stems = {params.base .. "st"}
stems = {params.base .. "hi"}
stems = {params.base .. "st", params.base .. "hi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 43/]"
table.insert(data.categories, "Finnish ohut-type nominals")
local params = get_params(args, 5, true)
make_weak(params.base, params.strong, params.final, params.weak)
if params.weak == params.strong then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.weak .. params.final .. "t"}
stems = {params.base .. params.strong .. params.final .. "e"}
stems = {params.base .. params.weak .. params.final .. "tt"}
stems = {params.base .. params.strong .. params.final .. "i"}
stems = {params.base .. params.strong .. params.final .. "it"}
stems = {params.base .. params.strong .. params.final .. "isi", params.base .. params.strong .. params.final .. "ih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 44/], no gradation"
table.insert(data.categories, "Finnish kevät-type nominals")
local params = get_params(args, 2)
local vowel = mw.ustring.sub(params.base, -1)
local stems = {}
stems = {params.base .. "t"}
stems = {params.base .. vowel}
stems = {params.base .. "tt"}
stems = {params.base .. vowel .. "se"}
stems = {params.base .. "i"}
stems = {params.base .. "it"}
stems = {params.base .. "isi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "ihin"}
end
inflections = function(args, data)
data.title = "] type 45/], ''nt-nn'' gradation"
table.insert(data.categories, "Finnish kahdeksas-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "s"}
stems = {params.base .. "nte"}
stems = {params.base .. "nne"}
stems = {params.base .. "tt"}
stems = {params.base .. "nsi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 46/], ''nt-nn'' gradation"
table.insert(data.categories, "Finnish tuhat-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. "t"}
stems = {params.base .. "nte"}
stems = {params.base .. "nne"}
stems = {params.base .. "tt"}
stems = {params.base .. "nsi"}
make_stems(data, stems)
process_stems(data, stems, params.a)
data.forms.rare = {params.base .. "nten"}
end
inflections = function(args, data)
data.title = "] type 47/], no gradation"
table.insert(data.categories, "Finnish kuollut-type nominals")
local params = get_params(args, 2)
local stems = {}
stems = {params.base .. params.u .. "t"}
stems = {params.base .. "ee"}
stems = {params.base .. params.u .. "tt"}
stems = {params.base .. "eese"}
stems = {params.base .. "ei"}
stems = {params.base .. "eit"}
stems = {params.base .. "eisi", params.base .. "eih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
inflections = function(args, data)
data.title = "] type 48/]"
table.insert(data.categories, "Finnish hame-type nominals")
local params = get_params(args, 4, true)
make_weak(params.base, params.strong, "e", params.weak)
if params.weak == params.strong then
data.title = data.title .. ", no gradation"
else
data.title = data.title .. ", ''" .. params.strong .. "-" .. params.weak .. "'' gradation"
end
local stems = {}
stems = {params.base .. params.weak .. "e"}
stems = {params.base .. params.strong .. "ee"}
stems = {params.base .. params.weak .. "ett"}
stems = {params.base .. params.strong .. "eese"}
stems = {params.base .. params.strong .. "ei"}
stems = {params.base .. params.strong .. "eit"}
stems = {params.base .. params.strong .. "eisi", params.base .. params.strong .. "eih"}
make_stems(data, stems)
process_stems(data, stems, params.a)
end
-- Helper functions
function postprocess(args, data)
local pos = args; if not pos or pos == "" then pos = "noun" end
local nosg = args; if nosg == "" then nosg = nil end
local nopl = args; if nopl == "" then nopl = nil end
local n = args; if n == "" then n = nil end
local suffix = args; if suffix == "" then suffix = nil end
local appendix = args; if appendix == "" then appendix = nil end
local has_ins_sg = args; if has_ins_sg == "" then has_ins_sg = nil end
-- Add the possessive suffix to the comitative plural, if the word is a noun
if pos == "noun" and data.forms then
for key, subform in ipairs(data.forms) do
data.forms = subform .. "en"
end
end
if nosg or n == "pl" then
table.insert(data.categories, "Finnish pluralia tantum")
end
-- TODO: This says "nouns", but this module is also used for adjectives!
if nopl or n == "sg" then
table.insert(data.categories, "Finnish uncountable nouns")
end
if not has_ins_sg then
data.forms = nil
end
for key, form in pairs(data.forms) do
-- Add suffix to forms
for i, subform in ipairs(form) do
subform = subform .. (suffix or "")
form = subform
end
if form.rare then
for i, subform in ipairs(form.rare) do
subform = subform .. (suffix or "")
form.rare = subform
end
end
-- Do not show singular or plural forms for nominals that don't have them
if ((nosg or n == "pl") and key:find("_sg$")) or ((nopl or n == "sg") and key:find("_pl$")) then
form = nil
end
data.forms = form
end
-- Check if the lemma form matches the page name
if not appendix and lang:makeEntryName(data.forms) ~= mw.title.getCurrentTitle().text then
table.insert(data.categories, "Finnish entries with inflection not matching pagename")
end
end
-- Make the table
function make_table(data)
local function show_form(form, no_rare)
if not form then
return "—"
elseif type(form) ~= "table" then
error("a non-table value was given in the list of inflected forms.")
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, m_links.full_link({lang = lang, term = subform}))
end
if not no_rare and form.rare then
for key, subform in ipairs(form.rare) do
table.insert(ret, m_links.full_link({lang = lang, term = subform}) .. "<sup>rare</sup>")
end
end
return table.concat(ret, "<br/>")
end
local function repl(param)
if param == "lemma" then
return m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
elseif param == "info" then
return data.title and " (" .. data.title .. ")" or ""
else
local param2 = mw.ustring.match(param, "^(.-):c$")
if param2 then
return show_form(data.forms, true)
else
return show_form(data.forms)
end
end
end
local wikicode = [=[
{| class="inflection-table fi-decl vsSwitcher" data-toggle-category="inflection"
|-
! class="vsToggleElement" colspan="4" | Inflection of {{{lemma}}}{{{info}}}
|- class="vsShow"
! class="case-column" colspan="2" | nominative
| class="number-column" | {{{nom_sg:c}}}
| class="number-column" | <span class="form-of plural-nominative-form-of lang-fi">{{{nom_pl:c}}}</span>
|- class="vsShow"
! colspan="2" | genitive
| <span class="form-of singular-genitive-form-of lang-fi">{{{gen_sg:c}}}</span>
| <span class="form-of plural-genitive-form-of lang-fi">{{{gen_pl:c}}}</span>
|- class="vsShow"
! colspan="2" | partitive
| <span class="form-of singular-partitive-form-of lang-fi">{{{par_sg:c}}}</span>
| <span class="form-of plural-partitive-form-of lang-fi">{{{par_pl:c}}}</span>
|- class="vsShow"
! colspan="2" | illative
| <span class="form-of singular-illative-form-of lang-fi">{{{ill_sg:c}}}</span>
| <span class="form-of plural-illative-form-of lang-fi">{{{ill_pl:c}}}</span>
|- class="vsHide"
! colspan="2" |
! singular
! plural
|- class="vsHide"
! class="case-column" colspan="2" | nominative
| class="number-column" | {{{nom_sg}}}
| class="number-column" | <span class="form-of plural-nominative-form-of lang-fi">{{{nom_pl}}}</span>
|- class="vsHide"
! rowspan="2" | accusative
! nom.<sup title="The nominative accusative is used, for example, as the object of certain passives and imperatives."></sup>
| {{{nom_sg}}}
| rowspan="2" | <span class="form-of plural-accusative-form-of lang-fi">{{{nom_pl}}}</span>
|- class="vsHide"
! gen.
| <span class="form-of singular-genitive-form-of lang-fi">{{{gen_sg}}}</span>
|- class="vsHide"
! colspan="2" | genitive
| <span class="form-of singular-genitive-form-of lang-fi">{{{gen_sg}}}</span>
| <span class="form-of plural-genitive-form-of lang-fi">{{{gen_pl}}}</span>
|- class="vsHide"
! colspan="2" | partitive
| <span class="form-of singular-partitive-form-of lang-fi">{{{par_sg}}}</span>
| <span class="form-of plural-partitive-form-of lang-fi">{{{par_pl}}}</span>
|- class="vsHide"
! colspan="2" | inessive
| <span class="form-of singular-inessive-form-of lang-fi">{{{ine_sg}}}</span>
| <span class="form-of plural-inessive-form-of lang-fi">{{{ine_pl}}}</span>
|- class="vsHide"
! colspan="2" | elative
| <span class="form-of singular-elative-form-of lang-fi">{{{ela_sg}}}</span>
| <span class="form-of plural-elative-form-of lang-fi">{{{ela_pl}}}</span>
|- class="vsHide"
! colspan="2" | illative
| <span class="form-of singular-illative-form-of lang-fi">{{{ill_sg}}}</span>
| <span class="form-of plural-illative-form-of lang-fi">{{{ill_pl}}}</span>
|- class="vsHide"
! colspan="2" | adessive
| <span class="form-of singular-adessive-form-of lang-fi">{{{ade_sg}}}</span>
| <span class="form-of plural-adessive-form-of lang-fi">{{{ade_pl}}}</span>
|- class="vsHide"
! colspan="2" | ablative
| <span class="form-of singular-ablative-form-of lang-fi">{{{abl_sg}}}</span>
| <span class="form-of plural-ablative-form-of lang-fi">{{{abl_pl}}}</span>
|- class="vsHide"
! colspan="2" | allative
| <span class="form-of singular-allative-form-of lang-fi">{{{all_sg}}}</span>
| <span class="form-of plural-allative-form-of lang-fi">{{{all_pl}}}</span>
|- class="vsHide"
! colspan="2" | essive
| <span class="form-of singular-essive-form-of lang-fi">{{{ess_sg}}}</span>
| <span class="form-of plural-essive-form-of lang-fi">{{{ess_pl}}}</span>
|- class="vsHide"
! colspan="2" | translative
| <span class="form-of singular-translative-form-of lang-fi">{{{tra_sg}}}</span>
| <span class="form-of plural-translative-form-of lang-fi">{{{tra_pl}}}</span>
|- class="vsHide"
! colspan="2" | instructive
| <span class="form-of singular-instructive-form-of lang-fi">{{{ins_sg}}}</span>
| <span class="form-of plural-instructive-form-of lang-fi">{{{ins_pl}}}</span>
|- class="vsHide"
! colspan="2" | abessive
| <span class="form-of singular-abessive-form-of lang-fi">{{{abe_sg}}}</span>
| <span class="form-of plural-abessive-form-of lang-fi">{{{abe_pl}}}</span>
|- class="vsHide"
! colspan="2" | comitative
| {{{com_sg}}}
| {{{com_pl}}}
|}]=]
return mw.ustring.gsub(wikicode, "{{{(+)}}}", repl)
end
export.inflections = inflections
return export