Pronunciation module for Bouyei. See {{pcc-pron}}
.
local export = {}
local find = mw.ustring.find
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local gsplit = mw.text.gsplit
local lower = mw.ustring.lower
local upper = mw.ustring.upper
local len = mw.ustring.len
-- https://en.wikipedia.orghttps://dictious.com/en/Bouyei_language
local initialConv = {
= 'p',
= 'pʰ',
= 'ɓ',
= 'm',
= 'f',
= 'v',
= 'w', -- to support /v/ ~ in some cases
= 't',
= 'tʰ',
= 'ɗ',
= 'n',
= 'ɬ',
= 'l',
= 'k',
= 'kʰ',
= 'ŋ',
= 'x',
= 'ɣ',
= 't͡ɕ',
= 't͡ɕʰ',
= 'ɲ',
= 'ɕ',
= 'j',
= 't͡s',
= 't͡sʰ',
= 's',
= 'z',
= 'pʲ',
= 'mʲ',
= 'ˀj',
= 'kʷ',
= 'ŋʷ',
= 'ˀv',
= 'ʔ',
}
local rimeConv = {
= 'a',
= 'o',
= 'ɔ',
= 'e',
= 'ɛ', -- e in Chinese loanwords
= 'i',
= 'z̩',
= 'u',
= 'ɯ',
= 'aːi',
= 'ɐi',
= 'oːi',
= 'ɯi',
= 'aːu',
= 'ɐu',
= 'eːu',
= 'iu',
= 'ɐɯ',
= 'iə',
= 'uə',
= 'ɯə',
= 'aːm',
= 'ɐm',
= 'oːm',
= 'ɔm',
= 'eːm',
= 'iəm',
= 'im',
= 'uəm',
= 'um',
= 'ɯəm',
= 'aːn',
= 'ɐn',
= 'oːn',
= 'ɔn',
= 'eːn',
= 'iən',
= 'in',
= 'uən',
= 'un',
= 'ɯən',
= 'ɯn',
= 'aːŋ',
= 'ɐŋ',
= 'oːŋ',
= 'ɔŋ',
= 'eːŋ',
= 'iəŋ',
= 'iŋ',
= 'uəŋ',
= 'uŋ',
= 'ɯəŋ',
= 'ɯŋ',
= 'aːp̚',
= 'ɐp̚',
= 'oːp̚',
= 'ɔp̚',
= 'eːp̚',
= 'iəp̚',
= 'ip̚',
= 'uəp̚',
= 'up̚',
= 'ɯəp̚',
= 'ɯp̚',
= 'aːt̚',
= 'ɐt̚',
= 'oːt̚',
= 'ɔt̚',
= 'eːt̚',
= 'iət̚',
= 'it̚',
= 'uət̚',
= 'ut̚',
= 'ɯət̚',
= 'ɯt̚',
= 'ɐk̚',
= 'ɔk̚',
= 'ek̚',
= 'ik̚',
= 'uk̚',
= 'ɯk̚',
= 'ia',
= 'io',
= 'iɐu',
= 'ua',
= 'ui',
= 'uɐi',
= 'aːu',
= 'əu',
= 'ɚ',
}
local toneConv = {
= '˨˦',
= '˩',
= '˥˧',
= '˧˩',
= '˧˥',
= '˧',
= '˧˥',
= '˧',
= '˧',
= '˧˩',
= '˥˧',
= '˨˦',
}
local function get_tone(syllable)
local toneless, tone = syllable, ""
if find(syllable, "$") then
toneless, tone = match(syllable, "(+)()$")
end
mw.log(toneless, tone)
return toneless, tone
end
local function syllabify(text)
text = gsub(text, "'", " ")
text = gsub(text, "()()", "%1 %2")
--text = gsub(text, "()()", "%1 %2")
return mw.text.gsplit(text, "")
end
function export.ipa(text)
text = string.lower(text)
local syllables = {}
for syllable in syllabify(text) do
local initial, rime, tone
syllable, tone = get_tone(syllable)
initial, rime = match(syllable, "^(??v?)(??g?)$")
if not initial or not rime then
error(syllable .. " cannot be recognized")
end
if find(tone, "^$") then
if initial == "e" then
initial = "ê"
elseif initial == "o" then
initial = "ô"
elseif initial == "i" and find(final, "^$") then
initial = "î"
end
end
local initial_ipa, rime_ipa, tone_value = initialConv, rimeConv, toneConv
if not initial_ipa then
error(initial .. " is not a valid initial")
elseif not rime_ipa then
error(rime .. " is not a valid rime")
end
table.insert(syllables, initial_ipa .. rime_ipa .. tone_value)
end
return "/" .. table.concat(syllables, ".") .. "/"
end
function export.show(frame)
local params = {
= { },
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local text = args
if not text then text = mw.title.getCurrentTitle().text end
local display = string.format("* %s",
require("Module:IPA").format_IPA_full {
lang = require("Module:languages").getByCode("pcc"),
items = {{ pron = export.ipa(text) }},
}
)
return display
end
return export