A modult a Modul:dng-pron/doc lapon tudod dokumentálni
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 initialConv = {
= "p", = "t", = "k",
= "pʰ", = "tʰ", = "kʰ",
= "t͡s", = "ʈ͡ʂ",
= "t͡sʰ", = "ʈ͡ʂʰ",
= "m", = "n", = "ŋ",
= "f", = "s", = "ʂ", = "ɕ", = "x",
= "v", = "l", = "ʐ", = "", = "l",
= "",
}
local finalConv = {
= "z̩", = "ɛɻ",
= "a", = "ɔ", = "ə",
= "ɛ", = "ei", = "ou",
= "æ̃", = "əŋ", = "ɑŋ", = "uŋ",
= "i", = "ia", = "iə",
= "iɔː", = "iou",
= "iæ̃", = "iŋ", = "iɑŋ",
= "u", = "ua", = "uɛ", = "uə",
= "uɛi", = "uei",
= "uæ̃", = "uɑŋ",
= "y", = "yə",
= "yæ̃", = "yŋ",
}
local toneConv = {
= "²⁴", = "⁵¹", = "⁴⁴", = "⁰",
}
local function fix(initial, final)
return initial, final
end
local function warn(initial, final, tone)
if not initialConv then
error("Invalid initial: " .. initial)
end
if not finalConv then
error("Invalid final: " .. final)
end
if tone == "4" then
error("Tone 4 currently not supported")
end
end
function export.convert(text, scheme)
if type(text) == "table" then
text, scheme = text.args, text.args
end
local result = {}
for word in gsplit(text, '/') do
local converted = {}
local extra2 = match(word, '^*')
for syllable in gmatch(word, '+*') do
local initial, final, erhua, tone, extra = match(syllable, '^(?)(+)(р?)()(*)$')
local caps = false
initial = initial or ''
if find(initial .. final, '') then
caps = true
initial, final = lower(initial), lower(final)
end
warn(initial, final, tone)
initial, final = fix(initial, final)
if final == 'э' and erhua == 'р' then
final, erhua = 'эр', ''
end
if scheme == 'IPA' then
initial = initialConv
final = finalConv
tone = toneConv
--[[
if erhua == 'r' then
if find(final, '^y') then -- 撮口呼
final = 'yɚ'
elseif find(final, '^i') then -- 齊齒呼
final = 'iɚ'
elseif find(final, '^u') then -- 合口呼
final = 'uɚ'
elseif (final == 'o' or final == 'oŋ') and find(initial, '^') then
final = 'ɚ'
elseif final == 'o' or final == 'oŋ' then
final = 'uɚ'
else -- 開口呼
final = 'ɚ'
end
end
--]]
syllable = initial .. final .. tone
syllable = gsub(syllable, 'ʈ͡ʂ(ʰ?)', 't͡ɕ%1')
syllable = gsub(syllable, 'ʂ(ʰ?)', 'ɕ%1')
syllable = gsub(syllable, '(ʂʰ?)z̩', '%1ʐ̩')
syllable = gsub(syllable, 'ʐz̩', 'ʐ̩')
table.insert(converted, syllable)
else
error('Convert to what representation?')
end
end
if scheme == 'IPA' then
local text = '/' .. table.concat(converted, ' ') .. '/'
table.insert(result, text)
end
end
if scheme == 'IPA' then
return table.concat(result, ', ')
end
end
function export.process(text)
local readings = {}
for reading in gsplit(text, '/') do
local tones = {}
for tone in gmatch(reading, '%d+') do
tone = gsub(tone, "()", { = "I", = "II", = "III"})
table.insert(tones, tone)
end
local cyr = gsub(reading, '%d', '')
local lat = require('Module:dng-translit').tr(cyr, nil, 'Cyrl')
table.insert(readings, string.format("] (%s, %s)", cyr, cyr, lat, table.concat(tones, '-')))
end
return table.concat(readings, ' / ')
end
return export