Module:rad-IPA: Difference between revisions

Jump to navigation Jump to search
Added rhyme
No edit summary
(Added rhyme)
Line 351: Line 351:
vowel[temp] = true
vowel[temp] = true
end
end
local marked_hiatus = {
["a"] = true, ["ai"] = true, ["au"] = true,
["ei"] = true, ["ɛ"] = true, ["ɤ"] = true, ["ɤi"] = true, ["i"] = true,
["iːe"] = true, ["ia"] = true, ["ie"] = true, ["oː"] = true,
["œ"] = true, ["œa"] = true, ["øi"] = true, ["ɔ"] = true, ["ɔa"] = true,
["ɔi"] = true, ["u"] = true, ["uːo"] = true, ["ua"] = true,
["uo"] = true, ["y"] = true,
}
local long = {
local long = {
Line 791: Line 800:
p_RemoveNext()
p_RemoveNext()
end
end
end
-- RESOLUTION OF MULTIPLE BOUNDARIES --
if p_current == " " and p_next == "|" then
p_Convert("|")
p_RemoveNext()
elseif p_current == " " and p_next == " " then
p_RemoveNext()
elseif p_current == "|" and (p_next == " " or p_next == "|") then
p_RemoveNext()
end
end
Line 1,291: Line 1,310:


local output = ""
local output = ""
mw.log("————— COMPILING OUTPUT —————")
for i = 1, #syllables do
for i = 1, #syllables do
local onset = ""
local onset = ""
local coda = ""
local coda = ""
local stress=""
local stress =""
-- add hiatus marker --
if syllables[i+1] then
if syllables[i]["coda"] == nil and marked_hiatus[syllables[i]["nucleus"]] and syllables[i+1]["onset"] == nil then
syllables[i]["coda"] = {"."}
mw.log("Hiatus marked between syllables " .. i .. " and " .. i+1 .. ".")
end
end
if type(syllables[i]) == "table" then
if type(syllables[i]) == "table" then
Line 1,316: Line 1,345:
output = output .. stress .. onset .. syllables[i]["nucleus"] .. coda
output = output .. stress .. onset .. syllables[i]["nucleus"] .. coda
elseif syllables[i] == " " then
output = output .. " "
elseif syllables[i] == "|" then
output = output .. " | "
else
else
output = output .. syllables[i]
error("Unknown phone identified: " .. syllables[i])
end
end
Line 1,324: Line 1,357:
return output  
return output  
end
function get_rhyme(IPA)
if mw.ustring.match(IPA, "([ %|])") then
return nil
end
if mw.ustring.match(IPA, "(ˈ)") then
IPA = mw.ustring.gsub(IPA, "(ˌ)", "")
IPA = mw.ustring.gsub(IPA, "^(.*ˈ)", "")
end
while true do
local check = mw.ustring.sub(IPA, 1, 1)
if consonant[check] then
IPA = mw.ustring.sub(IPA, 2)
else
break
end
end
return IPA
end
end


Line 1,347: Line 1,399:
outputIPA = syllables_to_string(outputIPA)
outputIPA = syllables_to_string(outputIPA)
if parameters["phon"] and parameters["format"] then
if parameters["rhyme"] then
outputIPA = "<span class=\"IPA\">[" .. outputIPA .. "]</span>"
outputIPA = get_rhyme(outputIPA)
elseif parameters["format"] then
outputIPA = "<span class=\"IPA\">/" .. outputIPA .. "/</span>"
end
end
mw.log(outputIPA)
if outputIPA == nil then
return outputIPA
mw.log("Invalid rhyme request.")
return nil
else
if parameters["phon"] and parameters["format"] then
outputIPA = "<span class=\"IPA\">[" .. outputIPA .. "]</span>"
elseif parameters["format"] then
outputIPA = "<span class=\"IPA\">/" .. outputIPA .. "/</span>"
end
mw.log(outputIPA)
return outputIPA
end
end
end
Line 1,363: Line 1,428:
Debug console test string:
Debug console test string:
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"rjaovs"}})
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"rjaovs"}})
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"rjaovs", "true"}}) (for hjádvanþs)
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"rjaovs", "hj"}})
]]
]]

Navigation menu