Module:rad-IPA: Difference between revisions

Jump to navigation Jump to search
Added progressive voicing resolution
(Fixed irregular recognition)
(Added progressive voicing resolution)
Line 125: Line 125:
}
}


-- ALL PHONES --
local valid_phone = {
local valid_phone = {
["a"] = true, ["aː"] = true, ["aːː"] = true, ["æː"] = true, ["ai"] = true, ["au"] = true, ["b"] = true,
["a"] = true, ["aː"] = true, ["aːː"] = true, ["æː"] = true, ["ai"] = true,
["ç"] = true, ["d"] = true, ["ð"] = true, ["eː"] = true, ["ei"] = true, ["ɛ"] = true, ["ɤ"] = true,
["au"] = true, ["b"] = true, ["ç"] = true, ["d"] = true, ["ð"] = true,
["ɤi"] = true, ["f"] = true, ["ɡ"] = true, ["ɣ"] = true, ["h"] = true, ["i"] = true, ["iː"] = true,
["dz"] = true, ["dʒ"] = true, ["eː"] = true, ["ei"] = true, ["ɛ"] = true,
["iːː"] = true, ["iːe"] = true, ["ia"] = true, ["ie"] = true, ["j"] = true, ["k"] = true, ["l"] = true,
["ɤ"] = true, ["ɤi"] = true, ["f"] = true, ["ɡ"] = true, ["ɣ"] = true,
["m"] = true, ["n"] = true, ["ŋ"] = true, ["oː"] = true, ["œ"] = true, ["œa"] = true, ["øi"] = true,
["h"] = true, ["i"] = true, ["iː"] = true, ["iːː"] = true, ["iːe"] = true,
["ɔ"] = true, ["ɔː"] = true, ["ɔa"] = true, ["ɔi"] = true, ["p"] = true, ["r"] = true, ["s"] = true,
["ia"] = true, ["ie"] = true, ["j"] = true, ["k"] = true, ["l"] = true,
["ʃ"] = true, ["t"] = true, ["u"] = true, [""] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["m"] = true, ["n"] = true, ["ŋ"] = true, ["oː"] = true, ["œ"] = true,
["uo"] = true, ["v"] = true, ["w"] = true, ["y"] = true, ["z"] = true, ["ʒ"] = true, ["θ"] = true,
["œa"] = true, ["øi"] = true, ["ɔ"] = true, ["ɔː"] = true, ["ɔa"] = true,
["ɔi"] = true, ["p"] = true, ["r"] = true, ["s"] = true, ["ʃ"] = true,
-- Temporary phones --
["t"] = true, ["ts"] = true, [""] = true, ["u"] = true, [""] = true,
["uːː"] = true, ["uːo"] = true, ["ua"] = true, ["uo"] = true, ["v"] = true,
["iːj"] = true, ["uːj"] = true, ["yːj"] = true,  
["w"] = true, ["y"] = true, ["z"] = true, ["ʒ"] = true, ["θ"] = true,  
}
}
local valid_phone_temp = {"iːj", "uːj", "yːj", "ù", "ū", "ĵ"}
for _, temp in ipairs(valid_phone_temp) do
valid_phone[temp] = true
end
-- CONSONANT GROUPS --


local consonant = {
local consonant = {
["b"] = true, ["ç"] = true, ["d"] = true, ["ð"] = true, ["f"] = true,
["b"] = true, ["ç"] = true, ["d"] = true, ["ð"] = true, ["dz"] = true,
["ɡ"] = true, ["ɣ"] = true, ["h"] = true, ["j"] = true, ["k"] = true,
["dʒ"] = true, ["f"] = true, ["ɡ"] = true, ["ɣ"] = true, ["h"] = true,
["l"] = true, ["m"] = true, ["n"] = true, ["ŋ"] = true, ["p"] = true,
["j"] = true, ["k"] = true, ["l"] = true, ["m"] = true, ["n"] = true,
["r"] = true, ["s"] = true, ["ʃ"] = true, ["t"] = true, ["v"] = true,
["ŋ"] = true, ["p"] = true, ["r"] = true, ["s"] = true, ["ʃ"] = true,
["w"] = true, ["y"] = true, ["z"] = true, ["ʒ"] = true, ["θ"] = true,
["t"] = true, ["ts"] = true, ["tʃ"] = true, ["v"] = true, ["w"] = true,
["z"] = true, ["ʒ"] = true, ["θ"] = true,
}
local consonant_temp = {"ĵ"}
for _, temp in ipairs(consonant_temp) do
consonant[temp] = true
end
local sibilant = {
["dz"] = true, ["dʒ"] = true ,
["s"] = true, ["ʃ"] = true,
["ts"] = true, [""] = true,
["z"] = true, ["ʒ"] = true,
}
 
local sibilant_alv = {
["dz"] = true,
["s"] = true,
["ts"] = true,
["z"] = true,
}
 
local sibilant_post = {
["dʒ"] = true,
["ʃ"] = true,
["tʃ"] = true,
["ʒ"] = true,
}
local sibilant_alv_to_post = {
["dz"] = "dʒ",
["s"] = "ʃ",
["ts"] = "tʃ",
["z"] = "ʒ",
}
local glide = {
["j"] = true, ["w"] = true,
}
local glide_temp = {"ĵ"}
for _, temp in ipairs(glide_temp) do
glide[temp] = true
end
local iotate = {
["d"] = "dʒ", ["dz"] = "dʒ",
["ɡ"] = "j", ["ɣ"] = "j",
["h"] = "ç",
["k"] = "tʃ",
["l"] = "j",
["s"] = "ʃ",
["t"] = "tʃ", ["ts"] = "tʃ",
["z"] = "ʒ",
}
}
-- VOWEL GROUPS --


local vowel = {
local vowel = {
Line 154: Line 215:
["œ"] = true, ["œa"] = true, ["øi"] = true, ["ɔ"] = true, ["ɔː"] = true, ["ɔa"] = true,
["œ"] = true, ["œa"] = true, ["øi"] = true, ["ɔ"] = true, ["ɔː"] = true, ["ɔa"] = true,
["ɔi"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["ɔi"] = true, ["u"] = true, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["uo"] = true,  
["uo"] = true, ["y"] = true,
-- Temporary phones --
["iːj"] = true, ["uːj"] = true, ["yːj"] = true,
}
 
local glide = {
["j"] = true, ["w"] = true,
}
}
local vowel_temp = {"iːj", "uːj", "yːj", "ù", "ū"}
for _, temp in ipairs(vowel_temp) do
vowel[temp] = true
end
-- MISC --


local boundary = {
local boundary = {
Line 231: Line 290:
  -- generate_IPA: mw.log("Tabular index recognised.")
  -- generate_IPA: mw.log("Tabular index recognised.")
  for j = 1, 0 - i do
  for j = 1, 0 - i do
-- DEBUG PRINT ONLY
--[[
local currentCombo = ""
local currentCombo = ""
if i == -2 and j == 2 then
if i == -2 and j == 2 then
Line 238: Line 297:
currentCombo = split_s[s_len + i + j - 1] .. " + " .. split_s[s_len + i + j]
currentCombo = split_s[s_len + i + j - 1] .. " + " .. split_s[s_len + i + j]
end
end
-- END OF DEBUG PRINT
-- generate_IPA: mw.log("Testing " .. currentCombo) ]]
-- generate_IPA: mw.log("Testing " .. currentCombo)
if getData[split_s[s_len + i + j]] then
if getData[split_s[s_len + i + j]] then
  getData = getData[split_s[s_len + i + j]]
  getData = getData[split_s[s_len + i + j]]
Line 300: Line 358:
while true do
while true do
i = i + 1
i = i + 1
local p_prev3 = working_phones[i - 3]
local p_prev2 = working_phones[i - 2]
local p_prev = working_phones[i - 1]
local p_prev = working_phones[i - 1]
local p_current = working_phones[i]
local p_current = working_phones[i]
Line 324: Line 380:
end
end
-- RESOLUTION OF [aù] --
-- Resolution of [aù] --
if p_prev == "a" and p_current == "ù" then
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].")
Line 332: Line 388:
-- RESOLUTION OF [u], [ù] and [ū] --
-- 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 356: Line 412:
end
end
-- RESOLUTION OF <ei> and  <øi> --
-- Resolution of <ei> and  <øi> --
if p_current == "ei" then
if p_current == "ei" then
for j = 1, i do
for j = 1, i do
Line 372: Line 428:
if vowel[p_next] then
if vowel[p_next] then
-- RESOLUTION OF PREVOCALIC <iej>, <uoj> and <yej> --  
-- Resolution of prevocalic <iej>, <uoj> and <yej> --  
if p_current == "iej" or p_current == "yej" or p_current == "uoj" then
if p_current == "iej" or p_current == "yej" or p_current == "uoj" then
Line 381: Line 437:
mw.log("[j] inserted to position " .. i + 1 .. ".")
mw.log("[j] inserted to position " .. i + 1 .. ".")
else
else
p_Convert("ie")
p_Resolve("")
end
end
end
end
-- RESOLUTION OF PREVOCALIC [ie] and [uo] --  
-- Resolution of prevocalic [ie] and [uo] --  
if p_current == "ie" then
if p_current == "ie" then
Line 395: Line 451:
else
else
-- RESOLUTION OF NON-PREVOCALIC <iej>, <uoj> and <yej> --  
-- Resolution of non-prevocalic <iej>, <uoj> and <yej> --  
if p_current == "iej" then
for toResolve, ResolveKey in pairs({["iej"] = "ei", ["uoj"] = "ɔi", ["yej"] = "øi"}) do
p_Resolve("ei")
if p_current == toResolve then
elseif p_current == "uoj" then
p_Resolve(ResolveKey)
p_Resolve("ɔi")
end
elseif p_current == "yej" then
p_Resolve("øi")
end
end
end
end
end
-- Removes placeholder phones from data --
for _, temp in ipairs(vowel_temp) do
valid_phone[temp] = nil
vowel[temp] = nil
end
mw.log("Vowel resolution result: [" .. table.concat(working_phones,"][") .. "]")
return working_phones
end
function resolve_consonants(phones)
local working_phones = phones
mw.log("————— BEGINNING CONSONANT RESOLUTION —————")
local i = 0
while true do
i = i + 1
local p_prev = working_phones[i - 1]
local p_current = working_phones[i]
local p_next = working_phones[i + 1]
local p_next2 = working_phones[i + 2]
local p_next3 = working_phones[i + 3]
local toResolve = false
if p_current == nil then break end
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 iotation --
if iotate[p_current] and p_next == "j" then
mw.log("[" .. p_current .. "j] found in position " .. i .. ".")
p_Convert(iotate[p_current])
table.remove(working_phones, i + 1)
mw.log("[j] removed from position " .. i + 1 .. ".")
elseif p_current == "ĵ" then
p_Convert("j")
end
-- Resolution of -s, -ș --
if p_next == "s" then
if sibilant[p_current] then
table.remove(working_phones, i + 1)
mw.log("[s] removed from position " .. i + 1 .. " following a sibilant.")
elseif p_current == "t" then
p_Convert("ts")
table.remove(working_phones, i + 1)
mw.log("[t][s] → [ts] in position " .. i .. ".")
elseif p_current == "d" then
p_Convert("dz")
table.remove(working_phones, i + 1)
mw.log("[d][s] → [dz] in position " .. i .. ".")
end
elseif p_next == "ʃ" then
if sibilant_post[p_current] == true then
table.remove(working_phones, i + 1)
mw.log("[ʃ] removed from position " .. i + 1 .. " following a postalveolar sibilant.")
elseif sibilant_alv[p_current] then
mw.log("[" .. p_current .. "][ʃ] → [" .. sibilant_alv_to_post[p_current] .. "] in position " .. i .. ".")
p_Convert(sibilant_alv_to_post[p_current])
table.remove(working_phones, i + 1)
elseif p_current == "t" then
p_Convert("tʃ")
table.remove(working_phones, i + 1)
mw.log("[t][ʃ] → [tʃ] in position " .. i .. ".")
elseif p_current == "d" then
p_Convert("dʒ")
table.remove(working_phones, i + 1)
mw.log("[d][ʃ] → [dʒ] in position " .. i .. ".")
end
end
-- Resolution of t --
-- Resolution of voicing --
-- Resolution of ts, tș, ts|s --
end
-- Removes placeholder phones from data --
for _, temp in ipairs(consonant_temp) do
valid_phone[temp] = nil
consonant[temp] = nil
glide[temp] = nil
end
end
Line 413: Line 568:
end
end


function export.generate(frame)
function export.generate(frame)
Line 418: Line 574:
local outputIPA = generate_IPA(args[1])
local outputIPA = generate_IPA(args[1])
outputIPA = resolve_vowels(outputIPA)
outputIPA = resolve_vowels(outputIPA)
outputIPA = resolve_consonants(outputIPA)
outputIPA = table.concat(outputIPA,"][")
outputIPA = table.concat(outputIPA,"][")

Navigation menu