Module:ryn-mut: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 13: Line 13:


local mutation_rules = {
local mutation_rules = {
["b"] = {"bh", "mb"},
["b"] = {"v", "mb"},
["bh"] = {nil, "mbh"},
["v"] = {nil, "mv"},
["c"] = {"ch", "nc"},
["k"] = {"h", "nk"},
["ch"] = {"gh", "nch"},
["h"] = {"", "nh"},
["d"] = {"d̦", "nd"},
["d"] = {"d̦", "nd"},
["d̦"] = {"d̦", "nd̦"},
["d̦"] = {"d̦", "nd̦"},
["dh"] = {nil, "ndh"},
["ð"] = {nil, ""},
["f"] = {nil, "mf"},
["f"] = {nil, "mf"},
["g"] = {"gh", "ng"},
["g"] = {"", "ng"},
["gh"] = {nil, "ngh"},
[""] = {nil, "nr̦"},
["l"] = {nil, "nl"},
["l"] = {nil, "nl"},
["lh"] = {"l", "nlh"},
["hl"] = {"l", "nl"},
["m"] = {},
["m"] = {},
["n"] = {},
["n"] = {},
["p"] = {"b", "mp"},
["p"] = {"b", "mp"},
["r"] = {nil, "dr"},
["r"] = {nil, "dr"},
["rh"] = {"r", "dr"},
["hr"] = {"r", "dr"},
["s"] = {"ș", "ns"},
["s"] = {"ș", "ns"},
["ș"] = {"ș", "nș"},
["ș"] = {"ș", "nș"},
["t"] = {"ț", "nt"},
["t"] = {"ț", "nt"},
["ț"] = {"ț", "nț"},
["ț"] = {"ț", "nț"},
["th"] = {nil, "nth"},
}
}
local vowel_pattern = "[aeiíoóu]"
local vowel_pattern = "[aáeiíouú]"
local gh_to_bh_vowel_pattern = "[eiíuó]"
local gh_to_v_vowel_pattern = "[eiíuú]"


local function get_radical_data(term)
local function get_radical_data(term)
local initial, prevowel, remainder
local initial, prevowel, remainder
if mw.ustring.sub(term, 2, 2) == "h" then
initial = mw.ustring.sub(term, 1, 1)
initial = mw.ustring.sub(term, 1, 2)
if initial == "h" then
remainder = mw.ustring.sub(term, 3)
local next_initial = mw.ustring.sub(term, 2, 2)
prevowel = mw.ustring.find(mw.ustring.sub(term, 3, 3), vowel_pattern) and true or false
if next_initial == "r" or next_initial == "l" then
else
initial = initial .. next_initial
initial = mw.ustring.sub(term, 1, 1)
prevowel = mw.ustring.find(mw.ustring.sub(term, 3, 3), vowel_pattern)
remainder = mw.ustring.sub(term, 2)
remainder = mw.ustring.sub(term, 3)
prevowel = mw.ustring.find(mw.ustring.sub(term, 2, 2), vowel_pattern) and true or false
return initial, false, prevowel, remainder
end
end
end
prevowel = mw.ustring.find(mw.ustring.sub(term, 2, 2), vowel_pattern)
remainder = mw.ustring.sub(term, 2)
local vowel = mw.ustring.find(initial, vowel_pattern) and true or false
local vowel = mw.ustring.find(initial, vowel_pattern) and true or false
return initial, vowel, prevowel, remainder
return initial, vowel, prevowel, remainder
Line 62: Line 64:
if change then
if change then
local r_initial = mw.ustring.sub(data.remainder, 1, 1)
local r_initial = mw.ustring.sub(data.remainder, 1, 1)
if change == "gh" and mw.ustring.find(r_initial, gh_to_bh_vowel_pattern) then
if change == "" and mw.ustring.find(r_initial, gh_to_v_vowel_pattern) then
change = "bh"
change = "v"
end
end
return change .. data.remainder
return change .. data.remainder

Navigation menu