A modult a Modul:wuu-pron/doc lapon tudod dokumentálni
local export = {}
local initial = {
= "p", = "pʰ", = "b̻", = "m", = "ʔm", = "f", = "v̻",
= "t", = "tʰ", = "d̻", = "n", = "ʔn", = "l", = "ʔl",
= "t͡s", = "t͡sʰ", = "s", = "z̻", = "t͡ɕ", = "t͡ɕʰ",
= "d̥͡ʑ", = "n̠ʲ", = "ʔn̠ʲ", = "ɕ", = "ʑ̻", = "k",
= "kʰ", = "ɡ̊", = "ŋ", = "ʔŋ", = "h", = "ʔ", = "ɦ", = ""
}
local final = {
= "a̱", = "o", = "ɔ", = "ɜ", = "e̞", = "ø", = "i",
= "ia̱", = "io", = "iɔ", = "iɜ", = "v̩ʷ", = "ɯa̱",
= "ɯe̞", = "v̩ʷø", = "y", = "yø", = "ã", = "ɑ̃",
= "əɲ", = "ʊŋ", = "a̱ʔ", = "ʊʔ", = "əʔ", = "iã",
= "iɑ̃", = "ɪɲ", = "i̯ʊŋ", = "ia̱ʔ", = "i̯ʊʔ", = "i̯ɪʔ",
= "ɯã", = "ɯɑ̃", = "ɯə̯ɲ", = "ɯa̱ʔ", = "ɯə̯ʔ", = "ʏɲ",
= "ɥ̯ɪʔ", = "əɻ", = "z̩"
}
local tone_contours = {
= "", = "³³",
= "⁵³", = "³⁴", = "²³", = "⁵⁵", = "¹²",
= "⁵⁵ ²¹", = "³³ ⁴⁴", = "²² ⁴⁴", = "³³ ⁴⁴", = "¹¹ ²³",
= "⁵⁵ ³³ ²¹", = "³³ ⁵⁵ ²¹", = "²² ⁵⁵ ²¹", = "³³ ⁵⁵ ²¹", = "¹¹ ²² ²³",
= "⁵⁵ ³³ ³³ ²¹", = "³³ ⁵⁵ ³³ ²¹", = "²² ⁵⁵ ³³ ²¹", = "³³ ⁵⁵ ³³ ²¹", = "²² ⁵⁵ ³³ ²¹",
= "⁵⁵ ³³ ³³ ³³ ²¹", = "³³ ⁵⁵ ³³ ³³ ²¹", = "²² ⁵⁵ ³³ ³³ ²¹", = "³³ ⁵⁵ ³³ ³³ ²¹", = "²² ⁵⁵ ³³ ³³ ²¹",
= "⁴⁴", = "³³", = "⁴⁴", = "²²",
= "³³", = "³³", = "³³", = "³³",
}
local syllabic = {
= "m̩", = "ŋ̍",
= "ʔm̩", = "ʔŋ̍"
}
local tone_table = {
= "A",
= "B",
= "C",
= "D",
}
local function determ_syl(text)
local voicing, coda = "voiceless", "unchecked"
if text:find("^") or text:find("^m") or text:find("^n") or text:find("jj") or text:find("xx") or text:find("hh") then
voicing = "voiced"
end
if text:find("q$") then
coda = "checked"
end
return voicing, coda
end
local function tone_determ(text)
local voicing, coda = determ_syl(text)
return tone_table
end
local function rom_check(text)
local tone = text:sub(1, 1)
text = mw.text.split(text:sub(2, -1), " ")
local voicing, coda = determ_syl(text)
if text:find("h?") or text:find("^z") or text:find("^ni") then
error("Invalid syllable: " .. text .. ". Palatalisation expected.")
end
if voicing == "voiced" and tone:find("") then
error("Invalid syllable: " .. text .. tone .. ". Voiced initials only occur in tones 3 and 5.")
elseif voicing == "voiceless" and tone:find("") then
error("Invalid syllable: " .. text .. tone .. ". Voiceless initials only occur in tones 1, 2 and 4.")
end
if coda == "checked" and tone:find("") then
error("Checked syllables only occur in tones 4 and 5.")
elseif coda ~= "checked" and tone:find("") then
error("Unchecked syllables only occur in tones 1, 2 and 3.")
end
return nil
end
function export.ipa_conv(original_text)
if type(original_text) == "table" then original_text = original_text.args end
original_text = mw.ustring.lower(original_text)
local text, conv_text = "", ""
local reading = mw.text.split(original_text, ",", true)
local syllable = {}
local syl_tone = {}
for reading_index = 1, #reading, 1 do
local components = mw.text.split(reading, "&", true)
for component_index = 1, #components do
local indep_words = mw.text.split(components, "+", true)
for indep_index = 1, #indep_words do
text = indep_words
local no_syllables = string.len(text:gsub("", "")) + 1
rom_check(text)
local tone = tone_contours or error("Tone notation is incorrect. See ].")
text = text:sub(2, -1)
local syllable = mw.text.split(text, " ", true)
local syl_tone = mw.text.split(tone, " ", true)
for i = 1, no_syllables, 1 do
if i == no_syllables and indep_words and tone ~= "³³" then
syl_tone = tone_contours) .. "-" ..
(no_syllables > 1 and "multiple" or "single")]
end
syllable = export.ipa_syl_conv(syllable)
syllable = syllable .. syl_tone
end
indep_words = table.concat(syllable, " ")
end
components = table.concat(indep_words, " ")
end
reading = table.concat(components, " ")
end
return table.concat(reading, "/, /")
end
function export.ipa_syl_conv(text)
if text:find("^%'?h?h??g?$") then
text = text:gsub("^(%'?h?h?)(?g?)$", function(a, b) return (initial or '') ..
(syllabic or syllabic or error(("Invalid syllable: \"%s\""):format(text))) end)
elseif text:find("^%'?ny") then
text = text:gsub("^(?ny)(???)$",
function(a, b) return initial .. (final or error(("Unrecognised final: \"%s\""):format(b))) end)
elseif text:find("^???h????$") then
text = text:gsub("^(????)(???)$",
function(a, b) return
(initial or error(("Unrecognised initial: \"%s\""):format(a))) ..
(final or error(("Unrecognised final: \"%s\""):format(b))) end)
else
return error(("Invalid syllable: \"%s\""):format(text))
end
return text
end
function export.rom(text)
if type(text) == 'table' then text = text.args end
text = mw.text.split(text, ",", true)
for i = 1, #text, 1 do
local parts = mw.text.split(text, '+', true)
for i = 1, #parts do
if string.find(parts, '^') then
parts = parts:sub(2,-1) .. ' (T' .. parts:sub(1,1) .. ')'
end
end
text = table.concat(parts, ' + ')
end
return table.concat(text, "; ")
end
return export