Module:siwa-noun: Difference between revisions
No edit summary |
Tag: Undo |
||
| (29 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
local m_u = require('Module:utilities') | local m_u = require('Module:utilities') | ||
local m_l = require('Module:links') | |||
local m_data = require('Module:siwa-noun/data') | local m_data = require('Module:siwa-noun/data') | ||
local m_com = require('Module:siwa-noun/common') | local m_com = require('Module:siwa-noun/common') | ||
local lang = require('Module:languages').getByCode("siwa") | |||
local sub = mw.ustring.sub | local sub = mw.ustring.sub | ||
| Line 20: | Line 22: | ||
local vowels = "[aeiouyůõảẻỉỏủỷęȯởử]" | local vowels = "[aeiouyůõảẻỉỏủỷęȯởử]" | ||
local consonants = "[mpbvntdsṡʦʨʥŋɲcɟħðrṁṅḥkgġhłƛɬḍ]" | local consonants = "[mpbvntdsṡʦʨʥŋɲcɟħðrṁṅḥkgġhłƛɬḍ]" | ||
local function dedigraphicize(word) | local function dedigraphicize(word) | ||
| Line 74: | Line 74: | ||
local sv = NAMESPACE == "Template" and "i" or parent_args[2] | local sv = NAMESPACE == "Template" and "i" or parent_args[2] | ||
local decl_type = (parent_args["decl"] == "decl" and detect_decl(word, sv, g)) or parent_args["decl"] or detect_decl(word, sv, g) | local decl_type = (parent_args["decl"] == "decl" and detect_decl(word, sv, g)) or parent_args["decl"] or detect_decl(word, sv, g) | ||
if decl_type == "l" then parent_args["nocoal"] = true end | |||
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 | ||
| Line 94: | Line 95: | ||
local data = {forms = {}, categories = {}} | local data = {forms = {}, categories = {}} | ||
data.lang = lang | |||
data.head = parent_args["head"] or word | data.head = parent_args["head"] or word | ||
data.proper = parent_args["proper"] and true or false | data.proper = parent_args["proper"] and true or false | ||
| Line 111: | Line 113: | ||
end | end | ||
if g == "i" then | local coal_cases = {"m", "ine", "ill", "ela", "ade", "all", "abl"} | ||
if g == "i" or data.pos == "adjectives" then | |||
if parent_args.m then data.forms["m"][1] = parent_args["m"] end | if parent_args.m then data.forms["m"][1] = parent_args["m"] end | ||
-- Diphthong and long vowel coalescence | -- Diphthong and long vowel coalescence | ||
if ( | if (parent_args.nocoal ~= 1) and (not m_data[word]) then | ||
for _, case in ipairs( | for _, case in ipairs(coal_cases) do | ||
local n = 1 | local n = 1 | ||
while data.forms[case][n] do | local v = "(" .. vowels .. ")" | ||
if data.decl_type ~= "l" then | |||
while data.forms[case][n] do | |||
for regex, repl in pairs(m_com.triphthong_coalescence) do | |||
data.forms[case][n] = gsub(data.forms[case][n], v .. v .. v .. v, "%1%2%3@%4") | |||
data.forms[case][n] = gsub(data.forms[case][n], regex, repl) | |||
data.forms[case][n] = gsub(data.forms[case][n], "@", "") | |||
-- just in case some slipped through | |||
if not parent_args["notine"] then | |||
data.forms["ine"][n] = gsub(data.forms["ine"][n], "([aoueů])ia$", "%1įa") | |||
data.forms["ine"][n] = gsub(data.forms["ine"][n], "ỉia$", "igįia") | |||
end | |||
end | |||
n = n + 1 | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
--[[ | --[[]] | ||
else | else | ||
for _, form in ipairs({"m_sg", "u_pl", "m_pl"}) do | for _, form in ipairs({"m_sg", "u_pl", "m_pl"}) do | ||
| Line 155: | Line 166: | ||
end | end | ||
--[=[ | |||
local function link(term) | local function link(term) | ||
local links = {} | local links = {} | ||
| Line 162: | Line 174: | ||
end | end | ||
return table.concat(links, ", ") | return table.concat(links, ", ") | ||
end | end | ||
]=] | |||
local function link(term) | |||
local links = {} | |||
for alt in gmatch(term, "([^%s,]+)") do | |||
alt = term == "—" and term or m_l.full_link{lang=data.lang,term=term} | |||
table.insert(links, alt) | |||
end | |||
return table.concat(links, ", ") | |||
end | |||
local function repl(param) | local function repl(param) | ||
| Line 209: | Line 232: | ||
local navframe = [=[ | 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; width: 70%;"> | <div class="wikitable 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; width: 70%;"> | ||
<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);">''{{{title}}}'' —]=] .. (data.pos == "adjectives" and " " or " {{{gender}}} ") .. sub(data.pos, 1, -2) .. (data.g == "i" and ", {{{decl_type}}}" or "") .. [=[ | <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);">''{{{title}}}'' —]=] .. (data.pos == "adjectives" and " " or " {{{gender}}} ") .. sub(data.pos, 1, -2) .. (data.g == "i" and ", {{{decl_type}}}" or "") .. [=[ | ||
</div> | </div> | ||