Module:hsb-adecl
Jump to navigation
Jump to search
- The following documentation is located at Module:hsb-adecl/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module implements {{hsb-decl-adj-auto}}
.
local export = {}
local function autoinflect(lemma)
local stem, substem, extra, ending = mw.ustring.match(lemma, "^((.+)(ch))([iy])$")
if not extra then
stem, substem, extra, ending = mw.ustring.match(lemma, "^((.+)([hktdłčćšžnw]))([iy])$")
end
if not extra then
stem, substem, ending = mw.ustring.match(lemma, "^((.+))([iy])$")
end
local extra_alt = { ["h"] = "z", ["ch"] = "š", ["k"] = "c", ["t"] = "ć", ["d"] = "dź", ["ł"] = "l" }
local soft = ending == "i" and mw.ustring.match(extra, "^[čćšžnw]$")
local addj = ending == "i" and mw.ustring.match(extra, "^[nw]$")
return {
[1] = lemma,
[2] = stem .. (addj and "j" or "") .. "e",
[3] = stem .. (addj and "j" or "") .. "a",
[4] = stem .. (soft and ((addj and "j" or "") .. "ej") or "aj"),
[5] = stem .. (addj and "j" or "") .. "ej",
[6] = substem .. (extra_alt[extra] or extra or "") .. (ending == "y" and "i" or (extra_alt[extra] and mw.ustring.match(extra_alt[extra], "^[cz]$") and "y" or "i")),
[7] = stem .. (addj and "j" or "") .. "eho",
[8] = stem .. (addj and "j" or "") .. "eje",
[9] = stem .. (addj and "j" or "") .. "eju",
[10] = lemma .. "ch",
[11] = stem .. (addj and "j" or "") .. "emu",
[12] = lemma .. "maj",
[13] = lemma .. "m",
[14] = stem .. (addj and "j" or "") .. "u",
[15] = lemma .. "mi",
[16] = (ending == "i" and not soft) and (stem .. "ej") or nil,
[17] = stem .. (addj and "j" or "") .. "oh",
[18] = stem .. (addj and "j" or "") .. "om",
}
end
function export.show(frame)
local title = mw.title.getCurrentTitle()
local pargs = frame:getParent().args
local lemma = frame.args[1] or pargs[1]; if lemma == "" then lemma = nil end
lemma = lemma or (title.namespace == 0 and title.text) or (title.nsText == "Template" and "tuni")
local declinfo = autoinflect(lemma, pargs) or error(("No declension pattern matches "%s""):format(lemma))
return frame:expandTemplate{ title = "hsb-decl-adj", args = declinfo }
end
return export