Module:qhv-verb: Difference between revisions

No edit summary
No edit summary
 
(41 intermediate revisions by the same user not shown)
Line 10: 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 17: Line 18:
local endings = {
local endings = {
["[lr]"] = "liquid",
["[lr]"] = "liquid",
["[ptkq]"] = "voiceless-stop",
["[ptkqbdg]"] = "stop",
["[mn]"] = "nasal",
["[mn]"] = "nasal",
["[bdg]"] = "voiced-stop",
["ñ"] = "palatal",
["lj"] = "palatal", ["ñ"] = "palatal",
["[hszvj]"] = "fricative",
["[aeiou]"] = "vowel",
["[^l][hszvj]"] = "fricative", ["gh"] = "fricative",
}
}


function export.detect_decl(word, class)
function export.detect_decl(word, class)
local root = sub(word, 1, -4)
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 find(root, "[eiou]$") or m_data.astems[word] then return "vowel", {sub(root, 1, -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}
else return "fricative", {root}
end
end
end
end
Line 61: 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 76: 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 = sub(word, -4, -4)
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 123: Line 132:
return "sylugon"
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 134: Line 143:
if match(mode, "^finite") then
if match(mode, "^finite") then
moods = {{"ind", "indicative"}, {"sub", "subjunctive"}, {"imp", "imperative"}}
moods = {{"ind", "indicative"}, {"sub", "subjunctive"}}
tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"imperf", "imperfect"},
tenses = {{"prs", "present"}, {"aor", "aorist"}, {"fut", "future"}, {"imperf", "imperfect"},
  {"prf", "perfect"}, {"plu", "pluperfect"}, {"hab", "past habitual"}}
  {"prf", "perfect"}, {"plu", "pluperfect"}, {"hab", "past habitual"}}
for _, mood in ipairs(moods) do
for _, mood in ipairs(moods) do
table.insert(ret, "|-\n! rowspan='8' style='background: #7AB350; width: 7em' | " .. mood[2] .. "\n")
table.insert(ret, "|-\n! rowspan='8' style='background: #7AB350; width: 7em' | " .. mood[2] .. "\n")
for _, tense in ipairs(tenses) do
for _, tense in ipairs(tenses) do
table.insert(ret, "|-\n! style='background: #ADE981; width: 7em' | " .. tense[2] .. "\n")
table.insert(ret, "|-\n! style='background: #ADE981; width: 7em' | " .. tense[2] .. "\n")
for _, number in ipairs({"sg", "pl"}) do
for _, number in ipairs({"sg", "pl"}) do
for i=1, 3 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")
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
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
end
end
end
end
else  
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
return table.concat(ret)
return table.concat(ret)
Line 165: Line 180:
{| 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 188: Line 203:
! style="background: #ADE981; width: 7em" | present
! style="background: #ADE981; width: 7em" | present
| rowspan="3" | —
| rowspan="3" | —
| ]=] .. link(show_form(data.forms["act_imp_prs_2sg"])) .. [=[
| ]=] .. link(show_form(data.forms["act_imp_prs_2sg"])) .. [=[&nbsp;
| rowspan="3" colspan="2" | —
| rowspan="3" colspan="2" | —
| ]=] .. link(show_form(data.forms["act_imp_prs_2pl"])) .. [=[
| ]=] .. link(show_form(data.forms["act_imp_prs_2pl"])) .. [=[&nbsp;
| rowspan="3" | —
| rowspan="3" | —
|-
|-
! style="background: #ADE981; width: 7em" | aorist
! style="background: #ADE981; width: 7em" | aorist
| rowspan="3" | —
| ]=] .. link(show_form(data.forms["act_imp_aor_2sg"])) .. [=[&nbsp;
| ]=] .. link(show_form(data.forms["act_imp_aor_2sg"])) .. [=[
| ]=] .. link(show_form(data.forms["act_imp_aor_2pl"])) .. [=[&nbsp;
| rowspan="3" colspan="2" | —
| ]=] .. link(show_form(data.forms["act_imp_aor_2pl"])) .. [=[
| rowspan="3" | —
|-
|-
! style="background: #ADE981; width: 7em" | future
! style="background: #ADE981; width: 7em" | future
| rowspan="3" | —
| ]=] .. link(show_form(data.forms["act_imp_fut_2sg"])) .. [=[&nbsp;
| ]=] .. link(show_form(data.forms["act_imp_fut_2sg"])) .. [=[
| ]=] .. link(show_form(data.forms["act_imp_fut_2pl"])) .. [=[&nbsp;
| rowspan="3" colspan="2" | —
| ]=] .. link(show_form(data.forms["act_imp_fut_2pl"])) .. [=[
| rowspan="3" | —
|-
|-
|}<ul style="margin-left:0px;"></ul>
|}<ul style="margin-left:0px;"></ul>
Line 214: Line 223:
! participle
! participle
|-
|-
! rowspan="5" style="background: #7AB350; width: 7em" | nonfinite
! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
! style="background: #ADE981; width: 7em" | present
]=] .. make_cases(data, "nonfinite active") .. [=[
|
|
|-
! 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></div>
Line 245: Line 236:
local passive = [=[
local passive = [=[
{| 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 269: Line 260:
! 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 290: Line 281:
! participle
! participle
|-
|-
! rowspan="5" style="background: #7AB350; width: 7em" | nonfinite
! rowspan="6" style="background: #7AB350; width: 7em" | nonfinite
! style="background: #ADE981; width: 7em" | present
]=] .. make_cases(data, "nonfinite passive") .. [=[
|
|
|-
! 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></div>
]=]
]=]
local wikicode = divframe_active .. active .. (not data.intr and divframe_passive .. passive or "")
local wikicode = divframe_active .. active .. divframe_passive .. passive
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))