Module:siwa-noun/common: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
local gsub = mw.ustring.gsub
local export = {}
local export = {}


Line 26: Line 28:
}
}
for regex, repl in pairs(lenition_patterns) do
for regex, repl in pairs(lenition_patterns) do
lenited = mw.ustring.gsub(word, regex, repl, 1)
lenited = word:gsub(regex, repl, 1)
if lenited ~= word then return lenited end
if lenited ~= word then return lenited end
end
end
Line 35: Line 37:
function export.coalescence(word, stress)
function export.coalescence(word, stress)
local diphthongs = { -- TODO: [ůy]V > ỷ in stressed
local diphthongs = { -- TODO: [ůy]V > ỷ in stressed
["[aę]▫[aę]"] = "ả", ["e▫e"] = "ẻ", ["i▫i"] = "ỉ", ["[yů]▫[yů]"] = "", ["[uyů]▫[uyů]"] = "ủ",  
["[aę]▫[aę]"] = "ả", ["e▫e"] = "ẻ", ["i▫i"] = "ỉ", ["u▫[yuů]"] = "", ["[]▫u"] = "ủ",
["[ei]▫[aę]"] = "ia", ["([ou])▫[aę]"] = "%1a", ["[ůy]▫[aę]"] = "ůa", ["a▫[ei]"] = "ai", ["a▫[ou]"] = "au", ["[aę]▫[yůu]"] = "ay",
["a▫e"] = "ai", ["a▫o"] = "au", ["ę▫[]"] = "ay",
["[eę]▫[ei]"] = "ei", ["[ie]▫o"] = "io", ["[eę]▫[ou]"] = "eu", [""] = "oi",
["ę▫[ei]"] = "ei", ["ę▫o"] = "eu",  
["e▫[aę]"] = "ia", ["e▫o"] = "io", ["i▫y"] = "",
["aa"] = "ā", [""] = "ā", ["ae"] = "ai", ["ai"] = "ai", ["ao"] = "au", ["au"] = "au", ["a[yů]"] = "ay",
["[uo]▫e"] = "oi", ["o▫ů"] = "ou",
["ęa"] = "ā", ["ęę"] = "ā", ["ęe"] = "ei", ["ęi"] = "ei", ["ęo"] = "eu", ["ęu"] = "ay", ["ę[yů]"] = "ay",
["[yůo]▫o"] = "uo",
["ea"] = "ia", ["eę"] = "ia", ["ee"] = "ē", ["ei"] = "ei", ["eo"] = "io", ["eu"] = "eu", ["e[yů]"] = "ey",
["[yů][yů]"] = "",
["ia"] = "ia", ["ię"] = "ia", ["ie"] = "ie", ["ii"] = "ī", ["io"] = "io", ["iu"] = "iu", ["i[yů]"] = "iů",
["([ae])▫ů"] = "%1y", ["([iou])▫ę"] = "%1a",  
["oa"] = "oa", ["oę"] = "oa", ["oe"] = "oi", ["oi"] = "oi", ["oo"] = "uo", ["ou"] = "ou", ["o[yů]"] = "ou",
["[yů]▫a"] = "ů▫a", ["[yů]▫ę"] = "ů▫a", ["[yů]▫e"] = "ů▫i", ["[yů]▫i"] = "ů▫i", -- to screen out stressed vs. unstressed
["ua"] = "ua", ["uę"] = "ua", ["ue"] = "ui", ["ui"] = "ui", ["uo"] = "uo", ["uu"] = "ū", ["u[yů]"] = "ū",
["[yů]a"] = "ůa", ["[yů]ę"] = "ůa", ["[yů]e"] = "ůi", ["[yů]i"] = "ůi", ["[yů]o"] = "uo", ["[yů]u"] = "ū", ["[yů][yů]"] = "ȳ",
}
}
for regex, repl in pairs(diphthongs) do
word = word:gsub(regex, repl, 1)
end
if stress then
word = word:gsub("[ůy]▫.", "ỷ")
end
word = word:gsub("▫", "")
return word
end
end