モジュール:khb-pron
このモジュールについての説明文ページを モジュール:khb-pron/doc に作成できます
-- For New Tai Lue script only
local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local initials = {
['ᦀ'] = {ipa = 'ʔ', class = 'high'}, ['ᦁ'] = {ipa = 'ʔ', class = 'low'},
['ᦂ'] = {ipa = 'k', class = 'high'}, ['ᦃ'] = {ipa = 'x', class = 'high'}, ['ᦄ'] = {ipa = 'ŋ', class = 'high'},
['ᦅ'] = {ipa = 'k', class = 'low'}, ['ᦆ'] = {ipa = 'x', class = 'low'}, ['ᦇ'] = {ipa = 'ŋ', class = 'low'},
['ᦈ'] = {ipa = 't͡s', class = 'high'}, ['ᦉ'] = {ipa = 's', class = 'high'}, ['ᦊ'] = {ipa = 'j', class = 'high'},
['ᦋ'] = {ipa = 't͡s', class = 'low'}, ['ᦌ'] = {ipa = 's', class = 'low'}, ['ᦍ'] = {ipa = 'j', class = 'low'},
['ᦎ'] = {ipa = 't', class = 'high'}, ['ᦏ'] = {ipa = 'tʰ', class = 'high'}, ['ᦐ'] = {ipa = 'n', class = 'high'},
['ᦑ'] = {ipa = 't', class = 'low'}, ['ᦒ'] = {ipa = 'tʰ', class = 'low'}, ['ᦓ'] = {ipa = 'n', class = 'low'},
['ᦔ'] = {ipa = 'p', class = 'high'}, ['ᦕ'] = {ipa = 'pʰ', class = 'high'}, ['ᦖ'] = {ipa = 'm', class = 'high'},
['ᦗ'] = {ipa = 'p', class = 'low'}, ['ᦘ'] = {ipa = 'pʰ', class = 'low'}, ['ᦙ'] = {ipa = 'm', class = 'low'},
['ᦚ'] = {ipa = 'f', class = 'high'}, ['ᦛ'] = {ipa = 'v', class = 'high'}, ['ᦜ'] = {ipa = 'l', class = 'high'},
['ᦝ'] = {ipa = 'f', class = 'low'}, ['ᦞ'] = {ipa = 'v', class = 'low'}, ['ᦟ'] = {ipa = 'l', class = 'low'},
['ᦠ'] = {ipa = 'h', class = 'high'}, ['ᦡ'] = {ipa = 'd', class = 'high'}, ['ᦢ'] = {ipa = 'b', class = 'high'},
['ᦣ'] = {ipa = 'h', class = 'low'}, ['ᦤ'] = {ipa = 'd', class = 'low'}, ['ᦥ'] = {ipa = 'b', class = 'low'},
['ᦦ'] = {ipa = 'kʷ', class = 'high'}, ['ᦧ'] = {ipa = 'xʷ', class = 'high'},
['ᦨ'] = {ipa = 'kʷ', class = 'low'}, ['ᦩ'] = {ipa = 'xʷ', class = 'low'},
['ᦪ'] = {ipa = 'sʷ', class = 'high'}, ['ᦫ'] = {ipa = 'sʷ', class = 'low'},
['ᦈ^'] = {ipa = 't͡ɕ', class = 'high'}, ['ᦉ^'] = {ipa = 'ɕ', class = 'high'},
['ᦋ^'] = {ipa = 't͡ɕ', class = 'low'}, ['ᦌ^'] = {ipa = 'ɕ', class = 'low'},
['ᦪ^'] = {ipa = 'ɕʷ', class = 'high'}, ['ᦫ^'] = {ipa = 'ɕʷ', class = 'low'},
}
local vowels = {
[''] = 'a', ['ᦱ'] = 'aː', ['ᦲ'] = 'i', ['ᦳ'] = 'u', ['ᦴ'] = 'uː', ['ᦳ+'] = 'uː',
['ᦵ'] = 'e', ['ᦶ'] = 'ɛ', ['ᦷ'] = 'o', ['ᦸ'] = 'ɔ', ['ᦹ'] = 'ɯ', ['ᦵᦲ'] = 'ɤ',
['ᦺ'] = 'aj', ['ᦻ'] = 'aːj', ['ᦼ'] = 'uj', ['ᦽ'] = 'oj', ['ᦾ'] = 'ɔj', ['ᦿ'] = 'ɯj', ['ᦵᧀ'] = 'ɤj',
['ᦲ+'] = 'iː', ['ᦵ+'] = 'eː', ['ᦶ+'] = 'ɛː', ['ᦷ+'] = 'oː', ['ᦸ+'] = 'ɔː', ['ᦹ+'] = 'ɯː', ['ᦵᦲ+'] = 'ɤː',
-- might read differently by regions
['ᦲ?'] = 'i(ː)', ['ᦳ?'] = 'u(ː)', ['ᦴ?'] = 'u(ː)',
['ᦵ?'] = 'e(ː)', ['ᦶ?'] = 'ɛ(ː)', ['ᦷ?'] = 'o(ː)',
['ᦸ?'] = 'ɔ(ː)', ['ᦹ?'] = 'ɯ(ː)', ['ᦵᦲ?'] = 'ɤ(ː)',
}
local finals = {
[''] = '', ['ᧁ'] = 'w',
['ᧂ'] = 'ŋ', ['ᧃ'] = 'n', ['ᧄ'] = 'm',
['ᧅ'] = 'k̚', ['ᧆ'] = 't̚', ['ᧇ'] = 'p̚',
['#'] = 'ʔ', -- non-final with ᦰ
}
local tones = {
[''] = {high = '˥', low = '˥˩'},
['ᧈ'] = {high = '˧˥', low = '˧'}, -- also checked syllable
['ᧉ'] = {high = '˩˧', low = '˩'},
['$'] = {high = '', low = ''}, -- toneless syllable
}
function export.show(frame)
local args = frame:getParent().args
local text = args[1] or PAGENAME -- supports only one pronunciation
local debug = args['d'] or nil
local qualifier = args['q'] or nil
local ipa = {}
local haveToneless = false
text = mw.ustring.gsub(text, '᧞', 'ᦶᦜ')
text = mw.ustring.gsub(text, '᧟', 'ᦶᦜᧁ')
for syl in mw.text.gsplit(text, '[ %.%-]') do
syl = mw.ustring.gsub(syl, '([ᦵᦶᦷᦺ])([ᦀ-ᦫ])', '%2%1') -- for easier detection
local i, v, f, t, s = mw.ustring.match(syl, '^([ᦀ-ᦫ])([ᦱ-ᧀ%+%?]*)([ᧁ-ᧇ]?)([ᧈᧉ%$]?)(ᦰ?)$')
if mw.ustring.match(i, '^([ᦈᦉᦋᦌᦪᦫ])$') and mw.ustring.match(v, '^([ᦲᦵᦶ]%+?)$') then
i = i .. '^'
end
if f == '' then
if s == '' then
if v == '' then
t = '$'
elseif v == 'ᦳ' and t == '' then
f = '#'
t = 'ᧈ'
elseif (mw.ustring.match(v, '^([ᦲᦵᦶᦷᦸᦹ])$') or v == 'ᦵᦲ') and t ~= '$' then
v = v .. '+'
end
else --s == 'ᦰ'
f = '#'
if t == '' then
t = 'ᧈ'
end
end
end
if f == 'ᧅ' or f == 'ᧆ' or f == 'ᧇ' then
if (mw.ustring.match(v, '^([ᦲᦳᦵᦶᦷᦸᦹ])$') or v == 'ᦵᦲ') and t == 'ᧈ' then
v = v .. '+'
else
t = 'ᧈ'
end
end
if t == '$' then
haveToneless = true
end
if debug then
table.insert(ipa, '['..(i or '-')..']['..(v or '-')..']['..(f or '-')..']['..(t or '-')..']['..(s or '-')..']')
else
table.insert(ipa, initials[i].ipa .. vowels[v] .. finals[f] .. tones[t][initials[i].class])
end
end
return '* ' .. (qualifier and frame:expandTemplate{title = 'qualifier', args = {qualifier}} .. ' ' or '') .. '[[w:国際音声記号|IPA]]<sup>([[付録:タイ・ルー語の発音表記|?]])</sup>: <span class="IPA">/' .. table.concat(ipa, '.') .. '/</span>[[カテゴリ:タイ・ルー語 国際音声記号あり]]' .. (#ipa > 0 and '[[カテゴリ:タイ・ルー語 ' .. #ipa .. '音節語]]' or '') .. (haveToneless and '[[カテゴリ:タイ・ルー語 terms with toneless syllable]]' or '')
end
return export