Shan pronunciation module.
local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local lang = require("Module:languages").getByCode("shn")
local initials = {
= 'k', = 'kʰ', = 'ɡ', = 'ŋ',
= 't͡ɕ', = 'z', = 'ɲ',
= 't', = 'tʰ', = 'd', = 'n',
= 'p', = 'pʰ', = 'f', = 'b', = 'm',
= 'j', = 'r', = 'l', = 'w',
= 'θ', = 'sʰ', = 'h', = 'ʔ',
= 'ʃ', = 'd͡ʑ', = 't͡ɕʰ',
}
local medials = {
= '', = 'j', = 'r', = 'w',
}
local vowels = {
= 'a', = 'aː', = 'aː', = 'i', = 'iː', = 'u', = 'uː', = 'o',
= 'eː', = 'e', = 'ɛː', = 'ɛ', = 'ɔ',
= 'aw', = 'aːw', = 'iw', = 'ew', = 'ɛw',
= 'ɯ', = 'ɯː', = 'ɤ', = 'ɤː', = 'oː', = 'ɔː', = 'aɰ',
= 'ɔ̯aː', -- rare e.g. ငွႃႉ / တွႃး / တွႃႇရႃႉ / တွႃႉ / ၵွႃႇ / ၸွႃ / ၸီးပွႃးယေး / except ၵျွႃး = ၵျႃး
= '', -- pure consonant sound
}
local finals = {
= '', = 'k̚', = 'ŋ', = 't̚', = 'n',
= 'p̚', = 'm', = 'j',
}
local tones = {
= '˨˦', = '˩', = '˧˧˨', = '˥', = '˦˨ˀ', = '˧',
= '', -- no tone for !
}
function export.show(frame)
local args = frame:getParent().args
local text = args or PAGENAME -- supports only one pronunciation
local debug = args or nil
local qualifier = args or nil
local audioFile = args or args or nil -- not to use the expensive 'exists' property
local ipa = {}
local rhyme
for syl in mw.text.gsplit(text, '') do
syl = mw.ustring.gsub(syl, 'ႆ', 'ၺ်') -- for easier detection
local i, m, v, f, t = mw.ustring.match(syl,
'^()(?)(*)(*)(?)$')
if not i then
error("Pattern did not match the syllable " .. tostring(syl) .. ".")
end
if i == 'သ' and m == 'ျ' then
i = 'သျ'
m = ''
end
if i == 'ၵ' and m == 'ျ' then
i = 'ၵျ'
m = ''
end
if i == 'ၶ' and m == 'ျ' then
i = 'ၶျ'
m = ''
end
if m == 'ႂ' and v == '်' then
m = ''
v = 'ႂ်'
end
if v == 'ူ' and f ~= '' then
v = 'ူ*'
end
if v == '!' then
t = 'x'
end
if debug then
table.insert(ipa, '')
else
local missing
for _, part in pairs {
{ 'initial', initials, i },
{ 'medial', medials, m },
{ 'vowel', vowels, v },
{ 'final', finals, f },
{ 'tone', tones, t },
} do
if not part] then
missing = missing or require 'Module:array'()
table.insert(missing, part)
end
end
if missing then
error('Data for '
.. missing
:map(
function (part)
return part .. ' (' .. tostring(part) .. ')'
end)
:concat(', ') .. (missing and ' are' or ' is')
.. ' missing.')
end
table.insert(ipa, initials .. medials .. vowels .. finals .. tones)
rhyme = vowels .. finals -- This is meant to overwrite previous syllable.
end
end
return "* " .. (qualifier and require("Module:qualifier").format_qualifier({qualifier}) .. " " or "") ..
require("Module:IPA").format_IPA_full { lang = lang, items = {{pron = "/" .. table.concat(ipa, ".") .. "/"}} } .. "\n" ..
(audioFile and "*" .. require("Module:audio").format_audio { lang = lang, file = audioFile } .. "\n" or "") ..
(rhyme and "*" .. require("Module:rhymes").format_rhymes { lang = lang, rhymes = {{rhyme = rhyme}} } or "") ..
(#ipa > 0 and require("Module:utilities").format_categories("Shan " .. #ipa .. "-syllable words", lang) or "")
end
return export