local export = {}
local pron = {}
local m_para = require("Module:parameters")
local m_lang = require("Module:languages")
local m_IPA = require("Module:IPA")
local m_amf = "Module:amf-utilities"
local PAGENAME = mw.loadData("Module:headword/data").pagename
local gsub = mw.ustring.gsub
local lower = mw.ustring.lower
local split = mw.text.split
local insert = table.insert
local concat = table.concat
local GRAVE = "\204\128"
local ACUTE = "\204\129"
local CIRCUM = "\204\130"
local RETRACT = "\204\160"
local gvowel = "\204??" -- generic vowel
local encode = {
= "A",
= "B",
= "C",
= "D",
= "E",
= "G",
= "ɡ",
= "I",
= "J",
= "K",
= "N",
= "O",
= "Q",
= "T",
= "X",
= "Z",
}
function export.encode(text)
-- universal encoder
text = mw.ustring.toNFD(text)
mw.log(text:match(""))
return text
:gsub("", encode)
:gsub("ʼ", encode)
:gsub("sh", "S")
end
function export.decode(text)
local decode = {}
for m, n in pairs(encode) do decode = m end
return text:gsub(".", decode)
end
function export.make(frame)
local lang = frame.args
local params = {
= { list = true, default = PAGENAME },
}
if pron and pron.params then
for key, val in pairs(pron.params) do
params = val
end
end
local args = m_para.process(frame:getParent().args, params)
local data = {
lang = m_lang.getByCode(lang, true),
items = args
}
if pron then
pron.func(args, data)
else
pron.func(args, data)
end
return m_IPA.format_IPA_full(data)
end
--[[
Currently missing:
- Karo (kxh)
- Gayil (gyl)
Gayil's phonology is not well documented, only being briefly touched on in
Tsuge, 2006; this might still be enough to integrate it into generic, though.
Karo's is undocumented, as far as I can tell; at least, not to any useful
degree.
]]--
pron = {
-- supports: aiw, dim
func = function(args, data)
-- Seyoum, Mulugeta (2008) A Grammar of Dime, LOT Publications
-- Hayward, Richard J. (1990) "Notes on the Aari Language", in Omotic Language Studies, Routledge, ppg. 425-493 of 666
local ret = {}
local correspondences = {
J = "dʒ",
K = "tʃ",
S = "ʃ",
y = "j",
Z = "ʒ",
}
for _,i in ipairs(args) do
i = export.encode(lower(i))
i = i:gsub("(..?)%1", "%1ː")
:gsub("n()", "n" .. RETRACT .. "%1")
:gsub("^()", "%1ʰ")
:gsub("s" .. GRAVE .. "’", "tsʼ")
:gsub("s" .. GRAVE, "ts")
:gsub("ds", "dz")
:gsub("$", {
= "χ",
= "ɸ",
})
:gsub(gvowel .. "" .. gvowel, {
= "ʁ",
= "ɸ",
})
:gsub("nq", "ɴq")
insert(ret, { pron = "" })
end
data.items = ret
end
}
pron = {
func = function(args, data)
-- Petrollino, Sara (2016) A Grammar of Hamar: A South Omotic language of Ethiopia, Leiden University
local utilities = require(m_amf)
local correspondences = {
c = "tʃ",
g = "ɡ",
j = "dʒ",
y = "j",
B = "ɓ",
C = "tʃʼ",
D = "ɗ",
E = "ɛ",
G = "ɠ",
N = "ɲ",
O = "ɔ",
S = "ʃ",
T = "tʼ",
Q = "ʔ",
L = "ː", -- long
X = "\204\164", -- breathy
H = "\204\165", -- voiceless
}
local V = ""
-- custom version of utilities.combine
local function combine(syllables)
local a,f = syllables.accent, syllables.falling
local diacritic = f and "\204\130" or "\204\129"
local word = "" -- do not use table.concat to avoid modifying input
for i,syl in ipairs(syllables) do
if i == a then
syl = syl:gsub("","%0"..diacritic)
end
word = word .. syl
end
word = word:gsub("",correspondences)
return mw.ustring.toNFC(word)
end
local function pron(text)
text = utilities.syllabify(text)
if text.accent == 0 then
text.accent = 1
end
for i, syl in ipairs(text) do
text = syl:gsub("()%1", "%1L")
:gsub("cc", "tc")
end
text = text:gsub("^()", "ʔ%1")
return text
end
local function phon(text,last)
local C = "rCDB"
for i=1,#text do
if i>1 and text:sub(-1,-1):match("") then
text = text:gsub("^", {r="ɾ", C="c", D="d", B="β"})
:gsub("^ba", "βa")
end
if text:sub(-1,-1) == "n" and i<#text and text:sub(1,1):match("") then
text = text:gsub("n$", "ŋ")
end
text = text:gsub("^T()", "tsʼ%1")
text = text:gsub("n()$", "ŋ%1")
end
text = text:gsub("^Du", "ʔu")
:gsub("^ha", "a̤")
:gsub("^q", {qa="qʼa",qe="qʰe",qi="qʰi",qE="qʰE",qO="qʰO",qo="ʔo",qu="ʔu"})
if not text:find("ʰ") then
text = text:gsub("^()", "%1ʰ")
end
text = text:gsub("tʰsʼ", "tsʼ")
text = text:gsub("$", {p="p̚",b="b̚",B="ɓ̚",m="m̥",n="n̥",r="r̥",l="l̥"})
if text.accent ~= #text then
text = text:gsub("^q()$", "qʰ%1")
end
if last then -- make the utterance-final vowel (short/long/diphthong) breathy if stressed, voiceless if unstressed
text = text:gsub("+R?$", function(vowels)
vowels = vowels:gsub("","%1"..(text.accent == #text and "X" or "H"))
return vowels
end)
end
return text
end
local results = {}
for _, term in ipairs(args) do
local phonemic, phonetic = {}, {}
local words = split(term, " ", true)
for i,word in ipairs(words) do
local syllabified = pron(word)
phonemic = combine(syllabified)
phonetic = combine(phon(syllabified,i==#words))
end
phonemic = concat(phonemic, " ")
phonetic = concat(phonetic, " ")
insert(results, { pron = "/" .. phonemic .. "/" })
if phonemic ~= phonetic then
insert(results, { pron = "" })
end
end
data.items = results
end
}
return export