This module generates the phonemic IPA transcription of Akkadian entries. It runs Template:akk-IPA. The testcases are here.
local export = {}
local s = mw.ustring.gsub
local m = mw.ustring.match
local C = ""
local V = ""
local c = {
{"ṭ", "tˤ"},
{"ṣ", "sˤ"},
{"š", "ʃ"},
{"y", "j"},
{"g", "ɡ"},
{"ḫ", "χ"},
{"'", "ʔ"},
{"(" .. V .. C .. "?ˤ?)(" .. C .. "ˤ?)%f" .. V, "%1.%2"}
}
local d = {
{"", "aː"},
{"", "eː"},
{"", "iː"},
{"", "uː"}
}
function export.pronunciation_phonemic(word)
word = mw.ustring.lower(word)
for a = 1, #c do
word = s(word, c, c)
end
local N = {}
local i = 0
for a in string.gmatch(word, "%S+") do
i = i+1
N = a
end
for a = 1, #N do
if m(N, C .. "?ˤ?$") ~= nil then --last syllable is ultraheavy (circumflex)
N = s(N, "%.?(" .. C .. "?ˤ?)$", "ˈ%1") --final stress
elseif m(N, C .. "?ˤ?" .. C .. "ˤ?$") ~= nil then --again (any long V, + C)
N = s(N, "%.?(" .. C .. "?ˤ?" .. C .. "ˤ?)$", "ˈ%1") --final stress
elseif m(s(N, C .. "ˤ?" .. V .. C .. "?ˤ?$", ""), C .. "?ˤ?" .. "%.") ~= nil or m(s(N, C .. "ˤ?" .. V .. C .. "?ˤ?$", ""), C .. "?ˤ?" .. "" .. C .. "ˤ?%.") ~= nil then --otherwise, detects if there is (not where it is) a non-final heavy or ultraheavy syllable (long V, or any non-circumflex + C)
local n = ""
for b = 1, 5 do --arbitrary, find how to count syllables
N = s(N, "%.?(" .. C .. "?ˤ?" .. "%." .. n .. C .. "ˤ?" .. V .. C .. "?ˤ?)$", "ˈ%1") --long V
N = s(s(N, "%.?(" .. C .. "?ˤ?" .. "" .. C .. "ˤ?%." .. n .. C .. "ˤ?" .. V .. C .. "?ˤ?)$", "ˈ%1"), "ˈˈ", "ˈ") --non-circumflex + C
n = n .. C .. "ˤ?%." --+1 light syllable
end
else --no non-final heavy nor ultraheavy syllable detected, ie. there are only non-final light ones
N = s(N, "^( ?)(" .. C .. "?ˤ?%.)", "%1ˈ%2") --initial stress
end
end
word = table.concat(N, " ")
for a = 1, #d do
word = s(word, d, d)
end
return word
end
function export.show(frame)
local results = {}
table.insert(results, {pron = "/" .. export.pronunciation_phonemic(mw.title.getCurrentTitle().text) .. "/"})
return "* " .. require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("akk"), items = results }
end
return export