Module:qhv-verb: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
 
(77 intermediate revisions by the same user not shown)
Line 3: Line 3:
local find = mw.ustring.find
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gmatch = mw.ustring.gmatch
local match = mw.ustring.match
local u = mw.ustring.char
local u = mw.ustring.char


Line 9: Line 10:
local PAGENAME = mw.title.getCurrentTitle().text
local PAGENAME = mw.title.getCurrentTitle().text
local NAMESPACE = mw.title.getCurrentTitle().nsText
local NAMESPACE = mw.title.getCurrentTitle().nsText
local consonants = "[bdghjklmnpqrstvzñ]"


local lang = require("Module:languages").getByCode("qhv")
local lang = require("Module:languages").getByCode("qhv")
Line 16: Line 18:
local endings = {
local endings = {
["[lr]"] = "liquid",
["[lr]"] = "liquid",
["[ptkq]"] = "voiceless-stop",
["[ptkqbdg]"] = "stop",
["[mn]"] = "nasal",
["[mn]"] = "nasal",
["[bdg]"] = "voiced-stop",
["ñ"] = "palatal",
["lj"] = "voiceless-stop", ["ñ"] = "voiceless-stop",
["[hszvj]"] = "fricative",
["[^l][hszvj]"] = "fricative", ["gh"] = "fricative",
["egon"] = "e", ["igon"] = "i", ["ogon"] = "o", ["ugon"] = "u",
}
}


function export.detect_decl(word, class)
function export.detect_decl(word, class)
local root = sub(word, 1, -5)
root = sub(word, 1, -5)
tv = sub(word, -4, -4)
if class then
if class then
local decl = class
local decl = class
return decl, {sub(root, 1, (sub(root, -2) == ("lj" or "gh") and -3 or -2))}
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)}
elseif match(word, "urnegon$") or root == "urn" then
return "-urnegon", {root}
elseif find(tv, "[eiou]") or m_data.astems[word] then
return "vowel", {root}
elseif match(word, "[^l]ilagon$") or root == "il" then
return "-ilagon", {root}
elseif match(word, "[āeē]mm?agon$") and word ~= "jemagon" and word ~= "uēmagon" then
return "-emagon", {root}
elseif match(root, "lj$") then return "palatal", {root}
elseif match(root, "gh$") then return "fricative", {root}
elseif match(root, consonants .. "+" .. consonants .. "$") then return "cluster", {root}
else
else
for ending, decl in pairs(endings) do
for ending, decl in pairs(endings) do
if find(root, ending .. "$") then
if find(root, ending .. "$") then
return decl, {sub(root, 1, -(#ending + 1))}
return decl, {root}
elseif find(word, ending .. "$") then
return decl, {sub(root, 1, -2)}
else return "fricative", {root}
end
end
end
end
Line 47: Line 55:
local decl = {}
local decl = {}
local word = NAMESPACE == "Template" and "elēnagon" or parent_args.word or PAGENAME
local word = NAMESPACE == "Template" and "sylugon" or parent_args.word or PAGENAME
local args = {}
local args = {}


Line 62: Line 70:
end
end
if not decl_type then
-- if not decl_type then decl_type, numbers = "fricative", {root} end
error("Unknown declension '" .. decl_type .. "'")
end
args = require("Module:parameters").process(parent_args, m_data[decl_type].params, true)
args = require("Module:parameters").process(parent_args, m_data[decl_type].params, true)
Line 77: Line 83:
local data = {forms = {}, categories = {}}
local data = {forms = {}, categories = {}}
data.head = parent_args["head"] or nil
data.head = parent_args["head"] or parent_args["word"] or nil
data.no_cat = parent_args["nocat"] or parent_args["det"] or nil
data.no_cat = parent_args["nocat"] or parent_args["det"] or nil
data.thematic_vowel = tv
data.intr = parent_args["intr"] or parent_args[1] or nil
if data.intr and not data.no_cat then table.insert(data.categories, "High Valyrian intransitive verbs") end
-- Generate the forms
-- Generate the forms
Line 92: Line 101:


function make_table(data)
function make_table(data)
local function g_tooltip(n1, n2)
return require('Module:getn').format_list({n1, n2})
end
local function show_form(form)
local function show_form(form)
if not form then
if not form then
Line 125: Line 130:
return data.decl_type
return data.decl_type
elseif param == "pagename" and NAMESPACE == "Template" then
elseif param == "pagename" and NAMESPACE == "Template" then
return "rōva"
return "sylugon"
elseif param == "pagename" then
elseif param == "pagename" then
return PAGENAME
return data.head or PAGENAME
else
else
return show_form(data.forms[param])
return show_form(data.forms[param])
Line 133: Line 138:
end
end


local function make_cases(data, pre)
local function make_cases(data, mode)
local cases = {"nominative", "accusative", "genitive", "dative", "locative", "instrumental", "comitative", "vocative"}
local moods, tenses = {}, {}
local genders = data.decl_type == "I" and {"lunar", "solar", "terrestrial", "aquatic"} or {"lunar", "terrestrial"}
local ret = {}
local ret = {}
for _, case in ipairs(cases) do
if match(mode, "^finite") then
local case_short = sub(case, 1, 3)
moods = {{"ind", "indicative"}, {"sub", "subjunctive"}}
table.insert(ret, "|- style=\"background-color: #fdfdfd;\" \n! ! style=\"background-color: #FFB976; width:" .. (data.decl_type == "I" and "11.5%" or "16.68%") .. ";\"|" .. case .. "\n")
tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"imperf", "imperfect"},
for _, gender in ipairs(genders) do
  {"prf", "perfect"}, {"plu", "pluperfect"}, {"hab", "past habitual"}}
local g_short = sub(gender, 1, 1)
for _, number in ipairs({"sg", "pl"}) do
for _, mood in ipairs(moods) do
table.insert(ret, "| style=\"width:" .. (data.decl_type == "I" and "10.10%" or "20.83%") .. ";\" | " .. link(show_form(data.forms[(pre and "" or "post_") .. case_short .. "_" .. g_short .. "_" .. number])) .. "\n")
table.insert(ret, "|-\n! rowspan='8' 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")
if (tense[1] == "hab") and (i == 3) and (number == "pl") then table.insert(ret, "|-\n! style='background:#808080; height:.2em' colspan='9' |\n") end
end
end
end
end
else
tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"prf", "perfect"}, {"hab", "past habitual"}}
for _, tense in ipairs(tenses) do
table.insert(ret, "|-\n! style='background: #ADE981; width: 7em' | " .. tense[2] .. "\n")
for _, form in ipairs({"inf", "part"}) do
table.insert(ret, "| " .. link(show_form(data.forms[(match(mode, "%s(.*)$") == "active" and "act" or "pas") .. "_" .. form .. "_" .. tense[1]])) .. "\n")
end
end
end
end
Line 151: Line 171:
end
end
local divframe = [=[
local divframe_active = [=[
<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 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 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>'' — active voice</span></div>
<div class="mw-collapsible-content" style="font-size: 100%;">
<div class="mw-collapsible-content" style="font-size: 100%;">
]=]
]=]
local prepositive = [=[
local active = [=[
{| border="1px solid white" style="border-collapse: collapse; background:#ffffff; width:100%; text-align:center;" cellspacing="1" cellpadding="2"
|- style="background-color: #FFB976; text-align:center;"
! rowspan="2" style="background-color: #E57942;" | Prepositive
! colspan="2" | lunar]=] .. (data.decl_type ~= "I" and " and solar" or "") .. (data.decl_type == "I" and "\n! colspan=\"2\" | solar" or "") .. [=[&#x200B;
! colspan="2" | terrestrial]=] .. (data.decl_type ~= "I" and " and aquatic" or "") .. (data.decl_type == "I" and "\n! colspan=\"2\" | aquatic" or "") .. [=[&#x200B;
|- style="background-color: #FFD79B; font-size: 95%"
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. (data.decl_type ~= "I" and "" or [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa")) .. [=[&#x200B;
|- ]=] .. make_cases(data, true) .. [=[
|}<ul style="margin-left:0px;"></ul>
]=]
local postpositive = [=[
{| border="1px solid white" style="border-collapse: collapse; background:#ffffff; width:100%; text-align:center;" cellspacing="1" cellpadding="2"
|- style="background-color: #FFB976; text-align:center;"
! rowspan="2" style="background-color: #E57942;" | Postpositive
! colspan="2" ]=] .. (data.decl_type ~= "I" and "style=\"min-width: 20.83%;\" | lunar and solar" or "| lunar") .. (data.decl_type == "I" and "\n! colspan=\"2\" | solar" or "") .. [=[&#x200B;
! colspan="2" ]=] .. (data.decl_type ~= "I" and "style=\"min-width: 20.83%;\" | terrestrial and aquatic" or "| terrestrial") .. (data.decl_type == "I" and "\n! colspan=\"2\" | aquatic" or "") .. [=[&#x200B;
|- style="background-color: #FFD79B; font-size: 95%"
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. (data.decl_type ~= "I" and "" or [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa") .. [=[&#x200B;
! ]=] .. g_tooltip("s", "ol") .. [=[&#x200B;
! ]=] .. g_tooltip("p", "pa")) .. [=[&#x200B;
|- ]=] .. make_cases(data, false) .. [=[
|}
]=]
local final = [=[
<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">{{{pagename}}}</span>'' — active 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:#F9F9F9; text-align:center; width:100%; border-collapse: collapse;" border="1px solid #000"
|- style="background: #7AB350"
|- style="background: #7AB350"
! colspan="2" rowspan="3" style="background: #508626; color: #fff; width: 7em" | a-stem
! colspan="2" rowspan="3" style="background: #508626; color: #fff; width: 7em" | [[:Category:High Valyrian ]=] .. gsub(data.decl_type, "%s", "-") .. [=[ verbs|<span style="color: #fff; text-decoration: inherit; -moz-text-decoration-color: #fff; text-decoration-color: #fff;">{{{decl_type}}}</span>]]
! colspan="3" | singular
! colspan="3" | singular
! colspan="3" | plural
! colspan="3" | plural
Line 219: Line 198:
! pōnta
! pōnta
|-
|-
! rowspan="7" style="background: #7AB350; width: 7em" | indicative
]=] .. make_cases(data, "finite active") .. [=[
! style="background: #ADE981; width: 7em" | present
|
|
|
|
|
|
|-
|-
! style="background: #ADE981; width: 7em" | aorist
! rowspan="7" style="background: #7AB350; width: 7em" | imperative
|
|
|
|
|
|
|-
! style="background: #ADE981; width: 7em" | future
|
|
|
|
|
|
|-
! style="background: #ADE981; width: 7em" | imperfect
|
|
|
|
|
|
|-
! style="background: #ADE981; width: 7em" | perfect
|
|
|
|
|
|
|-
! style="background: #ADE981; width: 7em" | pluperfect
|
|
|
|
|
|
|-
! style="background: #ADE981; width: 7em" | past habitual
|
|
|
|
|
|
|-
! style="background:#808080; height:.2em" colspan="9" |
|-
! rowspan="7" style="background: #7AB350; width: 7em" | subjunctive
! style="background: #ADE981; width: 7em" | present
! style="background: #ADE981; width: 7em" | present
|  
| rowspan="3" | —
|  
| ]=] .. link(show_form(data.forms["act_imp_prs_2sg"])) .. [=[&nbsp;
|  
| rowspan="3" colspan="2" | —
|  
| ]=] .. link(show_form(data.forms["act_imp_prs_2pl"])) .. [=[&nbsp;
|  
| rowspan="3" |
|  
|-
|-
! style="background: #ADE981; width: 7em" | aorist
! style="background: #ADE981; width: 7em" | aorist
|  
| ]=] .. link(show_form(data.forms["act_imp_aor_2sg"])) .. [=[&nbsp;
|  
| ]=] .. link(show_form(data.forms["act_imp_aor_2pl"])) .. [=[&nbsp;
|
|
|
|
|-
|-
! style="background: #ADE981; width: 7em" | future
! style="background: #ADE981; width: 7em" | future
|
| ]=] .. link(show_form(data.forms["act_imp_fut_2sg"])) .. [=[&nbsp;
|  
| ]=] .. link(show_form(data.forms["act_imp_fut_2pl"])) .. [=[&nbsp;
|
|
|
|
|-
|-
! style="background: #ADE981; width: 7em" | imperfect
|}<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" | &nbsp;
|
! infinitive
|
! participle
|
|-
|-
! style="background: #ADE981; width: 7em" | perfect
! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
|
]=] .. make_cases(data, "nonfinite active") .. [=[
|
|
|
|
|
|-
|-
! style="background: #ADE981; width: 7em" | pluperfect
|}</div></div>
|  
]=]
|  
|  
local divframe_passive = [=[
|  
<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">]=] .. link(show_form(data.forms["pas_inf_prs"])) .. [=[</span>'' — passive voice</span></div>
|
<div class="mw-collapsible-content" style="font-size: 100%;">
]=]
local passive = [=[
{| 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" | [[:Category:High Valyrian ]=] .. gsub(data.decl_type, "%s", "-") .. [=[ verbs|<span style="color: #fff; text-decoration: inherit; -moz-text-decoration-color: #fff; text-decoration-color: #fff;">{{{decl_type}}}</span>]]
! 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
|-
|-
! style="background: #ADE981; width: 7em" | past habitual
]=] .. make_cases(data, "finite passive") .. [=[
|
|
|
|
|
|
|-
! style="background:#808080; height:.2em" colspan="9" |
|-
|-
! rowspan="7" style="background: #7AB350; width: 7em" | imperative
! rowspan="7" style="background: #7AB350; width: 7em" | imperative
! style="background: #ADE981; width: 7em" | present
! style="background: #ADE981; width: 7em" | present
| rowspan="3" |  
| rowspan="3" |
|  
| ]=] .. link(show_form(data.forms["pas_imp_prs_2sg"])) .. [=[&nbsp;
| rowspan="3" colspan="2" |  
| rowspan="3" colspan="2" |
|  
| ]=] .. link(show_form(data.forms["pas_imp_prs_2pl"])) .. [=[&nbsp;
| rowspan="3" |  
| rowspan="3" |
|-
|-
! style="background: #ADE981; width: 7em" | aorist
! style="background: #ADE981; width: 7em" | aorist
|  
| ]=] .. link(show_form(data.forms["pas_imp_aor_2sg"])) .. [=[&nbsp;
|  
| ]=] .. link(show_form(data.forms["pas_imp_aor_2pl"])) .. [=[&nbsp;
|-
|-
! style="background: #ADE981; width: 7em" | future
! style="background: #ADE981; width: 7em" | future
|  
| ]=] .. link(show_form(data.forms["pas_imp_fut_2sg"])) .. [=[&nbsp;
|  
| ]=] .. link(show_form(data.forms["pas_imp_fut_2pl"])) .. [=[&nbsp;
|-
|-
|}<ul style="margin-left:0px;"></ul>
|}<ul style="margin-left:0px;"></ul>
Line 357: Line 278:
|- style="background: #7AB350"
|- style="background: #7AB350"
! colspan="2" style="background: #508626; width: 7em" | &nbsp;
! colspan="2" style="background: #508626; width: 7em" | &nbsp;
! 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" | &nbsp;
! infinitive
! infinitive
! participle
! participle
|-
|-
! rowspan="5" style="background: #b35350; width: 7em" | nonfinite
! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
! style="background: #e88581; width: 7em" | present
]=] .. make_cases(data, "nonfinite passive") .. [=[
|
|
|-
! 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
|
|
|-
|-
|}</div></div>
|}</div></div>
]=]
]=]
local wikicode = divframe_active .. active .. (not data.intr and divframe_passive .. passive or "")
local wikicode = divframe .. prepositive .. postpositive .. "</div></div>"
return (gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. (data.no_cat and "" or require("Module:utilities").format_categories(data.categories, lang))
return (gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. (data.no_cat and "" or require("Module:utilities").format_categories(data.categories, lang))

Latest revision as of 18:48, 17 July 2021



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 consonants = "[bdghjklmnpqrstvzñ]"

local lang = require("Module:languages").getByCode("qhv")

local export = {}

local endings = {
	["[lr]"] = "liquid",
	["[ptkqbdg]"] = "stop",
	["[mn]"] = "nasal",
	["ñ"] = "palatal",
	["[hszvj]"] = "fricative",
}

function export.detect_decl(word, class)
	root  = sub(word, 1, -5)
	tv = sub(word, -4, -4)
	if class then
		local decl = class
		return decl, {sub(root, 1, (sub(root, -2) == ("lj" or "gh") and -3 or -2))}
	elseif match(word, "urnegon$") or root == "urn" then
		return "-urnegon", {root}
	elseif find(tv, "[eiou]") or m_data.astems[word] then
		return "vowel", {root}
	elseif match(word, "[^l]ilagon$") or root == "il" then
		return "-ilagon", {root}
	elseif match(word, "[āeē]mm?agon$") and word ~= "jemagon" and word ~= "uēmagon" then
		return "-emagon", {root}
	elseif match(root, "lj$") then return "palatal", {root}
	elseif match(root, "gh$") then return "fricative", {root}
	elseif match(root, consonants .. "+" .. consonants .. "$") then return "cluster", {root}
	else
		for ending, decl in pairs(endings) do
			if find(root, ending .. "$") then
				return decl, {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 "sylugon" 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 decl_type, numbers = "fricative", {root} 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 parent_args["word"] or nil
	data.no_cat = parent_args["nocat"] or parent_args["det"] or nil
	data.thematic_vowel = tv
	data.intr = parent_args["intr"] or parent_args[1] or nil
	if data.intr and not data.no_cat then table.insert(data.categories, "High Valyrian intransitive verbs") end
	
	-- 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 data.head or 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"}}
			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='8' 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")
							if (tense[1] == "hab") and (i == 3) and (number == "pl") then table.insert(ret, "|-\n! style='background:#808080; height:.2em' colspan='9' |\n") end
						end
					end
				end
			end
		else 
			tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"prf", "perfect"}, {"hab", "past habitual"}}
			for _, tense in ipairs(tenses) do
				table.insert(ret, "|-\n! style='background: #ADE981; width: 7em' | " .. tense[2] .. "\n")
				for _, form in ipairs({"inf", "part"}) do
					table.insert(ret, "| " .. link(show_form(data.forms[(match(mode, "%s(.*)$") == "active" and "act" or "pas") .. "_" .. form .. "_" .. tense[1]])) .. "\n")
				end
			end
		end
		return table.concat(ret)
	end
	
	local divframe_active = [=[
	<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>''  — active voice</span></div>
	<div class="mw-collapsible-content" style="font-size: 100%;">
	]=]
	
	local active = [=[
		{| 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" | [[:Category:High Valyrian ]=] .. gsub(data.decl_type, "%s", "-") .. [=[ verbs|<span style="color: #fff; text-decoration: inherit; -moz-text-decoration-color: #fff; text-decoration-color: #fff;">{{{decl_type}}}</span>]]
		! 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") .. [=[
		|-
		! rowspan="7" style="background: #7AB350; width: 7em" | imperative
		! style="background: #ADE981; width: 7em" | present
		| rowspan="3" | —
		| ]=] .. link(show_form(data.forms["act_imp_prs_2sg"])) .. [=[&nbsp;
		| rowspan="3" colspan="2" | —
		| ]=] .. link(show_form(data.forms["act_imp_prs_2pl"])) .. [=[&nbsp;
		| rowspan="3" | —
		|-
		! style="background: #ADE981; width: 7em" | aorist
		| ]=] .. link(show_form(data.forms["act_imp_aor_2sg"])) .. [=[&nbsp;
		| ]=] .. link(show_form(data.forms["act_imp_aor_2pl"])) .. [=[&nbsp;
		|-
		! style="background: #ADE981; width: 7em" | future
		| ]=] .. link(show_form(data.forms["act_imp_fut_2sg"])) .. [=[&nbsp;
		| ]=] .. link(show_form(data.forms["act_imp_fut_2pl"])) .. [=[&nbsp;
		|-
		|}<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" | &nbsp;
		! infinitive
		! participle
		|-
		! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
		]=] .. make_cases(data, "nonfinite active") .. [=[
		|-
		|}</div></div>
	]=]
	
	local divframe_passive = [=[
	<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">]=] .. link(show_form(data.forms["pas_inf_prs"])) .. [=[</span>'' — passive voice</span></div>
	<div class="mw-collapsible-content" style="font-size: 100%;">
	]=]
	
	local passive = [=[
		{| 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" | [[:Category:High Valyrian ]=] .. gsub(data.decl_type, "%s", "-") .. [=[ verbs|<span style="color: #fff; text-decoration: inherit; -moz-text-decoration-color: #fff; text-decoration-color: #fff;">{{{decl_type}}}</span>]]
		! 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 passive") .. [=[
		|-
		! rowspan="7" style="background: #7AB350; width: 7em" | imperative
		! style="background: #ADE981; width: 7em" | present
		| rowspan="3" | —
		| ]=] .. link(show_form(data.forms["pas_imp_prs_2sg"])) .. [=[&nbsp;
		| rowspan="3" colspan="2" | —
		| ]=] .. link(show_form(data.forms["pas_imp_prs_2pl"])) .. [=[&nbsp;
		| rowspan="3" | —
		|-
		! style="background: #ADE981; width: 7em" | aorist
		| ]=] .. link(show_form(data.forms["pas_imp_aor_2sg"])) .. [=[&nbsp;
		| ]=] .. link(show_form(data.forms["pas_imp_aor_2pl"])) .. [=[&nbsp;
		|-
		! style="background: #ADE981; width: 7em" | future
		| ]=] .. link(show_form(data.forms["pas_imp_fut_2sg"])) .. [=[&nbsp;
		| ]=] .. link(show_form(data.forms["pas_imp_fut_2pl"])) .. [=[&nbsp;
		|-
		|}<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" | &nbsp;
		! infinitive
		! participle
		|-
		! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
		]=] .. make_cases(data, "nonfinite passive") .. [=[
		|-
		|}</div></div>
	]=]
	
	local wikicode = divframe_active .. active .. (not data.intr and divframe_passive .. passive or "")
	
	return (gsub(wikicode, "{{{([a-z0-9_]+)}}}", repl)) .. (data.no_cat and "" or require("Module:utilities").format_categories(data.categories, lang))
end


return export