Module:tuf-noun
Appearance
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
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
-- Table-generating functions
local function make_table(data)
local function repl(param)
local accel = true
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, lemma = data.lemma, no_store = no_store} or nil}))
end
return table.concat(ret, "<br/>")
end
local wikicode = mw.getCurrentFrame():expandTemplate{
title = 'inflection-table-top',
args = {
title = '{{{info}}}',
tall = 'yes',
palette = 'blue'
}
}
wikicode = wikicode .. [=[
!
! singular
! plural
|-
! isolated
| data-accel-col="1" | {{{isolated|s}}}
| data-accel-col="2" | {{{isolated|p}}}
|-
! ergative
| data-accel-col="1" | {{{erg|s}}}
| data-accel-col="2" | {{{erg|p}}}
|-
! absolutive
| data-accel-col="1" | {{{absv|s}}}
| data-accel-col="2" | {{{absv|p}}}
|-
! genitive
| data-accel-col="1" | {{{gen|s}}}
| data-accel-col="2" | {{{gen|p}}}
|-
! vocative
| data-accel-col="1" | {{{voc|s}}}
| data-accel-col="2" | {{{voc|p}}}
]=]
wikicode = wikicode .. mw.getCurrentFrame():expandTemplate{ title = 'inflection-table-bottom' }
return mw.ustring.gsub(wikicode, "{{{[#!]?([a-z0-9|]+)}}}", 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 = {},
info = "Declension of ",
categories = {},
}
local ending_text = 0
-- add the lemma form
local stem = ""
local themes = {s = mw.title.getCurrentTitle().text}
if args[1] then
themes["p"] = args[1]
end
for n, w in pairs(themes) do
if rfind(w, "a$") then
--add forms
stem = rsub(w, "a$", "")
data.forms["isolated|" .. n] = {w}
data.forms["erg|" .. n] = {stem .. "at"}
data.forms["absv|" .. n] = {stem}
data.forms["gen|" .. n] = {stem .. "ay"}
data.forms["voc|" .. n] = {stem .. "u"}
elseif rfind(w, "á$") then
--add forms
stem = rsub(w, "á$", "")
data.forms["isolated|" .. n] = {w}
data.forms["erg|" .. n] = {stem .. "át"}
data.forms["absv|" .. n] = {stem}
data.forms["gen|" .. n] = {stem .. "áy"}
data.forms["voc|" .. n] = {stem .. "ú"}
else
error("Nouns should end in -a/-á.")
end
end
data.info = data.info .. require("Module:links").full_link({lang = lang, alt = themes["s"]}, "term")
return make_table(data)
end
return export