Module:sl-adjectives
Jump to navigation
Jump to search
- The following documentation is located at Module:sl-adjectives/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local lang = require("Module:languages").getByCode("sl")
-- Within this module, inflections are the functions that do the actual inflecting
-- by creating the forms of an adjective. They are defined further down.
local inflections = {}
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
PAGENAME = mw.title.getCurrentTitle().text
FULLPAGENAME = mw.title.getCurrentTitle().prefixedText
NAMESPACE = mw.title.getCurrentTitle().nsText
local infl_type = frame.args[1] or error("Inflection type has not been specified.")
local args = frame:getParent().args
local data = {forms = {}, info = nil, categories = {}}
if inflections[infl_type] then
inflections[infl_type](args, data)
else
error("Unknown inflection type '" .. infl_type .. "'")
end
return make_table(data)
end
-- Hard stem adjective
inflections["regular"] = function(args, data)
local stem = args[1]; if not stem or stem == "" then if NAMESPACE == "Template" then stem = "-" else error("1st parameter (stem) has not been specified.") end end
local final = args[2]; if final == "" then final = nil end
local def = args["def"]
-- Create the full stem, which is used when endings are added
local full_stem = stem
if final then
full_stem = full_stem .. final
else
full_stem = make_long(full_stem)
end
-- If the given stem doesn't contain any accent marks, flag the entry for attention
if not require("Module:sl-common").has_accents(full_stem) then
table.insert(data.categories, "Requests for accents in Slovene adjective entries")
end
-- Is this a hard stem or a soft stem?
local oe = "o"
data.info = "hard"
if require("Module:sl-common").is_soft(full_stem) then
oe = "e"
data.info = "soft"
end
-- Masculine singular
if def == "1" then
data.forms["nom_sg_m"] = {full_stem .. "i"}
elseif def == "0" then
data.forms["nom_sg_m"] = {stem .. (final and "e" .. final or "")}
else
data.forms["nom_sg_m"] = {stem .. (final and "e" .. final or "")}
data.forms["nom_sg_m_def"] = {full_stem .. "i"}
end
-- acc_sg_m depends on animacy
data.forms["gen_sg_m"] = {full_stem .. "ega"}
data.forms["dat_sg_m"] = {full_stem .. "emu"}
data.forms["loc_sg_m"] = {full_stem .. "em"}
data.forms["ins_sg_m"] = {full_stem .. "im"}
-- Feminine singular
data.forms["nom_sg_f"] = {full_stem .. "a"}
data.forms["acc_sg_f"] = {full_stem .. "o"}
data.forms["gen_sg_f"] = {full_stem .. "e"}
data.forms["dat_sg_f"] = {full_stem .. "i"}
data.forms["loc_sg_f"] = {full_stem .. "i"}
data.forms["ins_sg_f"] = {full_stem .. "o"}
-- Neuter singular
data.forms["nom_sg_n"] = {full_stem .. oe}
data.forms["acc_sg_n"] = {full_stem .. oe}
data.forms["gen_sg_n"] = {full_stem .. "ega"}
data.forms["dat_sg_n"] = {full_stem .. "emu"}
data.forms["loc_sg_n"] = {full_stem .. "em"}
data.forms["ins_sg_n"] = {full_stem .. "im"}
-- Masculine dual
data.forms["nom_du_m"] = {full_stem .. "a"}
data.forms["acc_du_m"] = {full_stem .. "a"}
data.forms["gen_du_m"] = {full_stem .. "ih"}
data.forms["dat_du_m"] = {full_stem .. "ima"}
data.forms["loc_du_m"] = {full_stem .. "ih"}
data.forms["ins_du_m"] = {full_stem .. "ima"}
-- Feminine dual
data.forms["nom_du_f"] = {full_stem .. "i"}
data.forms["acc_du_f"] = {full_stem .. "i"}
data.forms["gen_du_f"] = {full_stem .. "ih"}
data.forms["dat_du_f"] = {full_stem .. "ima"}
data.forms["loc_du_f"] = {full_stem .. "ih"}
data.forms["ins_du_f"] = {full_stem .. "ima"}
-- Neuter dual
data.forms["nom_du_n"] = {full_stem .. "i"}
data.forms["acc_du_n"] = {full_stem .. "i"}
data.forms["gen_du_n"] = {full_stem .. "ih"}
data.forms["dat_du_n"] = {full_stem .. "ima"}
data.forms["loc_du_n"] = {full_stem .. "ih"}
data.forms["ins_du_n"] = {full_stem .. "ima"}
-- Masculine plural
data.forms["nom_pl_m"] = {full_stem .. "i"}
data.forms["acc_pl_m"] = {full_stem .. "e"}
data.forms["gen_pl_m"] = {full_stem .. "ih"}
data.forms["dat_pl_m"] = {full_stem .. "im"}
data.forms["loc_pl_m"] = {full_stem .. "ih"}
data.forms["ins_pl_m"] = {full_stem .. "imi"}
-- Feminine plural
data.forms["nom_pl_f"] = {full_stem .. "e"}
data.forms["acc_pl_f"] = {full_stem .. "e"}
data.forms["gen_pl_f"] = {full_stem .. "ih"}
data.forms["dat_pl_f"] = {full_stem .. "im"}
data.forms["loc_pl_f"] = {full_stem .. "ih"}
data.forms["ins_pl_f"] = {full_stem .. "imi"}
-- Neuter plural
data.forms["nom_pl_n"] = {full_stem .. "a"}
data.forms["acc_pl_n"] = {full_stem .. "a"}
data.forms["gen_pl_n"] = {full_stem .. "ih"}
data.forms["dat_pl_n"] = {full_stem .. "im"}
data.forms["loc_pl_n"] = {full_stem .. "ih"}
data.forms["ins_pl_n"] = {full_stem .. "imi"}
end
function make_long(stem)
local vowel_repl = {
["à"] = "á",
["è"] = "ê",
["ì"] = "í",
["ò"] = "ô",
["ù"] = "ú"}
function repl(vowel, rest)
return (vowel_repl[vowel] or vowel) .. rest
end
return mw.ustring.gsub(stem, "([àèìòù])([^aeiouàèìòùáéíóúêô]+)$", repl)
end
function make_table(data)
local function repl(param)
local accel = false -- Temporary
local no_store = false
if param == "info" then
return mw.getContentLanguage():ucfirst(data.info or "")
elseif string.sub(param, 1, 1) == "!" then
no_store = true
param = string.sub(param, 2)
elseif string.sub(param, 1, 1) == "#" then
accel = false
param = string.sub(param, 2)
end
local forms = data.forms[param]
if not forms then
return "—"
end
local ret = {}
for key, subform in ipairs(forms) do
table.insert(ret, require("Module:links").full_link({lang = lang, term = subform, accel = accel and {form = param, no_store = no_store} or nil}))
end
return table.concat(ret, "<br/>")
end
local wikicode = [=[
{| class="messagebox" style="margin-bottom: 0.5em; background: #d9ebff; border: 1px solid #d9ebff;"
|-
| [[Image:Zobnoustnični m.svg|none|45px]]
| The '''[[Wiktionary:About Slovene|diacritics used in this section of the entry are non-tonal]]'''. If you are a native tonal speaker, please help by adding the tonal marks.
|}
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="background: #F9F9F9; border: 1px solid #aaaaaa;"
|- style="background: #d9ebff; text-align: left;"
! class="vsToggleElement" colspan="4" | {{{info}}}
|- class="vsShow"
! style="background: #d9ebff; width: 9em;" |
! style="background: #d9ebff; width: 10em;" | masculine
! style="background: #d9ebff; width: 10em;" | feminine
! style="background: #d9ebff; width: 10em;" | neuter
|- class="vsShow"
! style="width: 11em; background: #eff7ff;" | nom. sing.
| style="width: 11em;" | {{{!nom_sg_m}}}
| style="width: 11em;" | {{{!nom_sg_f}}}
| style="width: 11em;" | {{{!nom_sg_n}}}
|- class="vsHide"
! colspan="4" style="background: #b3d7ff;" | singular
|- class="vsHide"
! style="width: 11em; background: #d9ebff;" |
! style="width: 11em; background: #d9ebff;" | masculine
! style="width: 11em; background: #d9ebff;" | feminine
! style="width: 11em; background: #d9ebff;" | neuter
|- class="vsHide"
! style="background: #eff7ff;" | nominative
| {{{nom_sg_m}}}]=] .. (data.forms["nom_sg_m_def"] and ' <sup style="cursor:help" title="indefinite">ind</sup><br/>{{{nom_sg_m_def}}} <sup style="cursor:help" title="definite">def</sup>' or "") .. [=[
| {{{nom_sg_f}}}
| {{{nom_sg_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | genitive
| {{{gen_sg_m}}}
| {{{gen_sg_f}}}
| {{{gen_sg_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | dative
| {{{dat_sg_m}}}
| {{{dat_sg_f}}}
| {{{dat_sg_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | accusative
| ''nominative''<sup style="cursor:help" title="inanimate">inan</sup>'' or<br/>genitive''<sup style="cursor:help" title="animate">anim</sup>
| {{{acc_sg_f}}}
| {{{acc_sg_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | locative
| {{{loc_sg_m}}}
| {{{loc_sg_f}}}
| {{{loc_sg_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | instrumental
| {{{ins_sg_m}}}
| {{{ins_sg_f}}}
| {{{ins_sg_n}}}
|- class="vsHide"
! colspan="4" style="background: #b3d7ff;" | dual
|- class="vsHide"
! style="background: #d9ebff;" |
! style="background: #d9ebff;" | masculine
! style="background: #d9ebff;" | feminine
! style="background: #d9ebff;" | neuter
|- class="vsHide"
! style="background: #eff7ff;" | nominative
| {{{nom_du_m}}}
| {{{nom_du_f}}}
| {{{nom_du_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | genitive
| {{{gen_du_m}}}
| {{{gen_du_f}}}
| {{{gen_du_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | dative
| {{{dat_du_m}}}
| {{{dat_du_f}}}
| {{{dat_du_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | accusative
| {{{acc_du_m}}}
| {{{acc_du_f}}}
| {{{acc_du_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | locative
| {{{loc_du_m}}}
| {{{loc_du_f}}}
| {{{loc_du_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | instrumental
| {{{ins_du_m}}}
| {{{ins_du_f}}}
| {{{ins_du_n}}}
|- class="vsHide"
! colspan="4" style="background: #b3d7ff;" | plural
|- class="vsHide"
! style="background: #d9ebff;" |
! style="background: #d9ebff;" | masculine
! style="background: #d9ebff;" | feminine
! style="background: #d9ebff;" | neuter
|- class="vsHide"
! style="background: #eff7ff;" | nominative
| {{{nom_pl_m}}}
| {{{nom_pl_f}}}
| {{{nom_pl_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | genitive
| {{{gen_pl_m}}}
| {{{gen_pl_f}}}
| {{{gen_pl_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | dative
| {{{dat_pl_m}}}
| {{{dat_pl_f}}}
| {{{dat_pl_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | accusative
| {{{acc_pl_m}}}
| {{{acc_pl_f}}}
| {{{acc_pl_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | locative
| {{{loc_pl_m}}}
| {{{loc_pl_f}}}
| {{{loc_pl_n}}}
|- class="vsHide"
! style="background: #eff7ff;" | instrumental
| {{{ins_pl_m}}}
| {{{ins_pl_f}}}
| {{{ins_pl_n}}}
|}]=]
return mw.ustring.gsub(wikicode, "{{{([^}]+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end
return export