Module:xchc-noun: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
end | end | ||
local function gsubh(word, o, e, def) | local function gsubh(word, o, e, r, u, def) | ||
local backh = | local ipa = m_ipa.crux(word) | ||
local repl = {["ɛ"] = e, ["ɔ"] = o} | local backh = ipa:match("ɛ") and "ɛ" or ipa:match("ɔ") and "ɔ" or nil | ||
return word:gsub(" | local roundh = ipa:match("[yuɔo]") and "r" or ipa:match("[ie]") and "u" or nil | ||
local repl = {["ɛ"] = e, ["ɔ"] = o, ["r"] = r, ["u"] = u} | |||
return not r and word:gsub("B", repl[backh] or def) or word:gsub("R", repl[roundh] or def) | |||
end | end | ||
Line 53: | Line 55: | ||
or wordpron(word):me("[ɛa]") and "н" | or wordpron(word):me("[ɛa]") and "н" | ||
or wordpron(word):me("[uoɔ]") and "ӈ" | or wordpron(word):me("[uoɔ]") and "ӈ" | ||
or gsubh(" | or gsubh("Bӈ","о̆","э̆",nil,nil,"о̆") | ||
data.pl = { | data.pl = { | ||
["i"] = wordpron(word):me(voiceless) and gsubh(" | ["i"] = wordpron(word):me(voiceless) and gsubh("фBд","ө","э",nil,nil,"э") or gsubh("вBд","ө","э",nil,nil,"э"), | ||
["a"] = wordpron(word):me(voiceless) and gsubh(" | ["a"] = wordpron(word):me(voiceless) and gsubh("шBд","о̆","э̆",nil,nil,"о̆") or gsubh("жBд","о̆","э̆",nil,nil,"о̆"), | ||
} | } | ||
Line 106: | Line 108: | ||
local cases = {"nominative", "accusative", "dative", "genitive", "instrumental", "prosecutive", "adessive<br/>comitative", "ablative<br/>elative", "illative<br/>allative"} | local cases = {"nominative", "accusative", "dative", "genitive", "instrumental", "prosecutive", "adessive<br/>comitative", "ablative<br/>elative", "illative<br/>allative"} | ||
local numbers = {"singular", "paucal", "plural"} | local numbers = {"singular", "paucal", "plural"} | ||
local ret = {} | local ret = {} | ||
Line 115: | Line 116: | ||
end | end | ||
for _, | for _, number in ipairs(numbers) do | ||
table.insert(ret, "! " .. | table.insert(ret, "! " .. number .. "\n") | ||
end | end | ||
table.insert(ret, "|-\n") | table.insert(ret, "|-\n") | ||
Line 124: | Line 125: | ||
table.insert(ret, "|-\n") | table.insert(ret, "|-\n") | ||
for _, case in ipairs(cases) do | for _, case in ipairs(cases) do | ||
local c_sh = case:sub(1,3) | |||
for _, number in ipairs(numbers) do | |||
local n_sh = number:sub(1,3) | |||
local decl = { | |||
["nom"] = "", | |||
["acc"] = w_number[n_sh]:me(vowel) and "дза" or w_number[n_sh]:me(voiced) and "да" or "та", | |||
["dat"] = w_number[n_sh]:me(vowel) and "ша" or w_number[n_sh]:me(voiced) and "за" or "са", | |||
["gen"] = "ля", | |||
["ins"] = w_number[n_sh]:me(vowel) and "лза" or gsubh("Bлз","ө", "э", nil, nil, "ө"), | |||
["pro"] = gsubh("сBц","ө", "э", nil, nil, "ө"), | |||
["ade"] = "ляц", | |||
["abl"] = gsubh("сB",nil,nil,"u","i","u") .. gsubh("шR","о̄̆","э̄̆",nil,nil,"э̄̆"), | |||
["pro"] = gsubh("кFб","ү","ы",nil,nil,"ы"), | |||
} | |||
table.insert(ret, "| " .. show_form(w_number[n_sh] .. decl[c_sh])) | |||
end | |||
table.insert(ret, "\n") | |||
end | end | ||
Revision as of 15:52, 7 December 2023
- The following documentation is located at Module:xchc-noun/doc.[edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
local sub = mw.ustring.sub
local find = mw.ustring.find
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local split = mw.text.split
local gsplit = mw.text.gsplit
local m_tr = require('Module:xchc-translit')
local m_ipa = require('Module:xchc-pron')
local lang = require('Module:languages').getByCode("xchc")
local export = {}
local voiced = "mnɲŋbdɡvzʒɣlr"
local voiceless = "ptkfsʃxh"
local consonant = "[" .. voiced .. voiceless .. "]"
local vowel = "[aeɛioɔuyø]"
local function me(foo, pat)
return foo:match(pat .. "ː?$")
end
local function gsubh(word, o, e, r, u, def)
local ipa = m_ipa.crux(word)
local backh = ipa:match("ɛ") and "ɛ" or ipa:match("ɔ") and "ɔ" or nil
local roundh = ipa:match("[yuɔo]") and "r" or ipa:match("[ie]") and "u" or nil
local repl = {["ɛ"] = e, ["ɔ"] = o, ["r"] = r, ["u"] = u}
return not r and word:gsub("B", repl[backh] or def) or word:gsub("R", repl[roundh] or def)
end
function export.show(frame)
local parent_args = frame:getParent().args
local numbers = {}
local decl = {}
local g = NAMESPACE == "Template" and "a" or parent_args[1]
local word = NAMESPACE == "Template" and "өра̄" or parent_args["word"] or PAGENAME
local unc = parent_args["unc"] or false
local args = {}
if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end
local function wordpron(w)
return m_ipa.crux(w)
end
local data = {}
data.word = word
data.g = g
data.sg = word
data.pau = wordpron(word):me("[eiøy]") and "ч"
or wordpron(word):me("[ɛa]") and "н"
or wordpron(word):me("[uoɔ]") and "ӈ"
or gsubh("Bӈ","о̆","э̆",nil,nil,"о̆")
data.pl = {
["i"] = wordpron(word):me(voiceless) and gsubh("фBд","ө","э",nil,nil,"э") or gsubh("вBд","ө","э",nil,nil,"э"),
["a"] = wordpron(word):me(voiceless) and gsubh("шBд","о̆","э̆",nil,nil,"о̆") or gsubh("жBд","о̆","э̆",nil,nil,"о̆"),
}
end
function make_table(data)
local function show_form(form)
if not form then
return "—"
end
local ret = {}
for _, 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
alt = term == "—" and term or "[[Contionary:" .. alt .. "|" .. alt .. "]]"
table.insert(links, alt)
end
return table.concat(links, ", ")
end
local function repl(param)
if param == "decl_type" then
return data.decl_type == "irregular" and data.decl_type or "''" .. data.decl_type .. "''-declension"
elseif param == "title" then
return NAMESPACE == "Template" and "sivi" or data.alt or PAGENAME
elseif param == "word" and NAMESPACE == "Template" then
return "sivi"
elseif param == "word" then
return data.head
elseif param == "gender" then
return (data.g == "i" and "inanimate" or "animate")
else
return show_form(data.forms[param])
end
end
function make_cases(data)
local w_number = {["si"] = data.word .. data.sg, ["pa"] = data.word .. data.pa, ["pl"] = data.word .. data.pl}
local cases = {"nominative", "accusative", "dative", "genitive", "instrumental", "prosecutive", "adessive<br/>comitative", "ablative<br/>elative", "illative<br/>allative"}
local numbers = {"singular", "paucal", "plural"}
local ret = {}
if data.unc then
numbers[2], numbers[3], numbers_sh[2], numbers_sh[3] = nil, nil, nil, nil
end
for _, number in ipairs(numbers) do
table.insert(ret, "! " .. number .. "\n")
end
table.insert(ret, "|-\n")
for _, case in ipairs(cases) do
table.insert(ret, "! " .. case .. "\n")
end
table.insert(ret, "|-\n")
for _, case in ipairs(cases) do
local c_sh = case:sub(1,3)
for _, number in ipairs(numbers) do
local n_sh = number:sub(1,3)
local decl = {
["nom"] = "",
["acc"] = w_number[n_sh]:me(vowel) and "дза" or w_number[n_sh]:me(voiced) and "да" or "та",
["dat"] = w_number[n_sh]:me(vowel) and "ша" or w_number[n_sh]:me(voiced) and "за" or "са",
["gen"] = "ля",
["ins"] = w_number[n_sh]:me(vowel) and "лза" or gsubh("Bлз","ө", "э", nil, nil, "ө"),
["pro"] = gsubh("сBц","ө", "э", nil, nil, "ө"),
["ade"] = "ляц",
["abl"] = gsubh("сB",nil,nil,"u","i","u") .. gsubh("шR","о̄̆","э̄̆",nil,nil,"э̄̆"),
["pro"] = gsubh("кFб","ү","ы",nil,nil,"ы"),
}
table.insert(ret, "| " .. show_form(w_number[n_sh] .. decl[c_sh]))
end
table.insert(ret, "\n")
end
return table.concat(ret)
end
local navframe = [=[
<div class="mw-collapsible" style="border-collapse: collapse; margin: 0px 0px -1px 0px; padding: 2px; border: 1px solid #aaaaaa; text-align: center; font-size: 95%; overflow: auto; min-width: 70em; display:inline-block;">
<div style="min-height: 1.6em; font-size: 100%; text-align: left; background-color:#DEE9FB; 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);">'''''{title}'''''<span style="font-weight:normal;">{after_title}</span> </div>
<div class="mw-collapsible-content" style="font-size: 100%;">
]=]
end
return export