Module:rad-IPA: Difference between revisions

Jump to navigation Jump to search
Added syllable tagging
(Added syllabification)
(Added syllable tagging)
Line 101: Line 101:
[false] = "i",
[false] = "i",
},
},
["ỳ"] = "",
["ỳ"] = "y",
["z"] = "z",
["z"] = "z",
["þ"] = "θ",
["þ"] = "θ",
Line 196: Line 196:
["z"] = "z", ["ʒ"] = "ʒ", ["θ"] = "ð",  
["z"] = "z", ["ʒ"] = "ʒ", ["θ"] = "ð",  
}
}
local affricate = {
["dz"] = true, ["dʒ"] = true ,
["ts"] = true, ["tʃ"] = true,
}
local sibilant = {
local sibilant = {
Line 311: Line 316:
vowel[temp] = true
vowel[temp] = true
end
end
local long = {
["a"] = false, ["aː"] = true, ["aːː"] = true, ["æː"] = true, ["ai"] = true, ["au"] = true,
["eː"] = true, ["ei"] = true, ["ɛ"] = false, ["ɤ"] = false, ["ɤi"] = true, ["i"] = false,
["iː"] = true, ["iːː"] = true, ["iːe"] = true, ["ia"] = true, ["ie"] = true, ["oː"] = true,
["œ"] = false, ["œa"] = true, ["øi"] = true, ["ɔ"] = false, ["ɔː"] = true, ["ɔa"] = true,
["ɔi"] = true, ["u"] = false, ["uː"] = true, ["uːː"] = true, ["uːo"] = true, ["ua"] = true,
["uo"] = true, ["y"] = false,
}
local weak = {
["a"] = false, ["aː"] = false, ["aːː"] = false, ["æː"] = false, ["ai"] = false, ["au"] = false,
["eː"] = false, ["ei"] = false, ["ɛ"] = false, ["ɤ"] = true, ["ɤi"] = false, ["i"] = true,
["iː"] = false, ["iːː"] = false, ["iːe"] = false, ["ia"] = false, ["ie"] = false, ["oː"] = false,
["œ"] = false, ["œa"] = false, ["øi"] = false, ["ɔ"] = false, ["ɔː"] = false, ["ɔa"] = false,
["ɔi"] = false, ["u"] = false, ["uː"] = false, ["uːː"] = false, ["uːo"] = false, ["ua"] = false,
["uo"] = false, ["y"] = false,
}
-- MISC --
-- MISC --
Line 330: Line 353:
if mw.ustring.match(s, toReplace) then
if mw.ustring.match(s, toReplace) then
s = mw.ustring.gsub(s, toReplace, ReplaceKey)
s = mw.ustring.gsub(s, toReplace, ReplaceKey)
mw.log("Irregular spelling <" .. toReplace .. "> recognised. Treating as <" .. ReplaceKey .. ">.")
-- generate_IPA: mw.log("Irregular spelling <" .. toReplace .. "> recognised. Treating as <" .. ReplaceKey .. ">.")
end
end
end
end
Line 380: Line 403:
  -- 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
--[[
local currentCombo = ""
local currentCombo = ""
-- for logs only
if i == -2 and j == 2 then
if i == -2 and j == 2 then
currentCombo = split_s[s_len + i + j - 2] .. " + " .. split_s[s_len + i + j - 1] .. " + " .. split_s[s_len + i + j]
currentCombo = split_s[s_len + i + j - 2] .. " + " .. split_s[s_len + i + j - 1] .. " + " .. split_s[s_len + i + j]
Line 387: Line 410:
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
-- 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 480: Line 504:
-- 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 .. ". Testing for resolution.")
if consonant[p_next] then
if consonant[p_next] then
if glide[p_next2] then
if glide[p_next2] then
Line 486: Line 510:
mw.log("ɤCj!V environment identified.")
mw.log("ɤCj!V environment identified.")
p_Resolve("ɤ")
p_Resolve("ɤ")
else
mw.log("No resolution needed.")
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.")
p_Resolve("ɤ")
p_Resolve("ɤ")
else
mw.log("No resolution needed.")
end
end
else
mw.log("No resolution needed.")
end
end
elseif p_current == "ù" or p_current == "ū" then
elseif p_current == "ù" or p_current == "ū" then
Line 550: Line 580:
end
end
 
if boundary[p_current] then
mw.log("——— word boundary detected ———")
end
end
end
Line 710: Line 736:
p_RemoveNext()
p_RemoveNext()
mw.log("Geminate [" .. p_current .. "] removed in final position at position " .. i .. ".")
mw.log("Geminate [" .. p_current .. "] removed in final position at position " .. i .. ".")
end
if boundary[p_current] then
mw.log("——— word boundary detected ———")
end
end
Line 755: Line 777:
end
end
mw.log("————— BEGINNING SYLLABIFICATION —————")
mw.log("————— BUILDING SYLLABLES —————")
-- division into syllables --
-- division into syllables --
Line 775: Line 797:
mw.log("Syllable " .. syllable_no .. " registered:")
mw.log("Syllable " .. syllable_no .. " registered:")
logSyllable()
logSyllable()
mw.log("===== NEW SYLLABLE=====")
mw.log("====================")
syllable_no = syllable_no + 1
syllable_no = syllable_no + 1
working_syllable = {
working_syllable = {
Line 790: Line 812:
syllables[syllable_no] = p_current
syllables[syllable_no] = p_current
table.remove(working_phones, 1)
table.remove(working_phones, 1)
mw.log("Boundary syllable " .. syllable_no .. " registered: '" .. p_current .. "'.")
mw.log("Boundary syllable " .. syllable_no .. " registered: '" .. p_current .. "'\n====================")
syllable_no = syllable_no + 1
syllable_no = syllable_no + 1
end
end
Line 813: Line 835:
end
end
table.remove(working_phones, 1)
table.remove(working_phones, 1)
mw.log("Current test string: " .. table.concat(working_phones))
-- mw.log("Current working syllable:")
mw.log("Current working syllable:")
-- logSyllable()
logSyllable()
if #working_phones == 0 then
if #working_phones == 0 then
Line 822: Line 843:
end
end
end
end
mw.log(" ========= ")
mw.log("Current test string: " .. table.concat(working_phones))
if consonant[p_current] then
if consonant[p_current] then
Line 875: Line 893:
end
end


mw.log("——— STRING EXHAUSTED ———")
mw.log("STRING EXHAUSTED\n====================")
return syllables
end
 
function tag_syllables(syllables)
 
mw.log("————— TAGGING SYLLABLES —————")
local syl_count = #syllables
for i = 1, syl_count do
local syllable = syllables[i]
local function tag_syllable(tag, value)
syllables[i][tag] = value
mw.log("syllables[" .. i .. "][" .. tag .. "] = " .. tostring(value) )
end
-- tag checked syllables --
if type(syllable) == "table" then
if syllable["coda"] == nil then
tag_syllable("checked", false)
else
tag_syllable("checked", true)
end
-- tag long syllables --
if long[syllable["nucleus"]] then
tag_syllable("long", true)
else
tag_syllable("long", false)
end
-- tag weak syllables (nucleus = [i] [ɤ]) --
if weak[syllable["nucleus"]] then
tag_syllable("weak", true)
else
tag_syllable("weak", false)
end
-- tag heavy syllables (nucleus is long coda is an obstruent-initial cluster) -
if syllable["coda"] then
if long[syllable["nucleus"]] and affricate[syllable["coda"][1]] then
tag_syllable("heavy", true)
elseif long[syllable["nucleus"]] and obstruent[syllable["coda"][1]] and syllable["coda"][2] then
tag_syllable("heavy", true)
else
tag_syllable("heavy", false)
end
end
 
mw.log("—————")
end
end
return syllables
return syllables
Line 891: Line 968:
outputIPA = resolve_consonants(outputIPA, hj)
outputIPA = resolve_consonants(outputIPA, hj)
outputIPA = get_syllables(outputIPA)
outputIPA = get_syllables(outputIPA)
outputIPA = tag_syllables(outputIPA)
-- test output only --
-- test output only --
local test_output = ""
for i = 1, #outputIPA do
for i = 1, #outputIPA do
local onset = ""
local onset = ""
Line 907: Line 987:
end
end
mw.log("Syllable " .. i .. ": " .. onset .. " [ " .. outputIPA[i]["nucleus"] .. " ] " .. coda )
test_output = test_output .. " " .. onset .. " [ " .. outputIPA[i]["nucleus"] .. " ] " .. coda
else
else
mw.log("Boundary syllable " .. i .. ": '" .. outputIPA[i] .. "'")
test_output = test_output .. " " .. outputIPA[i]
end
end
end
end
mw.log(test_output)
-- return outputIPA
-- return outputIPA
end
end

Navigation menu