မဝ်ဂျူ:wuu-pron: အရာမတၞဟ်ခြာ အကြာ မူတၞဟ်ဂမၠိုင်

Content deleted Content added
Looks like the Mon edition isn't ready because of this: Lua error in မဝ်ဂျူ:wuu-pron at line 91: attempt to call field 'lower' (a nil value).
ဒစင်ဂမၠိုင်: ဟွံပ မကလေၚ်ပလေဝ်ဒါန်လဝ်
No edit summary
ဒစင်: မကလေၚ်ပလေဝ်ဒါန်လဝ်
လာင် ၁-
local export = {}
local data = mw.loadData("Module:wuu-pron/data")
 
--[=[
local initial = {
TODO:
["p"] = "p", ["ph"] = "pʰ", ["b"] = "b̻", ["m"] = "m", ["'m"] = "ʔm", ["f"] = "f", ["v"] = "v̻",
- do IPA for glottalised nasal intials (currently the glottal stop is dropped)
["t"] = "t", ["th"] = "tʰ", ["d"] = "d̻", ["n"] = "n", ["'n"] = "ʔn", ["l"] = "l", ["'l"] = "ʔl",
- FIND DATA FOR 3+ SYLLABLE SANDHI AND RPS!!! (we can settle for trisyllabics right)
["ts"] = "t͡s", ["tsh"] = "t͡sʰ", ["s"] = "s", ["z"] = "z̻", ["j"] = "t͡ɕ", ["q"] = "t͡ɕʰ",
- northern wu data: FIRST PRIORITY should be
["jj"] = "d̥͡ʑ", ["ny"] = "n̠ʲ", ["'ny"] = "ʔn̠ʲ", ["x"] = "ɕ", ["xx"] = "ʑ̻", ["k"] = "k",
- CHUANSHA 川沙 (sandhi found in 當代, needs. understanding)
["kh"] = "kʰ", ["g"] = "ɡ̊", ["ng"] = "ŋ", ["'ng"] = "ʔŋ", ["h"] = "h", ["'"] = "ʔ", ["hh"] = "ɦ", [""] = ""
- NEW KUNSHAN 崑山新派 (trisyllabic sandhi needed)
- HUZHOU 湖州 (trisyllabic sandhi needed)
- CIXI 慈溪 (慈溪方言研究 PDF exists but currently unretrieved, please inform @ND381 if a working PDF is in your possession ASAP!! zia-zia)
- any other northern wu points are good!! pls note the source u used in the EDIT SUMMARY if u do add one zia-zia
- MODULES for TAIZHOU & WENZHOU
→ and then we're done (probably)
]=]--
 
local loc_names = { -- Basic 聲韻調 Disyll LPS Trisyll LPS Quad+ LPS RPS Logic
['sh'] = 'Shanghai', -- + + + + + +
['jd'] = 'Jiading', -- + + + - - ?
['sj'] = 'Songjiang',-- + + + - - +
['cm'] = 'Chongming',-- + + + - + +
['sz'] = 'Suzhou', -- + + + + + +
-- ['ks'] = 'Kunshan', + + - - - - Wugniu "新派"
['cz'] = 'Changzhou',-- + + + - - +
['jx'] = 'Jiaxing', -- + + + - - +
['tx'] = 'Tongxiang',-- + + + - - +
['hn'] = 'Haining', -- + + + - + + Xiashi locality
['hy'] = 'Haiyan', -- + + + - - +
['hz'] = 'Hangzhou', -- + + + + + +
['sx'] = 'Shaoxing', -- + + + - + +
['nb'] = 'Ningbo', -- + + + - + +
}
 
-- default to "<loc_name> dialect" if empty
-- specifies the name of the Wikipedia article of the lect
local wiki_names = {
sh = 'Shanghainese',
jd = 'Taihu Wu',
sj = 'Taihu Wu',
jx = 'Taihu Wu',
tx = 'Taihu Wu',
hn = 'Taihu Wu',
hy = 'Taihu Wu'
}
 
local finalminidict = {
['sh'] = true,
["a"] = "a̱", ["o"] = "o", ["au"] = "ɔ", ["eu"] = "ɜ", ["e"] = "e̞", ["oe"] = "ø", ["i"] = "i",
['jd'] = true,
["ia"] = "ia̱", ["io"] = "io", ["iau"] = "iɔ", ["ieu"] = "iɜ", ["u"] = "v̩ʷ", ["ua"] = "ɯa̱",
['cm'] = true,
["ue"] = "ɯe̞", ["uoe"] = "v̩ʷø", ["y"] = "y", ["yoe"] = "yø", ["an"] = "ã", ["aan"] = "ɑ̃",
['sz'] = true,
["en"] = "əɲ", ["on"] = "ʊŋ", ["aq"] = "a̱ʔ", ["oq"] = "ʊʔ", ["eq"] = "əʔ", ["ian"] = "iã",
['cz'] = true,
["iaan"] = "iɑ̃", ["in"] = "ɪɲ", ["ion"] = "i̯ʊŋ", ["iaq"] = "ia̱ʔ", ["ioq"] = "i̯ʊʔ", ["iq"] = "i̯ɪʔ",
['jx'] = true,
["uan"] = "ɯã", ["uaan"] = "ɯɑ̃", ["un"] = "ɯə̯ɲ", ["uaq"] = "ɯa̱ʔ", ["ueq"] = "ɯə̯ʔ", ["yn"] = "ʏɲ",
['hz'] = true,
["yq"] = "ɥ̯ɪʔ", ["er"] = "əɻ", ["r"] = "z̩"
['sx'] = true,
['nb'] = true
}
 
local order = {'sh', 'jd', 'sj', 'cm', 'sz', 'cz', 'jx', 'tx', 'hn', 'hy', 'hz', 'sx', 'nb'}
local tone_contours = {
["1-0"] = "", ["1--"] = "³³",
["1-1"] = "⁵³", ["1-2"] = "³⁴", ["1-3"] = "²³", ["1-4"] = "⁵⁵", ["1-5"] = "¹²",
["2-1"] = "⁵⁵ ²¹", ["2-2"] = "³³ ⁴⁴", ["2-3"] = "²² ⁴⁴", ["2-4"] = "³³ ⁴⁴", ["2-5"] = "¹¹ ²³",
["3-1"] = "⁵⁵ ³³ ²¹", ["3-2"] = "³³ ⁵⁵ ²¹", ["3-3"] = "²² ⁵⁵ ²¹", ["3-4"] = "³³ ⁵⁵ ²¹", ["3-5"] = "¹¹ ²² ²³",
["4-1"] = "⁵⁵ ³³ ³³ ²¹", ["4-2"] = "³³ ⁵⁵ ³³ ²¹", ["4-3"] = "²² ⁵⁵ ³³ ²¹", ["4-4"] = "³³ ⁵⁵ ³³ ²¹", ["4-5"] = "²² ⁵⁵ ³³ ²¹",
["5-1"] = "⁵⁵ ³³ ³³ ³³ ²¹", ["5-2"] = "³³ ⁵⁵ ³³ ³³ ²¹", ["5-3"] = "²² ⁵⁵ ³³ ³³ ²¹", ["5-4"] = "³³ ⁵⁵ ³³ ³³ ²¹", ["5-5"] = "²² ⁵⁵ ³³ ³³ ²¹",
 
local ipa_initial = {
["A-single"] = "⁴⁴", ["B-single"] = "³³", ["C-single"] = "⁴⁴", ["D-single"] = "²²",
["A-multiplep"] = "³³p", ["B-multipleph"] = "³³", ["C-multipleb"] = "³³b", ["D-multiplem"] = "³³m", ["f"] = "f", ["v"] = "v",
["t"] = "t", ["th"] = "tʰ", ["d"] = "d", ["n"] = "n", ["l"] = "l",
["ts"] = "t͡s", ["tsh"] = "t͡sʰ", ["s"] = "s", ["z"] = "z", ["c"] = "t͡ɕ", ["ch"] = "t͡ɕʰ",
["dz"] = "d͡z", ["j"] = "d͡ʑ", ["gn"] = "n̠ʲ", ["sh"] = "ɕ", ["zh"] = "ʑ",
["k"] = "k", ["kh"] = "kʰ", ["g"] = "ɡ", ["ng"] = "ŋ", ["h"] = "h", ["gh"] = "ɦ",
[""] = "",
}
 
local syllabicipa_initial_override = {
--this always takes priority over the table above
["mm"] = "m̩", ["ngg"] = "ŋ̍",
--additional unique initials can also be defined here
["'mm"] = "ʔm̩", ["'ngg"] = "ʔŋ̍"
--a question mark means the initial does not exist
--there must be empty tables for all locations, even if there is nothing there
['sh'] = {
["dz"] = "?"
},
['jd'] = {
["dz"] = "?", ["zh"] = "?"
},
['sj'] = {
["p"] = "ɓ", ["t"] = "ɗ",
["f"] = "ɸ", ["v"] = "β",
["ch"] = "cʰ", ["c"] = "c", ["j"] = "ɟ", ["sh"] = "ç",
["zh"] = "?", ["dz"] = "?"
},
['cm'] = {
["v"] = "fv", ["z"] = "sz", ["zh"] = "ɕʑ", ["gh"] = "hɦ",
},
['sz'] = {
["dz"] = "?", ["zh"] = "?"
},
--[[['ks'] = {
["zh"] = "?", ["h"] = "x"
},]]
['cz'] = {
},
['jx'] = {
['dz'] = "?", ["vh"] = "ʔv"
},
['tx'] = {
},
['hn'] = {
},
['hy'] = {
["zh"] = "?"
},
['hz'] = {
["zh"] = "?"
},
['sx'] = {
},
['nb'] = {
}
}
 
local function get_initial(initial, loc)
local tone_table = {
return ipa_initial_override[loc][initial] or ipa_initial[initial] or error('Invalid initial: "' .. initial .. '"')
["voiceless-unchecked"] = "A",
end
["voiced-unchecked"] = "B",
 
["voiceless-checked"] = "C",
local function get_final(final, loc)
["voiced-checked"] = "D",
return data.ipa_final[loc][final] or error('Invalid final: "' .. final .. '"')
end
 
local ipa_syllabic = {
["m"] = "m̩", ["n"] = "n̩", ["ng"] = "ŋ̍",
}
 
-- diagnose tone error
local function determ_syl(text)
local function diagnose_tones(word_length, loc, text, tone, tone2, tone3)
local voicing, coda = "voiceless", "unchecked"
-- the cap on number of syllables
if text:find("^[bvdlzg]") or text:find("^m[^m]") or text:find("^n[^n]") or text:find("jj") or text:find("xx") or text:find("hh") then
local syl_cap = ({sh=5,sj=3,cm=3,sz=4,cz=3,jx=3,tx=3,hn=3,hy=3,hz=5,sx=3,nb=3})[loc]
voicing = "voiced"
if syl_cap and word_length > syl_cap then
error(("Maximum %d syllables supported for %s."):format(syl_cap, loc))
end
-- the cap on number of specified tones
if text:find("q$") then
local tone_cap = ({sj=3,ks=2,cz=3,jx=3,tx=3,hn=3,hy=2})[loc]
coda = "checked"
if tone_cap then
local expected = math.min(tone_cap, word_length)
local received = 1 + (tone2 ~= '' and 1 or 0) + (tone3 ~= '' and 1 or 0)
if received ~= expected then
error(('Expected %d tones, but received %d: "%s:%s".'):format(expected, received, loc, text))
end
elseif loc == 'sz' or loc == 'sx' then
-- sz: tone is 7 or 8, but second tone not provided
error("For " .. loc .. ", second tone must be specified.")
end
error(('Incorrect tone notation "%s" for %s. See [[WT:AZH/Wu]].'):format(tone..tone2..tone3, loc))
return voicing, coda
end
 
local function tone_determtone_superscript(text)
return text:gsub('[1-5]',{['1']='¹',['2']='²',['3']='³',['4']='⁴',['5']='⁵'})
local voicing, coda = determ_syl(text)
return tone_table[voicing .."-" .. coda]
end
 
local function rom_checkget_tone(text, loc)
local toneword_length = text:subgsub(1"[^ ]+", 1""):len() + 1
local tone, tone2, tone3 = text:match("^(.%u*)%w+ ?(%d?%u?)%w* ?(%d?%u?)")
text = mw.text.split(text:sub(2, -1), " ")[1]
if loc == "jx" and tone == "3" then
local voicing, coda = determ_syl(text)
tone = text:find("^3[ptkc]s?h") and "3B" or "3A"
elseif loc == "cm" then
if text:find("[kgs]h?[iy]") or text:find("^z[iy]") or text:find("^ni") then
local result = nil
error("Invalid syllable: " .. text .. ". Palatalisation expected.")
if tone:find("[MP]") then -- Verb + Motion / Verb + Pronoun
if word_length ~= 2 then error("cm: Unsupported word length.") end
result = data.tone_contours[loc][tone] or error("cm: Wrong motion/pronoun format.")
elseif tone:find("R",1,true) then -- Reduplication
local main_tone, redup_type, word, sub_tone = text:match("^(%d)R([VCN])(%l+) (%d)%3$")
main_tone, sub_tone = tonumber(main_tone), tonumber(sub_tone)
local conv_tone = (redup_type == "N" and main_tone%2==0 and word:find("^g?[mnl]") and main_tone-1) or main_tone
if sub_tone ~= conv_tone then error("cm: Wrong reduplication format.") end
result = data.tone_contours[loc]["R"..redup_type..main_tone]
end
if result then
return tone_superscript(result)
end
elseif loc == "sx" and tone:find("^%dA$") then
return tone_superscript(data.tone_contours[loc][tone])
end
local result = data.tone_contours[loc][word_length..tone..tone2..tone3]
or data.tone_contours[loc][word_length..tone..tone2]
or data.tone_contours[loc][word_length..tone]
return result and tone_superscript(result) or diagnose_tones(word_length, loc, text, tone, tone2, tone3)
end
 
local function RPS_tone_determ(word_length, tone, loc)
if voicing == "voiced" and tone:find("[124]") then
local result
error("Invalid syllable: " .. text .. tone .. ". Voiced initials only occur in tones 3 and 5.")
if word_length == 1 then
result = data.tone_contours[loc][tone .. "s"] or data.tone_contours[loc]['s']
elseif voicing == "voiceless" and tone:find("[35]") then
else
error("Invalid syllable: " .. text .. tone .. ". Voiceless initials only occur in tones 1, 2 and 4.")
result = data.tone_contours[loc]["multiple"]
end
return tone_superscript(result)
end
if coda == "checked" and tone:find("[123]") then
 
error("Checked syllables only occur in tones 4 and 5.")
local function rom_check(text, locs) --this checks wugniu
if text:match("%f[%l']['qx]") or text:match('ny') or text:match('hh') or text:match("h$") then
elseif coda ~= "checked" and tone:find("[45]") then
error('Invalid syllable: ' .. text ..'. Wugniu expected, but another romanisation is supplied.')
error("Unchecked syllables only occur in tones 1, 2 and 3.")
end
if text:match('ghi') and locs ~= 'cm' then
error('Invalid initial "ghi". Use "yi" instead.')
end
if text:match('ghu') and locs ~= 'cm' then
error('Invalid initial "ghu". Use "wu" instead.')
end
if text:match('%f[%l]y%f[%L]') then
error('Invalid syllable "y"')
end
if text:match('gn[aeou]') then
error('Palatalization expected. Insert an "i" after the "gn".')
end
if text:match('uw') then
error(('Invalid syllable in "%s".'):format(text))
end
if locs:find('cm') and (text:find('ueu') or text:find('uon') or text:find('ui')) then
error('cm: Mutation-only final found.')
end
return nil
end
 
function export.ipa_convipa_syl_conv(original_texttext, loc, initials, finals, syllabics, i, main_tone, tone)
-- get ipa from tables
if type(original_text) == "table" then original_text = original_text.args[1] end
local initial, final = text:match("^([td]?[pbmfvtdnlszcjghk][hng]?)(.+)$")
original_text = mw.ustring.lower(original_text)
local if_syllabic = syllabics[text]
if loc == 'sx' and text == 'gn' then if_syllabic = "ɲ̩" end
if not initial or if_syllabic then
initial, final = '', text
end
if loc == 'cm' then -- mutation
local mutated_initial = i > 1 and initial == "z" and "z"
local preglottal = ""
if tone ~= "0" and (mutated_initial or initial:find("^g?[mnl]") or initial == "") then
preglottal = (i > 1 or main_tone:find("^[1357]$")) and "ʔ" or "ɦ"
end
return preglottal
.. (mutated_initial or initials(initial,loc))
.. (if_syllabic or finals(final,loc))
end
return initials(initial,loc) .. (if_syllabic or finals(final,loc))
end
 
function export.wugniu_to_ipa(original_text, loc, initials, finals, syllabics, tones)
local text, conv_text = "", ""
local tone_number = ""
original_text = original_text:gsub(" (%l+)(%d%u?)", ' %2%1')
if loc == 'cm' then
original_text = original_text:gsub("%f[%l]yi?","i"):gsub("%f[%l]wu?","u")
else
original_text = original_text:gsub("%f[%l]yi?","ghi"):gsub("%f[%l]wu?","ghu")
end
local reading = mw.text.split(original_text, ",", true)
local syllable = {}
Line ၁၀၀ ⟶ ၂၆၁:
for indep_index = 1, #indep_words do
text = indep_words[indep_index]
local no_syllablestone_number = string.len(text:gsubsub("[^ ]"1, ""1)) + 1
rom_checklocal tone = tones(text, loc)
text = text:gsub("[^ %l]+", "")
local tone = tone_contours[no_syllables.."-"..text:sub(1, 1)] or error("Tone notation is incorrect. See [[WT:WUU]].")
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#syllable, 1 do
--RPS
if i == no_syllables and indep_words[indep_index + 1] and tone ~= "³³" then
syl_tone[if i] == tone_contours[tone_determ(#syllable and indep_words[iindep_index + 1]) ..and tone ~= "-³³" .. then
syl_tone[i] = RPS_tone_determ(#syllable, tone_number, loc)
(no_syllables > 1 and "multiple" or "single")]
end
syllable[i] = (syllable[i] ~= "" and export.ipa_syl_conv(syllable[i], loc, initials, finals, syllabics, i, tone_number, syl_tone[i]) or "")
syllable .. (syl_tone[i] == syllable[i]"0" ..and "" or syl_tone[i])
end
indep_words[indep_index] = table.concat(syllable, " ")
Line ၁၂၃ ⟶ ၂၈၃:
end
 
function export.ipa_syl_convwikt_to_wugniu(text)
if type(text) == "table" then text = text.args[1] end
if text:find("^%'?h?h?[mn][mg]?g?$") then
return text
text = text:gsub("^(%'?h?h?)([mn][mg]?g?)$", function(a, b) return (initial[a] or '') ..
--initials
(syllabic[b] or syllabic[a..b] or error(("Invalid syllable: \"%s\""):format(text))) end)
:gsub("'+", {["'"]=""})
:gsub("%f[%l][jqx][jx]?", {j="c", jj="j", q="ch", x="sh", xx="zh"})
elseif text:find("^%'?ny") then
text = text:gsub("^(%f[\'%l]?ny)([aeiouyr][aeou]?[aeu]?[nqr]?)$", "gn")
:gsub("%f[%l]hh", "gh")
function(a, b) return initial[a] .. (final[b] or error(("Unrecognised final: \"%s\""):format(b))) end)
 
--vowels
:gsub("un", "uen")
:gsub("yoe", "ioe")
:gsub("y", "iu")
:gsub("aan", "aon")
:gsub("%f[er]r", "y")
 
--syllabics
:gsub("g?h?mm", "m")
:gsub("g?h?ngg", "ng")
 
--tones
:gsub("[2-5]", {['2']='5', ['3']='6', ['4']='7', ['5']='8'})
--gh rules
elseif text:find("^[\']?[pbmfvtdnlszjqxkghr%']?[sjgx]?h?[aeiouyr][aeou]?[aeu]?[nqr]?$") then
:gsub("ghi", "yi")
text = text:gsub("^([\']?[pbmfvtdnlszjqxkghr%']?[sjgx]?[h]?)([aeiouyr][aeou]?[aeu]?[nqr]?)$",
:gsub("yi%f[aeou]", "y")
function(a, b) return
:gsub("ghu", "wu")
(initial[a] or error(("Unrecognised initial: \"%s\""):format(a))) ..
:gsub("wu%f[aeo]", "w")
(final[b] or error(("Unrecognised final: \"%s\""):format(b))) end)
end
else
 
return error(("Invalid syllable: \"%s\""):format(text))
local function wugniu_to_wikt(text)
if type(text) == "table" then text = text.args[1] end
--initials
return export.wugniu_format(text
:gsub("%f[%l][cjszg][nh]?", {c="j", ch="q", j="jj", sh="x", zh="xx", gn="ny", gh="hh"})
:gsub("%f[%l]yi?", "hhi")
:gsub("wu?", "hhu")
 
--vowels
:gsub("y%f[%L]", "r")
:gsub("uen", "un")
:gsub("ioe", "yoe")
:gsub("iu", "y")
:gsub("aon", "aan")
 
--syllabics
:gsub("%f[%l][mn]g?%f[%L]", {m="mm",n="nn",ng="ngg"})
 
--initial hh and '
:gsub("([157])([mnl])", "%1'%2")
:gsub("([68])([mn][mng]g?)%f[%L]", "%1hh%2")
 
--tones
:gsub("[5-8]", {['5']='2', ['6']='3', ['7']='4', ['8']='5'}))
end
 
function export.wugniu_format(text, loc)
-- 1a a 1a 1a3 a1 -> ^1a-a-a_1-^1a_3-a_1
-- 1a3-3a5 -> ^1a_3-^3a_5
return text
:gsub("[%- &+,]", {["-"]="", [" "]="-", ["&"]=" ", ["+"]=" ", [","]="; "})
:gsub("(%-?)(%d?%u?)('?%l+)(%d?%u?)", function(dash, tone1, main, tone2)
if dash == '-' and tone2 == '' then
tone1, tone2 = tone2, tone1
end
if tone1 ~= '' then
tone1 = '<sup>' .. tone1 .. '</sup>'
end
if tone2 ~= '' then
tone2 = '<sub>' .. tone2 .. '</sub>'
end
return dash .. tone1 .. main .. tone2
end)
end
 
local function wikt_format(text)
return export.wugniu_format(text)
end
 
local function minidict_format(text)
-- 1A3 3B5 3C D3 E -> A^3 B^5 C^3 D^3 E
-- 1A B -> A^1 B
return text
:gsub("-", "")
:gsub("[&+]", " ")
:gsub(",", "; ")
:gsub("[1-8]?(%l+)([1-8])", '%1<sup>%2</sup>')
:gsub("([1-8])(%l+)", '%2<sup>%1</sup>')
:gsub("%f[%l]([mnlr]%l*)(<sup>[1357]</sup>)", "'%1%2")
:gsub("[1-8]",{
["1"]="平",["2"]="平",
["3"]="上",["4"]="上",
["5"]="去",["6"]="去",
["7"]="入",["8"]="入",
})
end
 
function export.wugniu_to_minidict(text, loc)
if type(text) == "table" then text = text.args[1] end
text = text:gsub('%f[%l][yw]', {y = 'yi', w = 'wu'})
if loc == 'sx' then
text = text:gsub("[ei]+[nq]",{een="en",en="eon",iq="ieq"})
elseif loc == 'hz' then -- are we dealing with mergers?
text = text:gsub("[aeiu]+q?%f[%L]",{eu="ei",ieu="iu",aq="eq",iaq="ieq",iq="ieq",uaq="ueq"})
elseif loc == 'sz' or loc == 'cz' then
text = text:gsub("%f[%l]yie%f[%L]", "yiie") -- ye > yie
elseif loc == 'nb' then
text = text:gsub("yu%f[nq]", "oe")
elseif loc == 'sh' then
text = text:gsub("ie%f[%L]", "iae")
elseif loc == 'cm' then
text = text:gsub("<sup>→%l+</sup>", "")
elseif loc == 'jd' then
text = text:gsub("ue%f[%L]", "uie")
end
return minidict_format(text
--finals & syllabic
:gsub("iu([nq])", "iui%1")
:gsub("gher", "r")
:gsub("er", "r")
:gsub("q", "h"))
 
--initials
--Glottal stops? text = text:gsub("", "'")
:gsub("gn", "ny")
:gsub("nyi%f[aeou]", "ny")
:gsub('yi([aeiou])', 'y%1')
:gsub('wu([aeiou])', 'w%1')
end
 
-- various boilerplates
function export.name_boilerplate(name, wiki)
return '<i>[[w:' .. (wiki or name..' dialect') .. '|' .. name.. ']]</i>'
end
 
function export.consolas(text)
return '<span style="font-family: Consolas, monospace;">' .. text .. '</span>'
end
 
function export.wugniu_boilerplate(text)
return '\n*** <small><i>[[Wiktionary:About Chinese/Wu|Wugniu]]</i></small>: '
.. export.consolas(text)
end
 
function export.minidict_boilerplate(text)
return '\n*** <small><i>[[Wiktionary:About Chinese/Wu|MiniDict]]</i></small>: '
.. export.consolas(text)
end
 
function export.wikt_boilerplate(text)
return '\n*** <small><i>[[Wiktionary:About Chinese/Wu|Wiktionary Romanisation]] (Shanghai)</i></small>: '
.. export.consolas(text)
end
 
function export.IPA_boilerplate(text, name, wiki)
text = text:gsub("(/?[^ /,]*/[^ /,]*/?)", '<span style="white-space: nowrap;">%1</span>')
return '\n*** <small>Sinological [[Wiktionary:International Phonetic Alphabet|IPA]]'
.. ' (' .. export.name_boilerplate(name, wiki) .. ')</small>: '
.. '<span class="IPA">/' .. text .. '/</span>'
end
 
-- backwards compatibility for old usage "|w=<text>"
function export.legacy(text, mode)
require("Module:debug").track("wuu-pron/legacy")
local wugniu_text = export.wikt_to_wugniu(text)
local show = '\n**<small>(<i>[[w:Taihu Wu|Northern]]</i>)</small>: ' .. export.consolas(export.wugniu_format(wugniu_text))
local hide = '\n**<small>(' .. export.name_boilerplate('Shanghai') .. ')</small>: ' .. export.wugniu_boilerplate(export.wugniu_format(wugniu_text))
.. export.minidict_boilerplate(export.wugniu_to_minidict(wugniu_text, 'sh'))
.. export.wikt_boilerplate(wikt_format(text))
.. export.IPA_boilerplate(export.wugniu_to_ipa(wugniu_text, 'sh', get_initial, get_final, ipa_syllabic, get_tone), 'Shanghai')
return show, hide
end
 
local function preprocess_IPA(text, loc)
if loc == 'hz' then
return text:gsub("%f[%l]([td]?[szcj]h?i?u)%f[aeonq]", "%1w")
elseif loc == 'sx' then
return text:gsub("[^,&]+%+[^,&]+", function(chain)
local tone1,mode,word1,tone2,word2 = chain:match("^(%d)([AP]?)(%l+)%+(%d)(%l+)$")
if not tone1 then error("sx: Wrong chain format.") end
if mode == '' then mode = 'O' end
if mode == 'A' then
return tone1..'A'..word1..'&'..tone2..word2
end
return tone1..word1..' '..tone2..mode..word2
end):gsub("#(%d)","%1N")
elseif loc == 'cm' then
return text:gsub("%f[%l]%l+<(%l*)>","%1")
end
return text
end
 
local function export.rompreprocess_wugniu(text, loc)
if type(text)loc == 'tablejx' then text = text.args[1] end
text return = mw.text.split:gsub(text, "3[AB]",", true3")
elseif loc == 'cm' then
for i = 1, #text, 1 do
return text:gsub("[CMPR][VCN]?","")
local parts = mw.text.split(text[i], '+', true)
:gsub("%f[%l](%l*)<(%l*)>(%l*)(%d?)","%1%3%4<sup>→%2%3</sup>")
for i = 1, #parts do
elseif loc == 'sx' then
if string.find(parts[i], '^[0-9%-]') then
return text:gsub("[#CAP]","")
parts[i] = parts[i]:sub(2,-1) .. ' (T' .. parts[i]:sub(1,1) .. ')'
end
return text
end
 
local function preprocess_mutation(text, locs)
if locs:find('cm') then
text = text:gsub(" (%d?C?)([vzgd]h?)([%w<>]+)", function(tone, initial, final)
local mutated_initial = ({v="u",zh="",gh=""})[initial]
if mutated_initial == "u" and final:find("^u") then
mutated_initial = ""
elseif initial == "d" and final:find("^i") then
mutated_initial = "l"
end
if final:find("<") or not mutated_initial then
return " "..tone..initial..final
end
return " "..tone..initial.."<"..mutated_initial..">"..final
end)
end
if text:find("<") and locs ~= "cm" then
error("cm: Mutation is incompatible with collapsing.")
end
return text
end
 
function export.make(text, mode) --mode: textShow > true / textHide > false
text = text:gsub("勿", "6veq8") -- for backwards compatibility
if not text:match(':') then -- for backwards compatibility
return export.legacy(text, mode)
end
local show = ""
local hide = ""
local roms = {}
local input_seen, duplicated = {}, false
text = mw.text.split(text, ';', true)
for i = 1,#text,1 do
local s = mw.text.split(text[i], ':', true)
if not duplicated then
if input_seen[s[2]] then duplicated = true end
input_seen[s[2]] = true
end
if #s ~= 2 or #s[1] == 0 then
text[i] = table.concat(parts, ' + ')
error("Wugniu: prefix is required or too many prefixes")
end
local locs, t = mw.text.split(s[1], ',', true), s[2]
t = preprocess_mutation(t, s[1])
local list = {}
local format_text = t
for _, loc in ipairs(locs) do
if loc_names[loc] then
list[loc] = true
else
error('Wugniu: prefix "' .. loc .. '" is not recognized')
end
format_text = preprocess_wugniu(format_text, loc)
end
rom_check(t, s[1])
local wugniu_text = export.wugniu_format(format_text, locs[1])
table.insert(roms,wugniu_text)
local names = {}
local minidicts = {}
local minidicts_seen = {}
local IPAs = {}
for _, loc in ipairs(order) do if list[loc] then
table.insert(names, export.name_boilerplate(loc_names[loc], wiki_names[loc]))
if minidict[loc] then
local minidict_result = export.wugniu_to_minidict(format_text, loc)
if not minidicts_seen[minidict_result] then
table.insert(minidicts, minidict_result)
minidicts_seen[minidict_result] = true
end
end
local ipa_text = preprocess_IPA(t, loc)
ipa_text = export.wugniu_to_ipa(ipa_text, loc, get_initial, get_final, ipa_syllabic, get_tone)
table.insert(IPAs,export.IPA_boilerplate(ipa_text, loc_names[loc], wiki_names[loc]))
end end
hide = hide .. '\n** <small>(' .. table.concat(names,', ') .. ')</small>'
hide = hide .. export.wugniu_boilerplate(wugniu_text)
for _,minidict_text in ipairs(minidicts) do
hide = hide .. export.minidict_boilerplate(minidict_text)
end
if list.sh then
hide = hide .. export.wikt_boilerplate(wugniu_to_wikt(format_text))
end
hide = hide .. table.concat(IPAs, '')
end
show = '\n** <small>(<i>[[w:Taihu Wu|Northern]]</i>)</small>: ' .. export.consolas(table.concat(roms, ' / '))
if duplicated then
require("Module:debug").track("wuu-pron/duplicated")
end
return table.concat(textshow, "; ")hide
end
 
ကလေၚ်သီကေတ်လဝ် နူ "https://mnw.wiktionary.org/wiki/မဝ်ဂျူ:wuu-pron"