This module generates the phonemic and phonetic IPA transcription of Afar entries. It runs Template:aa-IPA. The testcases are here. The first parameter is the spelling, with stress, and there can be as many pronunciations as needed.
local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("aa")
local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower
local V = ""
local C = ""
local Ci = ""
local phon = {
="a", ="b", ="ħ", ="d", ="e", ="f",
="ɡ", ="h", ="i", ="ɟ", ="k", ="l",
="m", ="n", ="o", ="p", ="ʕ", ="r",
="s", ="t", ="u", ="w", ="ɖ", ="j",
="z", ="aˈ", ="eˈ", ="iˈ", ="oˈ", ="uˈ",
="aˌ", ="eˌ", ="iˌ", ="oˌ", ="uˌ",
}
local function phonemic(text)
text = rlower(text)
-- general phonology
text = rsub(text, ".", phon)
-- digraphs
text = rsub(text, "(" .. V .. ")(?)%1", "%1ː%2")
text = rsub(text, "sh", "ʃ")
text = rsub(text, "(" .. C .. "?)(" .. V .. "ː?)()", "%3%1%2")
text = rsub(text, "(" .. C .. ")%1", "%1ː")
text = rsub(text, "ɟ", "d͡ʒ")
return(text)
end
local function phonetic(text)
text = phonemic(text)
-- retroflex
text = rsub(text, "(" .. V .. "?)ɖ(" .. V .. ")", "%1ɽ%2")
text = rsub(text, "n(?)ɖ", "ɳ%1ɖ")
text = rsub(text, "s(?)ɖ", "ʂ%1ɖ")
-- other consonants
text = rsub(text, "n(?)()", "ŋ%1%2")
text = rsub(text, "r", "ɾ")
text = rsub(text, "ɾː", "rː")
text = rsub(text, "ɾ()ɾ", "r%1r")
text = rsub(text, "()()", "%1ʰ%2")
text = rsub(text, "()$", "ʰ%1")
-- vowels
text = rsub(text, "^(?)(" .. V .. ")", "%1ʔ%2")
text = rsub(text, "a", "ʌ")
text = rsub(text, "e", "ɛ")
text = rsub(text, "i", "ɪ")
text = rsub(text, "o", "ɔ")
text = rsub(text, "u", "ʊ")
text = rsub(text, "ʕʌ", "ʕa")
text = rsub(text, "ʕɛ", "ʕe")
text = rsub(text, "ʕɪ", "ʕi")
text = rsub(text, "ʕɔ", "ʕo")
text = rsub(text, "ʕʊ", "ʕu")
text = rsub(text, "ʌː", "aː")
text = rsub(text, "ɛː", "eː")
text = rsub(text, "ɪː", "iː")
text = rsub(text, "ɔː", "oː")
text = rsub(text, "ʊː", "uː")
return(text)
end
function export.syllabify(term) --split for hyphenation
local H, i = {}, 0
for a in string.gmatch(rsub(term, "(" .. Ci .. "?)(" .. Ci .. ")%f", "%1.%2"), "+") do
i = i+1
H = a
end
return H
end
function export.show(frame)
local parent_args = frame:getParent().args
local params = {
= {list = true, required = true}
}
local args = require("Module:parameters").process(parent_args, params)
local p = args
local phol = {}
for _, word in ipairs(p) do
table.insert(phol, {pron = "/" .. phonemic(word) .. "/ "})
end
local H = ""
local title = mw.loadData("Module:headword/data").pagename
if mw.ustring.match(title, "^.+$") then
H = export.syllabify(title)
H = "\n* " .. require("Module:hyphenation").format_hyphenations { lang = lang, hyphs = {{hyph = H}} }
end
return "* " .. m_IPA.format_IPA_full { lang = lang, items = phol } .. H
end
return export