Module:xum-decl
Jump to navigation
Jump to search
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {};
local format_g = require("Module:gender and number").format_list;
local format_link = require("Module:links").full_link;
local lang = require("Module:languages").getByCode('xum');
-- these are the noun and adjective declension
local cases = {}
cases.nom = "nominative";
cases.gen = "genitive";
cases.dat = "dative";
cases.acc = "accusative";
cases['acc-en'] = "accusative + ''" .. format_link({ term = "-en", lang = lang }) .. "''";
cases['acc-ars'] = "accusative + ''" .. format_link({ term = "-ař", lang = lang }) .. "''";
cases.abl = "ablative";
cases['abl-kom'] = "ablative + ''" .. format_link({ term = "-kom", lang = lang }) .. "''";
cases['abl-per'] = "ablative + ''" .. format_link({ term = "-per", lang = lang }) .. "''";
cases.ablkom = "ablative"; -- ???
cases.voc = "vocative";
cases['loc-en'] = "locative + ''" .. format_link({ term = "-en", lang = lang }) .. "''";
cases['loc-en?'] = "locative (+ ''" .. format_link({ term = "-en", lang = lang }) .. "''?)";
local function case_string(str)
if (str:match("-s$")) then
return cases[str:gsub("-s$", "")] .. " sigular";
elseif (str:match("-p$")) then
return cases[str:gsub("-p$", "")] .. " plural";
end
if (str:match("-mf")) then
return cases[str:gsub("-mf", "")] .. ' <abbr title="masculine or feminine">m./f.</abbr>';
elseif (str:match("-n")) then
return cases[str:gsub("-n", "")] .. " neuter";
end
return cases[str];
end
-- these are the verb forms
local forms = {}
forms['3s-impv'] = '<abbr title="third person singular">3s</abbr> <abbr title="imperative">impv.</abbr> <abbr title="future">fut.</abbr>'
forms['3p-impv'] = '<abbr title="third person plural">3p</abbr> <abbr title="imperative">impv.</abbr> <abbr title="future">fut.</abbr>'
forms['2s-fut'] = '<abbr title="second person singular">2s</abbr> <abbr title="indicative">indc.</abbr> <abbr title="future">fut.</abbr>'
forms['3p-fut-pas'] = '<abbr title="third person plural">3p</abbr> <abbr title="indicative">indc.</abbr> <abbr title="future">fut.</abbr> <abbr title="passive">pass.</abbr>'
forms['3s-fut-perf'] = '<abbr title="third person singular">3s</abbr> <abbr title="perfect">perf.</abbr> <abbr title="future">fut.</abbr>'
forms['3p-fut-perf'] = '<abbr title="third person plural">3p</abbr> <abbr title="perfect">perf.</abbr> <abbr title="future">fut.</abbr>'
forms['3s-subj'] = '<abbr title="third person singular">3s</abbr> <abbr title="subjunctive">subj.</abbr> <abbr title="present">pres.</abbr>'
forms['inf'] = '<abbr title="infinitive">inf.</abbr> <abbr title="present">pres.</abbr>'
forms['pp'] = "past participle"
forms['3s-fut-perf-pas'] = '<abbr title="third person singular">3s</abbr> <abbr title="perfect">perf.</abbr> <abbr title="future">fut.</abbr> <abbr title="passive">pass.</abbr>'
local function form_string(str)
return forms[str];
end
-- these are the varieties
local function format_varname(short, long)
return '<abbr title="' .. long .. [[">'']] .. short .. "''</abbr>";
end
local varieties = {}
varieties.eig = format_varname("e.Ig.", "early Iguvine");
varieties.lig = format_varname("l.Ig.", "late Iguvine");
varieties.vel = format_varname("Vel.", "Velitraean");
-- this prints all the attested spellings of only one variety
local function format_var(str)
local o = varieties[str:gsub(":.+", "")] .. " ";
for k in string.gmatch(str:gsub(".+:", ""), "[^, ]+") do
o = o .. format_link({ term = k, lang = lang }) .. ", ";
end
return o:sub(1, -3); -- remove final comma
end
-- this prints all of attested spellings of one form
local function format_allvars(str)
local value = '';
for k in string.gmatch(str, "[^.]+") do
value = value .. format_var(k) .. "<br/>";
end
return value:sub(1, -6); -- remove final <br/>
end
-- these three functions help build the wikitable
local function make_margin(str)
return '<div style="margin-left:.5em;margin-right:.5em">' .. str .. '</div>';
end
local function start_table(i, lemma, lemmatized, gendr)
return '{| class="inflection-table" style="background: #FAFAFA; border: 1px solid #d0d0d0; text-align: left;' .. (i and 'margin-top:0px; margin-bottom: 0px; width:100%;' or '') .. '"\n|- style="background: #CCC;"\n! colspan="3" | ' .. make_margin('Inflection of ' .. lemma .. '<sup><abbr title="lemmatized in the ' .. lemmatized .. '">?</abbr></sup> ' .. gendr) .. '\n';
end
local function start_line(string, second)
return '|-\n! style="background-color: #eff7ff;" | ' .. make_margin(string) .. '\n|' .. second .. '\n';
end
-- entry point for {{xum-decl}}
function export.show(frame)
local args = frame:getParent().args;
local lemma = "''" .. args[1] .. "''";
local lemma_g = format_g({args[2]});
local o = start_table(args.i, lemma, 'accusaitve', lemma_g);
local i = 3; local arg_i = args[i];
while (arg_i) do
o = o .. start_line(case_string(arg_i:gsub("/.+", "")), make_margin(format_allvars(arg_i:gsub(".+/", ""))));
i = i + 1; arg_i = args[i];
end
return o .. '|}';
end
-- entry point for {{xum-conj}}
function export.show_verb(frame)
local args = frame:getParent().args;
local lemma = "''" .. args[1] .. "''";
local o = start_table(false, lemma, 'present infinitive', '');
local i = 2; local arg_i = args[i];
while (arg_i) do
o = o .. start_line (form_string(arg_i:gsub("/.+", "")), arg_i:match("//") and arg_i:gsub(".+//", "") or make_margin(format_allvars(arg_i:gsub(".+/", ""))));
i = i + 1; arg_i = args[i];
end
return o .. '|}';
end
-- entry point for {{xum-invar}}
function export.show_invar(frame)
return '*' .. format_allvars(frame:getParent().args[1]);
end
return export;