Module:rad-IPA: Difference between revisions

Jump to navigation Jump to search
Added more vowel resolution
m (Optimisation)
(Added more vowel resolution)
Line 37: Line 37:
["e"] = {
["e"] = {
["a"] = "ia",
["a"] = "ia",
["j"] = "iːj",
["j"] = "iej",
[false] = "ie",
[false] = "ie",
},
},
Line 75: Line 75:
["o"] = {
["o"] = {
["a"] = "ua",
["a"] = "ua",
["j"] = "uːj",
["j"] = "uoj",
[false] = "uo",
[false] = "uo",
},
},
Line 91: Line 91:
["w"] = "w",
["w"] = "w",
["x"] = "ʒ",
["x"] = "ʒ",
["y"] = {
["e"] = {
["a"] = "ia",
["j"] = "yej",
[false] = "ie",
},
[false] = "i",
},
["ỳ"] = "ỳ",
["ỳ"] = "ỳ",
["z"] = "z",
["z"] = "z",
Line 102: Line 110:
data["ì"] = data["i"]
data["ì"] = data["i"]
data["ò"] = data["o"]
data["ò"] = data["o"]
data["y"] = data["i"]
data["y"]["e"]["j"] = "yːj"
data["ý"] = data["í"]
data["ý"] = data["í"]
data["ỷ"] = data["ỉ"]
data["ỷ"] = data["ỉ"]
Line 152: Line 158:


local boundary = {
local boundary = {
[" "] = true, ["|"] = true, ["·"] = true,  
[" "] = true, ["|"] = true, ["·"] = true,
}
}


Line 269: Line 275:
end
end


function resolve_u(phones)
function resolve_vowels(phones)
local working_phones = phones
local working_phones = phones
mw.log("————— BEGINNING U RESOLUTION —————")
mw.log("————— BEGINNING VOWEL RESOLUTION —————")
 
for i = 1, #working_phones do
for i = 1, #working_phones do
local p_prev3 = working_phones[i - 3]
local p_prev2 = working_phones[i - 2]
local p_prev = working_phones[i - 1]
local p_current = working_phones[i]
local p_current = working_phones[i]
local p_next = working_phones[i + 1]
local p_next = working_phones[i + 1]
Line 279: Line 289:
local toResolve = false
local toResolve = false
if p_current == "a" and p_next == "ù" then
local function p_Resolve(p_new)
working_phones[i] = p_new
mw.log("[" .. p_current .. "] resolved to [" .. p_new .. "] in position ".. i .. ".")
p_new = ""
end
local function p_Convert(p_new)
working_phones[i] = p_new
mw.log("[" .. p_current .. "] converted to [" .. p_new .. "] in position ".. i .. ".")
p_current = p_new
p_new = ""
end
-- RESOLUTION OF [aù] --
if p_prev == "a" and p_current == "ù" then
mw.log("<aù> recognised in position " .. i .. ". Converting to resolvable [u].")
mw.log("<aù> recognised in position " .. i .. ". Converting to resolvable [u].")
working_phones[i + 1] = "u"
p_Convert("u")
p_current = "u"
end
end
-- RESOLUTION OF [u], [ù] and [ū] --
if p_current == "u" then
if p_current == "u" then
mw.log("[u] found in position " .. i .. ".")
mw.log("[u] found in position " .. i .. ".")
Line 290: Line 317:
if not vowel[p_next3] then
if not vowel[p_next3] then
mw.log("ɤCj!V environment identified.")
mw.log("ɤCj!V environment identified.")
toResolve = true
p_Resolve("ɤ")
end
end
elseif not vowel[p_next2] and not glide[p_next2] then
elseif not vowel[p_next2] and not glide[p_next2] then
mw.log("ɤC!V environment identified.")
mw.log("ɤC!V environment identified.")
toResolve = true
p_Resolve("ɤ")
end
end
end
end
Line 305: Line 332:
working_phones[i] = "ɤ"
working_phones[i] = "ɤ"
mw.log("[u] → [ɤ] in position ".. i .. ".")
mw.log("[u] → [ɤ] in position ".. i .. ".")
end
-- RESOLUTION OF <ei> and  <øi> --
if p_current == "ei" then
for j = 1, i do
local check_phone = working_phones[i - j]
if boundary[check_phone] or check_phone == nil then
mw.log("Initial [ei] found in position" .. i .. ".")
p_Resolve("ai")
break
elseif not consonant[check_phone] then
break
end
end
end
-- RESOLUTION OF <iej>, <uoj> and <yej> --
if vowel[p_next] then
if p_current == "iej" or p_current == "yej" or p_current == "uoj" then
mw.log("Pre-vocalic <" .. p_current .. "> found in position " .. i .. ".")
if p_current == "uoj" then
p_Resolve("uo")
else
p_Resolve("ie")
end
table.insert(working_phones, i + 1, "j")
mw.log("[j] inserted to position " .. i + 1 .. ".")
end
else
if p_current == "iej" then
p_Resolve("ei")
elseif p_current == "uoj" then
p_Resolve("ɔi")
elseif p_current == "yej" then
p_Resolve("øi")
end
end
end
end
end
mw.log("[u] resolution result: [" .. table.concat(working_phones,"][") .. "]")
mw.log("Vowel resolution result: [" .. table.concat(working_phones,"][") .. "]")
return working_phones
return working_phones
Line 317: Line 385:
local args = getArgs(frame)
local args = getArgs(frame)
local outputIPA = generate_IPA(args[1])
local outputIPA = generate_IPA(args[1])
outputIPA = resolve_u(outputIPA)
outputIPA = resolve_vowels(outputIPA)
outputIPA = table.concat(outputIPA,"][")
outputIPA = table.concat(outputIPA,"][")

Navigation menu