Module:qhv-verb
Jump to navigation
Jump to search
- The following documentation is located at Module:qhv-verb/doc.[edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local sub = mw.ustring.sub
local gsub = mw.ustring.gsub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local match = mw.ustring.match
local u = mw.ustring.char
local m_utils = require("Module:utilities")
local m_data = require('Module:qhv-verb/data')
local PAGENAME = mw.title.getCurrentTitle().text
local NAMESPACE = mw.title.getCurrentTitle().nsText
local lang = require("Module:languages").getByCode("qhv")
local export = {}
local endings = {
["[lr]"] = "liquid",
["[ptkq]"] = "voiceless-stop",
["[mn]"] = "nasal",
["[bdg]"] = "voiced-stop",
["lj"] = "palatal", ["ñ"] = "palatal",
["egon"] = "e", ["igon"] = "i", ["ogon"] = "o", ["ugon"] = "u",
["[^l][hszvj]"] = "fricative", ["gh"] = "fricative",
}
function export.detect_decl(word, class)
local root = sub(word, 1, -5)
if class then
local decl = class
return decl, {sub(root, 1, (sub(root, -2) == ("lj" or "gh") and -3 or -2))}
elseif m_data.astems[word] then return "a", {sub(root, -2)}
else
for ending, decl in pairs(endings) do
if find(root, ending .. "$") then
return decl, {sub(root, 1, -(#ending + 1))}
elseif find(word, ending .. "$") then
return decl, {sub(root, 1, -2)}
else return "fricative", {root}
end
end
end
end
-- The main entry point.
function export.show(frame)
local parent_args = frame:getParent().args
local decl = {}
local word = NAMESPACE == "Template" and "elēnagon" or parent_args.word or PAGENAME
local args = {}
if not m_data[word] then
if frame.args.decl then
decl_type = frame.args.decl
else
if parent_args.c and parent_args[1] then
decl_type = parent_args.c
numbers = {parent_args[1]}
else
decl_type, numbers = export.detect_decl(word, parent_args.c)
end
end
if not decl_type then
error("Unknown declension '" .. decl_type .. "'")
end
args = require("Module:parameters").process(parent_args, m_data[decl_type].params, true)
if numbers then
for i, number in ipairs(numbers) do
args[i] = number
end
end
end
local data = {forms = {}, categories = {}}
data.head = parent_args["head"] or nil
data.no_cat = parent_args["nocat"] or parent_args["det"] or nil
-- Generate the forms
if m_data[word] then
m_data[word](parent_args, data)
else
m_data[decl_type](args, data)
end
-- Make the table
return make_table(data)
end
function make_table(data)
local function show_form(form)
if not form then
return "—"
end
local ret = {}
for key, subform in ipairs(form) do
table.insert(ret, subform)
end
return table.concat(ret, ", ")
end
local function link(term)
local links = {}
for alt in gmatch(term, "([^%s,]+)") do
if alt ~= "—" then
alt = "[[Contionary:" .. alt .. "|" .. alt .. "]]"
end
table.insert(links, alt)
end
return table.concat(links, ", ")
end
local function repl(param)
if param == "decl_type" then
return data.decl_type
elseif param == "pagename" and NAMESPACE == "Template" then
return "sylugon"
elseif param == "pagename" then
return PAGENAME
else
return show_form(data.forms[param])
end
end
local function make_cases(data, mode)
local moods, tenses = {}, {}
local ret = {}
if match(mode, "^finite") then
moods = {{"ind", "indicative"}, {"sub", "subjunctive"}, {"imp", "imperative"}}
tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"imperf", "imperfect"},
{"prf", "perfect"}, {"plu", "pluperfect"}, {"hab", "past habitual"}}
for _, mood in ipairs(moods) do
table.insert(ret, "|-\n! rowspan='7' style='background: #7AB350; width: 7em' | " .. mood[2] .. "\n")
for _, tense in ipairs(tenses) do
table.insert(ret, "|-\n! style='background: #ADE981; width: 7em' | " .. tense[2] .. "\n")
for _, number in ipairs({"sg", "pl"}) do
for i=1, 3 do
table.insert(ret, "| " .. link(show_form(data.forms[(match(mode, "%s(.*)$") == "active" and "act" or "pas") .. "_" .. mood[1] .. "_" .. tense[1] .. "_" .. tostring(i) .. number])) .. "\n")
end
end
end
end
else
end
return table.concat(ret)
end
local divframe = [=[
<div class="mw-collapsible mw-collapsed" style="border-collapse: collapse; margin: 0px 0px -1px 0px; padding: 2px; text-align: center; border: 1px solid #aaaaaa; font-size: 95%; overflow: auto; width: auto;">
<div style="min-height: 1.6em; font-weight:bold; font-size: 100%; text-align: left; background-color:#efefef; padding-left: 10px; background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), to(#DFDFDF), color-stop(0.6, #E3E3E3)); background-image: -moz-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF); background-image: -o-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);"><span class="nowrap">Declension of ''<span lang="qhv">{{{pagename}}}</span>'' ([[:Category:High Valyrian class-{{{decl_type}}} adjectives|class {{{decl_type}}}]])</span></div>
<div class="mw-collapsible-content" style="font-size: 100%;">
]=]
local final = [=[
{| style="background:#F9F9F9; text-align:center; width:100%; border-collapse: collapse;" border="1px solid #000"
|- style="background: #7AB350"
! colspan="2" rowspan="3" style="background: #508626; color: #fff; width: 7em" | a-stem
! colspan="3" | singular
! colspan="3" | plural
|- style="background: #ADE981"
! 1<sup>st</sup> person
! 2<sup>nd</sup> person
! 3<sup>rd</sup> person
! 1<sup>st</sup> person
! 2<sup>nd</sup> person
! 3<sup>rd</sup> person
|- style="background: #CEF6BD;"
! nyke
! ao
! ziry/ūja
! īlon
! jeme
! pōnta
|-
]=] .. make_cases(data, "finite active") .. [=[
|-
! style="background:#808080; height:.2em" colspan="9" |
|-
! rowspan="7" style="background: #7AB350; width: 7em" | imperative
! style="background: #ADE981; width: 7em" | present
| rowspan="3" |
|
| rowspan="3" colspan="2" |
|
| rowspan="3" |
|-
! style="background: #ADE981; width: 7em" | aorist
|
|
|-
! style="background: #ADE981; width: 7em" | future
|
|
|-
|}<ul style="margin-left:0px;"></ul>
{| style="background:#F9F9F9; text-align:center; width:100%; border-collapse: collapse;" border="1px solid #000"
|- style="background: #7AB350"
! colspan="2" style="background: #508626; width: 7em" |
! infinitive
! participle
|-
! rowspan="5" style="background: #7AB350; width: 7em" | nonfinite
! style="background: #ADE981; width: 7em" | present
|
|
|-
! style="background: #ADE981; width: 7em" | aorist
|
|
|-
! style="background: #ADE981; width: 7em" | future
|
|
|-
! style="background: #ADE981; width: 7em" | perfect
|
|
|-
! style="background: #ADE981; width: 7em" | past habitual
|
|
|-
|}</div></div>
<div class="mw-collapsible mw-collapsed" style="border-collapse: collapse; margin: 0px 0px -1px 0px; padding: 2px; text-align: center; border: 1px solid #aaaaaa; font-size: 95%; overflow: auto; width: auto;">
<div style="min-height: 1.6em; font-weight:bold; font-size: 100%; text-align: left; background-color:#efefef; padding-left: 10px; background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), to(#DFDFDF), color-stop(0.6, #E3E3E3)); background-image: -moz-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF); background-image: -o-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);"><span class="nowrap">Conjugation of ''<span lang="qhv">{{{pagenamex}}}</span>'' — passive voice</span></div>
<div class="mw-collapsible-content" style="font-size: 100%;">
{| style="background:#F9F9F9; text-align:center; width:100%; border-collapse: collapse;" border="1px solid #000"
|- style="background: #b35350"
! colspan="2" rowspan="3" style="background: #862826; color: #fff; width: 7em" | a-stem
! colspan="3" | singular
! colspan="3" | plural
|- style="background: #e88581"
! 1<sup>st</sup> person
! 2<sup>nd</sup> person
! 3<sup>rd</sup> person
! 1<sup>st</sup> person
! 2<sup>nd</sup> person
! 3<sup>rd</sup> person
|- style="background: #f5c6bd;"
! nyke
! ao
! ziry/ūja
! īlon
! jeme
! pōnta
|-
! rowspan="7" style="background: #b35350; width: 7em" | indicative
! style="background: #e88581; width: 7em" | present
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | aorist
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | future
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | imperfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | perfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | pluperfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | past habitual
|
|
|
|
|
|
|-
! style="background:#808080; height:.2em" colspan="9" |
|-
! rowspan="7" style="background: #b35350; width: 7em" | subjunctive
! style="background: #e88581; width: 7em" | present
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | aorist
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | future
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | imperfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | perfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | pluperfect
|
|
|
|
|
|
|-
! style="background: #e88581; width: 7em" | past habitual
|
|
|
|
|
|
|-
! style="background:#808080; height:.2em" colspan="9" |
|-
! rowspan="7" style="background: #b35350; width: 7em" | imperative
! style="background: #e88581; width: 7em" | present
| rowspan="3" |
|
| rowspan="3" colspan="2" |
|
| rowspan="3" |
|-
! style="background: #e88581; width: 7em" | aorist
|
|
|-
! style="background: #e88581; width: 7em" | future
|
|
|-
|}<ul style="margin-left:0px;"></ul>
{| style="background:#F9F9F9; text-align:center; width:100%; border-collapse: collapse;" border="1px solid #000"
|- style="background: #e88581"
! colspan="2" style="background: #862826; width: 7em" |
! infinitive
! participle
|-
! rowspan="5" style="background: #b35350; width: 7em" | nonfinite
! style="background: #e88581; width: 7em" | present
|
|
|-
! style="background: #e88581; width: 7em" | aorist
|
|
|-
! style="background: #e88581; width: 7em" | future
|
|
|-
! style="background: #e88581; width: 7em" | perfect
|
|
|-
! style="background: #e88581; width: 7em" | past habitual
|
|
|-
|}
]=]
local wikicode = divframe .. final .. "</div></div>"
return (gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. (data.no_cat and "" or require("Module:utilities").format_categories(data.categories, lang))
end
return export