模組:Sandbox/Elmru/test

Wikipedia (chū-iû ê pek-kho-choân-su) beh kā lí kóng...
跳至導覽 跳至搜尋

此模組的說明文件可於模組:Sandbox/Elmru/test/doc建立

local p = {}
 
function attachTone(a, n)
    n = tonumber(n)

	if a == "Oai" then
		if n == 1 then return "Oai" end
		if n == 2 then return "Oái" end
		if n == 3 then return "Oài" end
		if n == 4 then return "Oai" end
        if n == 5 then return "Oâi" end
        if n == 6 then return "Oǎi" end
        if n == 7 then return "Oāi" end
        if n == 8 then return "Oa̍i" end
		return a
	end
	
	if a == "oai" then
		if n == 1 then return "oai" end
		if n == 2 then return "oái" end
		if n == 3 then return "oài" end
		if n == 4 then return "oai" end
        if n == 5 then return "oâi" end
        if n == 6 then return "oǎi" end
        if n == 7 then return "oāi" end
        if n == 8 then return "oa̍i" end
		return a
	end
	
	if a == "Oan" then
		if n == 1 then return "Oan" end
		if n == 2 then return "Oán" end
		if n == 3 then return "Oàn" end
		if n == 4 then return "Oan" end
        if n == 5 then return "Oân" end
        if n == 6 then return "Oǎn" end
        if n == 7 then return "Oān" end
        if n == 8 then return "Oa̍n" end
		return a
	end
	
	if a == "oan" then
		if n == 1 then return "oan" end
		if n == 2 then return "oán" end
		if n == 3 then return "oàn" end
		if n == 4 then return "oan" end
        if n == 5 then return "oân" end
        if n == 6 then return "oǎn" end
        if n == 7 then return "oān" end
        if n == 8 then return "oa̍n" end
		return a
	end
	
	if a == "O" then
		if n == 1 then return "O" end
		if n == 2 then return "Ó" end
		if n == 3 then return "Ò" end
		if n == 4 then return "O" end
        if n == 5 then return "Ô" end
        if n == 6 then return "Ŏ" end
        if n == 7 then return "Ō" end
        if n == 8 then return "O̍" end
		return a
	end
 
	if a == "o" then
		if n == 1 then return "o" end
		if n == 2 then return "ó" end
		if n == 3 then return "ò" end
		if n == 4 then return "o" end
        if n == 5 then return "ô" end
        if n == 6 then return "ǒ" end
        if n == 7 then return "ō" end
        if n == 8 then return "o̍" end
		return a
	end
	
	if a == "E" then
		if n == 1 then return "E" end
		if n == 2 then return "É" end
		if n == 3 then return "È" end
		if n == 4 then return "E" end
        if n == 5 then return "Ê" end
        if n == 6 then return "Ě" end
        if n == 7 then return "Ē" end
        if n == 8 then return "E̍" end
		return a
	end
 
	if a == "e" then
		if n == 1 then return "e" end
		if n == 2 then return "é" end
		if n == 3 then return "è" end
		if n == 4 then return "e" end
        if n == 5 then return "ê" end
        if n == 6 then return "ě" end
        if n == 7 then return "ē" end
        if n == 8 then return "e̍" end
		return a
	end
	
    if a == "A" then
		if n == 1 then return "A" end
		if n == 2 then return "Á" end
		if n == 3 then return "À" end
		if n == 4 then return "A" end
        if n == 5 then return "Â" end
        if n == 6 then return "Ǎ" end
        if n == 7 then return "Ā" end
        if n == 8 then return "A̍" end
		return a
	end
    if a == "a" then
		if n == 1 then return "a" end
		if n == 2 then return "á" end
		if n == 3 then return "à" end
		if n == 4 then return "a" end
        if n == 5 then return "â" end
        if n == 6 then return "ǎ" end
        if n == 7 then return "ā" end
        if n == 8 then return "a̍" end
		return a
	end

    if a == "U" then
		if n == 1 then return "U" end
		if n == 2 then return "Ú" end
		if n == 3 then return "Ù" end
		if n == 4 then return "U" end
        if n == 5 then return "Û" end
        if n == 6 then return "Ǔ" end
        if n == 7 then return "Ū" end
        if n == 8 then return "U̍" end
		return a
	end

    if a == "u" then
		if n == 1 then return "u" end
		if n == 2 then return "ú" end
		if n == 3 then return "ù" end
		if n == 4 then return "u" end
        if n == 5 then return "û" end
        if n == 6 then return "ǔ" end
        if n == 7 then return "ū" end
        if n == 8 then return "u̍" end
		return a
	end
 
    if a == "I" then
		if n == 1 then return "I" end
		if n == 2 then return "Í" end
		if n == 3 then return "Ì" end
		if n == 4 then return "I" end
        if n == 5 then return "Î" end
        if n == 6 then return "Ǐ" end
        if n == 7 then return "Ī" end
        if n == 8 then return "I̍" end
		return a
	end
    
	if a == "i" then
		if n == 1 then return "i" end
		if n == 2 then return "í" end
		if n == 3 then return "ì" end
		if n == 4 then return "i" end
        if n == 5 then return "î" end
        if n == 6 then return "ǐ" end
        if n == 7 then return "ī" end
        if n == 8 then return "i̍" end
		return a
	end
	
	if a == "Ng" then
		if n == 1 then return "Ng" end
		if n == 2 then return "Ńg" end
		if n == 3 then return "Ǹg" end
		if n == 4 then return "Ng" end
        if n == 5 then return "N̂g" end
        if n == 6 then return "Ňg" end
        if n == 7 then return "N̄g" end
        if n == 8 then return "N̍g" end
		return a
	end
	
	if a == "ng" then
		if n == 1 then return "ng" end
		if n == 2 then return "ńg" end
		if n == 3 then return "ǹg" end
		if n == 4 then return "ng" end
        if n == 5 then return "n̂g" end
        if n == 6 then return "ňg" end
        if n == 7 then return "n̄g" end
        if n == 8 then return "n̍g" end
		return a
	end

    if a == "M" then
		if n == 1 then return "M" end
		if n == 2 then return "Ḿ" end
		if n == 3 then return "M̀" end
		if n == 4 then return "M" end
        if n == 5 then return "M̂" end
        if n == 6 then return "M̌" end
        if n == 7 then return "M̄" end
        if n == 8 then return "M̍" end
		return a
	end
	
	if a == "m" then
		if n == 1 then return "m" end
		if n == 2 then return "ḿ" end
		if n == 3 then return "m̀" end
		if n == 4 then return "m" end
        if n == 5 then return "m̂" end
        if n == 6 then return "m̌" end
        if n == 7 then return "m̄" end
        if n == 8 then return "m̍" end
		return a
	end
    
    if a == "Oo" then
		if n == 1 then return "O͘" end
		if n == 2 then return "Ó͘" end
		if n == 3 then return "Ò͘" end
		if n == 4 then return "O͘" end
        if n == 5 then return "Ô͘" end
        if n == 6 then return "Ŏ͘" end
        if n == 7 then return "Ō͘" end
        if n == 8 then return "O̍͘" end
        return a
	end
    
    if a == "oo" then
		if n == 1 then return "o͘" end
		if n == 2 then return "ó͘" end
		if n == 3 then return "ò͘" end
		if n == 4 then return "o͘" end
        if n == 5 then return "ô͘" end
        if n == 6 then return "ǒ͘" end
        if n == 7 then return "ō͘" end
        if n == 8 then return "o̍͘" end
		return a
	end

	return a
 
end

function selectVowel(chara, n)
 
	if not chara then
		return
	end
    
  -- Tone-attaching order: oai, oan, o, e, a, u, i, ng, m.
  -- Output will change by the order below.
    if chara:find('Oai') then
		return chara:gsub("Oai", attachTone("Oai", n))
	end
    if chara:find('oai') then
		return chara:gsub("oai", attachTone("oai", n))
	end
	if chara:find('Oan') then
		return chara:gsub("Oan", attachTone("Oan", n))
	end
    if chara:find('oan') then
		return chara:gsub("oan", attachTone("oan", n))
	end
    if chara:find('Oo') then
		return chara:gsub("Oo", attachTone("Oo", n))
	end
    if chara:find('oo') then
		return chara:gsub("oo", attachTone("oo", n))
	end
    if chara:find('O') then
		return chara:gsub("O", attachTone("O", n))
	end
    if chara:find('o') then
		return chara:gsub("o", attachTone("o", n))
	end
	if chara:find('E') then
		return chara:gsub("E", attachTone("E", n))
	end
	if chara:find('e') then
		return chara:gsub("e", attachTone("e", n))
	end
	if chara:find('A') then
		return chara:gsub("A", attachTone("A", n))
	end
	if chara:find('a') then
		return chara:gsub("a", attachTone("a", n))
	end
	if chara:find('U') then
		return chara:gsub("U", attachTone("U", n))
	end
    if chara:find('u') then
		return chara:gsub("u", attachTone("u", n))
    end
    if chara:find('I') then
		return chara:gsub("I", attachTone("I", n))
	end
	if chara:find('i') then
		return chara:gsub("i", attachTone("i", n))
	end
	if chara:find('Ng') then
		return chara:gsub("Ng", attachTone("Ng", n))
    end
    if chara:find('ng') then
		return chara:gsub("ng", attachTone("ng", n))
    end
    if chara:find('M') then
		return chara:gsub("M", attachTone("M", n))
    end
    if chara:find('m') then
		return chara:gsub("m", attachTone("m", n))
    end
	
end
 
function p.pehoeji(frame)
	local input = frame.args[1]
	if not input then
		return
	end
	local out = input:gsub("([%a]+)(%d)", selectVowel):gsub("nn", "ⁿ")
	return (out)
end
 
return p