Module:snon-mut: Difference between revisions
No edit summary |
Tag: Undo |
||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 11: | Line 11: | ||
local export = {} | local export = {} | ||
local words = mw.text.split("hello world hi", "%s") | |||
local first = table.remove(words, 1) | |||
local ords = words | |||
function export.mutations(ret, args) | function export.mutations(ret, args) | ||
local | 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 25: | ||
local vowels = "([aeiouàèìòù])" | local vowels = "([aeiouàèìòù])" | ||
local apostrophe | local apostrophe | ||
words[1] = " " | |||
words = table.concat(words, " ") | |||
if args.len then | if args.len then | ||
ret.lenition = args.len | ret.lenition = args.len | ||
elseif match(first_letter, "[ | 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 | ||
ret.lenition = "-" | ret.lenition = "-" | ||
| Line 35: | Line 42: | ||
local eclipsis_prefixes = { | local eclipsis_prefixes = { | ||
["b"] = "m", ["c"] = "g", ["d"] = "n", ["f"] = "v", ["g"] = "n", | ["b"] = "m", ["c"] = "g", ["d"] = "n", ["f"] = "v", ["g"] = "n", | ||
["p"] = "b", ["t"] = "d", ["h"] = " | ["p"] = "b", ["t"] = "d", ["h"] = "gh", ["s"] = "z", ["v"] = "b", | ||
} | } | ||
| Line 41: | Line 48: | ||
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 = "-" | ||
| Line 70: | Line 77: | ||
["ecl"] = {}, | ["ecl"] = {}, | ||
["len"] = {}, | ["len"] = {}, | ||
["temp_len"] = {type = "boolean"}, | |||
["temp_ecl"] = {type = "boolean"}, | |||
} | } | ||
| Line 77: | Line 87: | ||
local ret = {radical = args[1]} | local ret = {radical = args[1]} | ||
ret, is_vowel = export.mutations(ret, args) | ret, is_vowel = export.mutations(ret, args) | ||
if args.temp_len then | |||
return ret.lenition == "-" and ret.radical or ret.lenition | |||
end | |||
if args.temp_ecl then | |||
return ret.eclipsis == "-" and ret.radical or ret.eclipsis | |||
end | |||
local links = {} | local links = {} | ||