Module:xchc-noun: Difference between revisions
No edit summary |
No edit summary |
||
| (101 intermediate revisions by the same user not shown) | |||
| Line 10: | Line 10: | ||
local m_tr = require('Module:xchc-translit') | local m_tr = require('Module:xchc-translit') | ||
local m_ipa = require('Module:xchc-pron') | local m_ipa = require('Module:xchc-pron') | ||
local c = require("Module:languages/data").chars | |||
local lang = require('Module:languages').getByCode("xchc") | local lang = require('Module:languages').getByCode("xchc") | ||
| Line 17: | Line 19: | ||
local export = {} | local export = {} | ||
local voiced = "mnɲŋbdɡvzʒɣlr" | local voiced = "мньӈбдгвзжғлрй" --"mnɲŋbdɡvzʒɣlr" | ||
local voiceless = "ptkfsʃxh" | local voiceless = "пткфсшӀчц" --"ptkfsʃxh" | ||
local consonant = "[" .. voiced .. voiceless .. "]" | local consonant = "[" .. voiced .. voiceless .. "]" | ||
local vowel = "[aeɛioɔuyø]" | local vowel = "[ыиэеаяүөуюоёӯӣɜɔ]" --"[aeɛioɔuyø]" | ||
local genders = {["a"] = "animate", ["i"] = "inanimate"} | |||
local function | local function gsubh(word, pat, repl, def) | ||
local harmony = m_ipa.harmony(word) | |||
end | |||
if pat:match("B") and pat:match("R") then | |||
pat = gsub(pat, "B", repl[harmony.backness]) | |||
pat = gsub(pat, "R", repl[harmony.roundness]) | |||
else | |||
pat = gsub(pat, "([BR])",function(s) return repl[harmony[s == "B" and "backness" or "roundness"]] end) | |||
end | |||
return pat | |||
return | |||
end | end | ||
| Line 37: | Line 41: | ||
local parent_args = frame:getParent().args | local parent_args = frame:getParent().args | ||
local g = NAMESPACE == "Template" and "a" or parent_args[1] | local g = NAMESPACE == "Template" and "a" or parent_args[1] | ||
local word = NAMESPACE == "Template" and "өра̄" or parent_args["word"] or PAGENAME | local word = NAMESPACE == "Template" and "өра̄" or parent_args["word"] or PAGENAME | ||
local unc = parent_args["unc"] or false | local unc = parent_args["unc"] or false | ||
local args = {} | local args = {} | ||
if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end | if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end | ||
local | data = {} | ||
data.word = word | |||
data.nocat = parent_args["nocat"] or false | |||
data.g = g | |||
data.sg = "" | |||
local pautable = { | |||
["[эеыиӣөү]"] = "ч", | |||
["[ɛая]"] = "н", | |||
["[уӯоɔ]"] = "ӈ", | |||
} | |||
local simplified_word = m_ipa.simplify(word) | |||
--data.pau = nil | |||
if simplified_word:match(vowel .. "$") then | |||
for pat, pau in pairs(pautable) do | |||
if simplified_word:match(pat .. "$") then | |||
data.pau = pau | |||
break | |||
end | |||
end | |||
else | |||
data.pau = gsubh(word, "Bӈ",{["b"]="о̆",["f"]="э̆", ["ab"]="о̆"}) | |||
end | end | ||
data.pl = { | data.pl = { | ||
["i"] = | ["i"] = (match(simplified_word, "[" .. voiceless .. "]$") and "ш" or "ж") .. gsubh(word, "Bд",{["b"]="о̆",["e"]="э̆", ["ab"]="о̆"}), | ||
["a"] = | ["a"] = (match(simplified_word, "[" .. voiceless .. "]$") and "ф" or "в") .. gsubh(word, "Rд",{["r"]="ө",["u"]="э", ["ar"]="э"}), | ||
} | } | ||
| Line 67: | Line 83: | ||
function make_table(data) | function make_table(data) | ||
local function show_form(form) | local function show_form(form) | ||
local function link(term) | local function link(term) | ||
| Line 86: | Line 102: | ||
for _, subform in ipairs(type(form) == "table" or {form}) do | for _, subform in ipairs(type(form) == "table" or {form}) do | ||
table.insert(ret, link(subform)) | table.insert(ret, link(subform)) | ||
local tr_subform, _ = m_tr.tr(subform,lang) | |||
table.insert(tr_ret, tr_subform) | |||
end | end | ||
return table.concat(ret, ", ") .. | return '<span lang="xchc" class="Cyrl">' .. table.concat(ret, ", ") .. '</span><br/><span style="color: #888;">' .. table.concat(tr_ret, ", ") .. "</span>" | ||
end | end | ||
| Line 101: | Line 118: | ||
numbers[2], numbers[3], numbers_sh[2], numbers_sh[3] = nil, nil, nil, nil | numbers[2], numbers[3], numbers_sh[2], numbers_sh[3] = nil, nil, nil, nil | ||
end | end | ||
table.insert(ret, " | table.insert(ret, '! style="width:8em;" |\n') | ||
for _, number in ipairs(numbers) do | for _, number in ipairs(numbers) do | ||
table.insert(ret, "! " .. number .. "\n") | table.insert(ret, "! " .. number .. "\n") | ||
| Line 108: | Line 125: | ||
for _, case in ipairs(cases) do | for _, case in ipairs(cases) do | ||
local c_sh = case:sub(1,3) | local c_sh = case:sub(1,3) | ||
table.insert(ret, " | table.insert(ret, '! style="background:#EFF4FD" |' .. case .. '\n') | ||
for _, number in ipairs(numbers) do | for _, number in ipairs(numbers) do | ||
local n_sh = number:sub(1,2) | local n_sh = number:sub(1,2) | ||
| Line 114: | Line 131: | ||
local decl = { | local decl = { | ||
["nom"] = "", | ["nom"] = "", | ||
["acc"] = | ["acc"] = match(w_number[n_sh], vowel .. "$") and "дза" | ||
["dat"] = | or match(w_number[n_sh], voiced .. "$") and "да" | ||
or "та", | |||
["dat"] = match(w_number[n_sh], vowel .. "$") and "ша" | |||
or match(w_number[n_sh], voiced .. "$") and "за" | |||
or "са", | |||
["gen"] = "ля", | ["gen"] = "ля", | ||
["ins"] = | ["ins"] = match(w_number[n_sh], vowel .. "$") and "лз" | ||
["pro"] = gsubh(" | or gsubh(w_number[n_sh], "Rлз",{["r"]="ө",["u"]="э",["ar"]="ө"}), | ||
["pro"] = gsubh(w_number[n_sh], "сRц",{["r"]="ө",["u"]="э", ["ar"]="ө"}), | |||
["ade"] = "ляц", | ["ade"] = "ляц", | ||
["abl"] = gsubh(" | ["abl"] = gsubh(w_number[n_sh], "сRшB",{["r"]="у",["u"]="ы",["b"]="о̄̆",["f"]="э̄̆",["ar"]="у",["ab"]="э̄̆"}), | ||
[" | ["ill"] = gsubh(w_number[n_sh], "кRб",{["r"]="ү",["u"]="ы",["ar"]="ы"}), | ||
} | } | ||
table.insert(ret, "| " .. show_form(w_number[n_sh] .. decl[c_sh])) | table.insert(ret, "| " .. show_form(w_number[n_sh] .. decl[c_sh]) .. "\n") | ||
end | end | ||
table.insert(ret, "|-\n") | table.insert(ret, "|-\n") | ||
| Line 132: | Line 154: | ||
local t = [=[ | local t = [=[ | ||
<div class="mw-collapsible" style=" | <div class="mw-collapsible" style="margin: 0px 0px -1px 0px; padding: 2px; border: 1px solid #aaaaaa; text-align: center; border-collapse: collapse; font-size: 95%; overflow: auto; width: auto; min-width: 35em; display:inline-block; color: #202122;"> | ||
<div style="min-height: 1.6em; font-size: 100%; text-align: left | <div style="min-height: 1.6em; font-size: 100%; text-align: left; 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); background: #EFF4FD; cursor: pointer;">'''Declension of {title}''' (<span style="font-weight:normal; font-size: smaller;">{after_title}</span>) </div> | ||
<div class="mw-collapsible-content" style="font-size: 100%;"> | <div class="mw-collapsible-content" style="font-size: 100%; display: block;"> | ||
{| | {\op}|style="background:#F9F9F9; text-align:center; min-width:35em; width:100%;" class="inflection-table" | ||
|- | |- style="background:#BDD3F7" | ||
{all_cases} | |||
|- | |- | ||
|}</div></div> | |{\cl}</div></div> | ||
]=] | ]=] | ||
return t | return require("Module:string utilities").format(t,{ | ||
title='<span lang="xchc" class="Cyrl">' .. data.word .. '</span>', | |||
after_title="[[:Category:Chiingimec " .. genders[data.g] .. " nouns|" .. genders[data.g] .. "]]", | |||
all_cases=make_cases(data) | |||
}) .. (data.nocat and "" or "[[Category:Chiingimec " .. genders[data.g] .. " nouns|" .. genders[data.g] .. "]]") | |||
end | end | ||
return export | return export | ||