Module:snon-mut: Difference between revisions

No edit summary
No edit summary
Line 13: Line 13:


function export.mutations(ret, args)
function export.mutations(ret, args)
local lower_radical = mw.ustring.lower(mw.text.split(ret.radical or args.word, "%s")[1])
local words = mw.text.split(ret.radical or args.word, "%s")
local lower_radical = mw.ustring.lower(words[1])
local first_letter = match(lower_radical, "^%W*(%w)")
local first_letter = match(lower_radical, "^%W*(%w)")
local is_proper = ret.radical ~= lower_radical
local is_proper = ret.radical ~= lower_radical
Line 19: Line 20:
local vowels = "([aeiouàèìòù])"
local vowels = "([aeiouàèìòù])"
local apostrophe
local apostrophe
words = " " .. table.concat(table.remove(words, 1), " ")
if args.len then
if args.len then
ret.lenition = args.len
ret.lenition = args.len
elseif match(first_letter, "[bcdfgmptsnv]") then
elseif match(first_letter, "[bcdfgmptsnv]") then
ret.lenition = ret.radical:gsub("^(.)", "%1h")
ret.lenition = ret.radical:gsub("^(.)", "%1h") .. words
elseif match(first_letter, vowels) then -- h-prothesis
elseif match(first_letter, vowels) then -- h-prothesis
ret.lenition = "h'" .. lower_radical
ret.lenition = "h'" .. lower_radical .. words
apostrophe = true
apostrophe = true
else
else
Line 39: Line 41:
ret.eclipsis = args.ecl
ret.eclipsis = args.ecl
elseif eclipsis_prefixes[first_letter] then
elseif eclipsis_prefixes[first_letter] then
ret.eclipsis = eclipsis_prefixes[first_letter] .. sub(lower_radical, 2, -1)
ret.eclipsis = eclipsis_prefixes[first_letter] .. sub(lower_radical, 2, -1) .. words
elseif match(first_letter, vowels) then
elseif match(first_letter, vowels) then
ret.eclipsis = "n'" .. lower_radical
ret.eclipsis = "n'" .. lower_radical .. words
apostrophe = true
apostrophe = true
elseif match(lower_radical, "^ghi" .. vowels) then
elseif match(lower_radical, "^ghi" .. vowels) then
ret.eclipsis = gsub(lower_radical, "^ghi" .. vowels, "ni%1")
ret.eclipsis = gsub(lower_radical, "^ghi" .. vowels, "ni%1") .. words
else
else
ret.eclipsis = "-"
ret.eclipsis = "-"