Module:ryn-mut
Jump to navigation
Jump to search
Documentation for this module may be created at Module:ryn-mut/documentation
local export = {}
local params = {
[1] = {alias_of = "r"},
r = {default = mw.title.getCurrentTitle().text},
n = {},
nocat = {type = "boolean"},
}
local IRREG_MARKER = "<sup>△</sup>"
local UNCHANGED_MARKER = "<i>unchanged</i>"
local function is_vowel(c)
return c == "a" or c == "e" or c == "i" or c == "í" or c == "o" or c == "ó" or c == "u"
end
local function is_labial_consonant(c)
return c == "p" or c == "b"
end
local function n_is_exempt(c)
return c == "m" or c == "n"
end
function export.n_mutate(radical, override)
local function n_mutate_default(radical)
local initial = string.sub(radical, 1, 1)
if n_is_exempt(initial) then return radical end
if initial == "r" then return "d" .. radical end
if is_vowel(initial) then return "n-" .. radical end
if is_labial_consonant(initial) then return "m" .. radical end
return "n" .. radical
end
local mut = n_mutate_default(radical)
if override and mut ~= override then
return override, true
else
return mut, false
end
end
function export.show(frame)
local args = require("Module:parameters").process(frame:getParent().args, params)
local r = args["r"]
local n, n_irregular = export.n_mutate(r, args["n"])
local ret = '{| style="display:table; width:60%; border: 1px solid #b3b3b3; font-size: 95%; text-align: center;'
ret = ret .. '\n|-'
ret = ret .. '\n! style="background:#e3e3e3" colspan=4 | [[Appendix:Riyan mutation|Riyan mutation]]'
ret = ret .. '\n|-'
ret = ret .. '\n! style="padding-top:4px;" | [[Appendix:Glossary#radical|radical]]'
ret = ret .. '\n! style="padding-top:4px; | [[Appendix:Glossary#nasal|nasal]]'
ret = ret .. '\n|-'
ret = ret .. '\n| style="padding-bottom:4px;" | ' .. r
ret = ret .. '\n| style="padding-bottom:4px;" | ' .. ((n == r) and UNCHANGED_MARKER or n) .. (n_irregular and IRREG_MARKER or "")
ret = ret .. '\n|-'
if n_irregular then
ret = ret .. '\n| colspan=4 | <small style="font-size:85%;">' .. IRREGMARKER .. 'Irregular.</small>'
end
if n ~= r then
ret = ret .. "\n| colspan=4 | <small style=\"font-size:85%;\">''Note:'' Some of these forms may be hypothetical. Not every possible mutated form of every word actually occurs.</small>"
end
ret = ret .. '\n|}'
if n_irregular and (not args["nocat"]) then
ret = ret .. "[[Categories:Riyan terms with irregular mutation]]"
end
return ret
end
return export