Module:snon-mut: Difference between revisions
No edit summary |
Tag: Undo |
||
| (8 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 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 80: | 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 = {} | ||
for k, v in pairs(ret) do | for k, v in pairs(ret) do | ||
if v == "-" then | if v == "-" then | ||
links[k] = | links[k] = "''not applicable''" | ||
else | else | ||
links[k] = m_l.full_link{lang = lang, term = v} | links[k] = m_l.full_link{lang = lang, term = v} | ||
end | end | ||
end | end | ||