local lang = require("Module:languages").getByCode("tuf")
local rfind = mw.ustring.find
local rsplit = mw.text.split
local export = {}
local function rsub(term, foo, bar)
local retval = mw.ustring.gsub(term, foo, bar)
return retval
end
local function postprocess(args, data)
data.lemma = data.forms
-- Check if the lemma form matches the page name
if (lang:makeEntryName(data.lemma)) ~= mw.title.getCurrentTitle().text then
table.insert(data.categories, lang:getCanonicalName() .. " entries with inflection not matching pagename")
end
end
-- Table-generating functions
local function make_table(data)
local function repl(param)
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
param = string.sub(param, 2)
end
local forms = data.forms
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}))
end
return table.concat(ret, "<br/>")
end
local wikicode = mw.getCurrentFrame():expandTemplate{
title = 'inflection-table-top',
args = {
title = '{{{info}}}',
tall = 'yes',
palette = 'green'
}
}
wikicode = wikicode .. [=[
! colspan = "8" class = "outer"|declarative
|-
! intentional
! negative
! colspan="2" |obligative
! colspan="2" |impossibilitive
! present
! past
|-
| {{{dint}}}
| {{{dneg}}}
| colspan = "2" |{{{dobl}}}
| colspan = "2" |{{{dimp}}}
| {{{dpres}}}
| {{{dpast}}}
|-
| colspan="2" class="separator" |
| style="border-bottom:0;border-right:0" class="separator" |
| colspan="2" class="separator" |
| style="border-bottom:0;border-right:0" class="separator" |
| colspan="2" class="separator" |
|-
! colspan = "2" class="outer" |contrastive
! rowspan="3" class="separator" |
! colspan = "2" class="outer" |interrogative
! rowspan="3" class="separator" |
! colspan = "2" class="outer" |imperative
|-
! near past
! near future
! present
! past
! positive
! negative
|-
| {{{cpast}}}
| {{{cfut}}}
| {{{inpres}}}
| {{{inpast}}}
| {{{impos}}}
| {{{imneg}}}
]=]
wikicode = wikicode .. mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom', args = {notes = "<small>This table is not exhaustive.</small>"} }
return mw.ustring.gsub(wikicode, "{{{?(+)}}}", repl) .. require("Module:utilities").format_categories(data.categories, lang)
end --normal table
-- Inflection functions (common nouns)
function export.show(frame)
local args = frame:getParent().args
local data = {
forms = {},
categories = {},
= {},
}
local ending_text = 0
-- add the lemma form
local stem = ""
local base = args.pagename or mw.title.getCurrentTitle().text
--find the root and the theme
local themes = {"qui", "cui", "yi", "ni", "w̃i", "wi", "a", "o", "u"}
local theme
local root
for _, th in ipairs(themes) do
if rfind(base, th .. "nro$") then
root = rsub(base, th .. "nro$", "")
theme = th
break
end
end
--tenses for each suffix
local suffixes = {
= {dneg = "tiro", dobl = "cátaro", dimp = "cajatro", dpres = "caro", dpast = "jacro",
cpast = "quira", cfut = "cáyquira", inpres = "qui", inpast = "cyi", impos = "w̃i"},
= {dneg = "ctiro", dobl = "cuátaro", dimp = "cuajatro", dpres = "cro", dpast = "jacro",
cpast = "cuira", cfut = "cuáyquira", inpres = "cuiqui", inpast = "cyi", impos = "cwi"},
= {dneg = "tiro", dobl = "yataro", dimp = "yajatro", dpres = "caro", dpast = "jecro",
cpast = "yira", cfut = "yáyquira", inpres = "qui", inpast = "yi", impos = "owi"},
= {dneg = "ntiro", dobl = "nátaro", dimp = "najatro", dpres = "nro", dpast = "njacro",
cpast = "nira", cfut = "náyquira", inpres = "nca", inpast = "nyi", impos = "nwi"},
= {dneg = "w̃tiro", dobl = "w̃átaro", dimp = "w̃ajatro", dpres = "w̃ro", dpast = "w̃jacro",
cpast = "w̃ira", cfut = "w̃áyquira", inpres = "w̃ca", inpast = "w̃ya", impos = "w̃i"},
= {dneg = "utiro", dobl = "wataro", dimp = "wajatro", dpres = "wro", dpast = "ujacro",
cpast = "wira", cfut = "wayquira", inpres = "wca", inpast = "wya", impos = "wi"},
= {dneg = "atiro", dobl = "ataro", dimp = "ajatro", dpres = "aro", dpast = "ajacro",
cpast = "aira", cfut = "ayquira", inpres = "aca", inpast = "ayi", impos = "awi"},
= {dneg = "otiro", dobl = "otaro", dimp = "ojotro", dpres = "oro", dpast = "ojocro",
cpast = "oira", cfut = "oyquira", inpres = "oca", inpast = "oyi", impos = "owi"},
= {dneg = "útiro", dobl = "wátaro", dimp = "wajatro", dpres = "uro", dpast = "ujacro",
cpast = "úira", cfut = "wayquira", inpres = "uca", inpast = "uya", impos = "uwa"},
}
--auxiliary stuff
local function unstress(w)
return rsub(w, "", { = "a", = "e", = "i", = "o", = "u"})
end
local function stress(w)
return w
end
local root_is_stressed = rfind(root, "")
--do the tenses
data.forms = {base}
local tenses = {"dneg", "dobl", "dimp", "dpres", "dpast", "cpast", "cfut", "inpres", "inpast", "impos"}
for _, t in ipairs(tenses) do
if root_is_stressed then
data.forms = {root .. unstress(suffixes)}
else
data.forms = {root .. suffixes}
end
end
---------------------------
---------------------------
--final stuff
table.insert(data.categories, "Central Tunebo verbs in -" .. theme)
data.info = "Conjugation of " .. require("Module:links").full_link({lang = lang, alt = base}, "term") .. " <small>(stem in -" .. theme .. "</small>)"
return make_table(data)
end
return export