Module:ábḫ-ipa: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
local export = {}
local export = {}
function isStressed(p, pp)
if (p == "ˌ") or (pp == "ˌ") then
return true
else
return false
end
end


function export.convert(frame)
function export.convert(frame)
Line 121: Line 113:
end
end
-- look through word and replace the correct .'s with ˌ's
newWord = {}
newWord = {}
index = 1
index = 1
for i,val in ipairs(result) do
for i,val in ipairs(result) do
stress = newStresses[index]
-- look through word and replace the correct .'s with ˌ's
if (i == 1) and val == "." and newStresses[1] == "." then
if (i == 1) and val == "." and newStresses[1] == "." then
index = index + 1
index = index + 1
elseif val == "." or val == "ˈ" then
elseif val == "." or val == "ˈ" then
table.insert(newWord, newStresses[index])
table.insert(newWord, stress)
index = index + 1
index = index + 1
else
-- allophonic rules, i.e., from a one-to-one phonemic map to a one-to-
table.insert(newWord, val)
-- one phonetic map: vowels first
end
elseif val == "a" then
end
if stress == "." then
table.insert(newWord, "w")
word = newWord
else
newWord = {}
-- allophonic rules, i.e., from a one-to-one phonemic map to a one-to one
-- phonetic map
for i,val in ipairs(word) do
-- let's start with vowels
if val == "a" then
if isStressed(word[i-1], word[i-2]) then
table.insert(newWord, "a")
table.insert(newWord, "a")
else
table.insert(newWord, "w")
end
end
elseif val == "e" then
elseif val == "e" then
if word[i+1] ~= nil then
if stress == "." then
if not isStressed(word[i-1], word[i-2]) and mw.ustring.match(word[i+2], "[dntz]") then
if result[i+1] ~= nil then
table.insert(newWord, "3")
if mw.ustring.match(result[i+1], "[ntzdr]") then
table.insert(newWord, "3")
elseif result[i+2] ~= nil then
if mw.ustring.match(result[i+1], "[%.ˌˈ]") and mw.ustring.match(result[i+2], "[ntzdr]") then
table.insert(newWord, "3")
else
table.insert(newWord, "e")
end
else
table.insert(newWord, "e")
end
else
else
table.insert(newWord, "e")
table.insert(newWord, "e")
Line 160: Line 153:
-- now let's do consonants
-- now let's do consonants
elseif val == "b" then
elseif val == "b" then
if ((word[i-1] == ".") or (word[i-1] == "ˌ") or (word[i-1] == "ˈ")) and (word[i-2] == "m") then
if ((result[i-1] == ".") or (result[i-1] == "ˌ") or (result[i-1] == "ˈ")) and (result[i-2] == "m") then
table.insert(newWord, "8")
table.insert(newWord, "8")
else
else