Module:ábḫ-ipa: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
for i,val in ipairs(word) do
for i,val in ipairs(word) do
if val == "b" then
if val == "a" then
if not mw.ustring.match(word[i-1], "[m]") then
if mw.ustring.match(word[i-1], "[áa]") then
table.insert(result, "ː")
elseif mw.ustring.match(word[i+1], "[á]") then
table.insert(result, "ǎ")
else
table.insert(result, "a")
end
elseif val == "á" then
if mw.ustring.match(word[i-1], "[a]") then
table.insert(result, "ː")
elseif mw.ustring.match(word[i+1], "[a]") then
table.insert(result, "â")
else
table.insert(result, "á")
end
elseif val == "b" then
if mw.ustring.match(word[i-1], "[m]") then
table.insert(result, "b")
else
table.insert(result, "β")
table.insert(result, "β")
end
end
elseif val == "d" then
table.insert(result, "ð")
elseif val == "e" then
if mw.ustring.match(word[i+1], "[í]") then
table.insert(result, "ě")
else
table.insert(result, "e")
end
elseif val == "é" then
if mw.ustring.match(word[i+1], "[i]") then
table.insert(result, "ê")
else
table.insert(result, "é")
end
elseif val == "h" then
if not mw.ustring.match(word[i-1], "[j]") then
table.insert(result, "ɦ")
end
elseif val == "ḫ" then
table.insert(result, "x")
elseif val == "i" then
if mw.ustring.match(word[i-1], "[ée]") then
table.insert(result, "ːɪ̯")
elseif mw.ustring.match(word[i-1], "[aáoó]") then
table.insert(result, "ɪ̯")
elseif mw.ustring.match(word[i-1], "[ií]") then
table.insert(result, "ː")
elseif mw.ustring.match(word[i+1], "[í]") then
table.insert(result, "ǐ")
end
elseif val == "í" then
if mw.ustring.match(word[i-1], "[e]") then
table.insert(result, "ːɪ̯")
elseif mw.ustring.match(word[i+1], "i") then
table.insert(result, "î")
else
table.insert(result, "í")
end
elseif val == "j" then
if mw.ustring.match(word[i+1], "[h]") then
table.insert(result, "ʑ")
else
table.insert(result, "ɟ̟")
end
elseif val == "k" then
if mw.ustring.match(word[i-1], "[n]") then
table.insert(result, "g")
else
table.insert(result, "k")
end
elseif val == "n" then
if mw.ustring.match(word[i+1], "[k]") then
table.insert(result, "ŋ")
else
table.insert(result, "n̪")
end
elseif val == "o" then
if mw.ustring.match(word[i-1], "[a]") then
table.insert(result, "o̯")
elseif mw.ustring.match(word[i+1], "[iú]") then
table.insert(result, "ɔ̌")
else
table.insert(result, "ɔ")
end
elseif val == "r" then
table.insert(result, "ɺ")
elseif val == "s" then
table.insert(result, "ɕ")
elseif val == "t" then
if mw.ustring.match(word[i-1], "[n]") and not mw.ustring.match(word[i+1], "[t]") then
table.insert(result, "d̪")
else
table.insert(result, "t̪")
end
elseif val == "u" then
table.insert(result, "ːʊ̯")
elseif val == "y" then
table.insert(result, "j")
elseif val == "z" then
table.insert(result, "θ̱")
else
else
table.insert(result, val)
table.insert(result, val)

Revision as of 22:04, 21 February 2020



local export = {}

function export.convert(frame)
	local word = type(frame) == "table" and frame.args[1] or frame
	
	word = mw.text.split(word, "", true)
	
	result = {}
	
	for i,val in ipairs(word) do
		if val == "a" then
			if mw.ustring.match(word[i-1], "[áa]") then
				table.insert(result, "ː")
			elseif mw.ustring.match(word[i+1], "[á]") then
				table.insert(result, "ǎ")
			else
				table.insert(result, "a")
			end
		elseif val == "á" then
			if mw.ustring.match(word[i-1], "[a]") then
				table.insert(result, "ː")
			elseif mw.ustring.match(word[i+1], "[a]") then
				table.insert(result, "â")
			else
				table.insert(result, "á")
			end
		elseif val == "b" then
			if mw.ustring.match(word[i-1], "[m]") then
				table.insert(result, "b")
			else
				table.insert(result, "β")
			end
		elseif val == "d" then
			table.insert(result, "ð")
		elseif val == "e" then
			if mw.ustring.match(word[i+1], "[í]") then
				table.insert(result, "ě")
			else
				table.insert(result, "e")
			end
		elseif val == "é" then
			if mw.ustring.match(word[i+1], "[i]") then
				table.insert(result, "ê")
			else
				table.insert(result, "é")
			end
		elseif val == "h" then
			if not mw.ustring.match(word[i-1], "[j]") then
				table.insert(result, "ɦ")
			end
		elseif val == "ḫ" then
			table.insert(result, "x")
		elseif val == "i" then
			if mw.ustring.match(word[i-1], "[ée]") then
				table.insert(result, "ːɪ̯")
			elseif mw.ustring.match(word[i-1], "[aáoó]") then
				table.insert(result, "ɪ̯")
			elseif mw.ustring.match(word[i-1], "[ií]") then
				table.insert(result, "ː")
			elseif mw.ustring.match(word[i+1], "[í]") then
				table.insert(result, "ǐ")
			end
		elseif val == "í" then
			if mw.ustring.match(word[i-1], "[e]") then
				table.insert(result, "ːɪ̯")
			elseif mw.ustring.match(word[i+1], "i") then
				table.insert(result, "î")
			else
				table.insert(result, "í")
			end
		elseif val == "j" then
			if mw.ustring.match(word[i+1], "[h]") then
				table.insert(result, "ʑ")
			else
				table.insert(result, "ɟ̟")
			end
		elseif val == "k" then
			if mw.ustring.match(word[i-1], "[n]") then
				table.insert(result, "g")
			else
				table.insert(result, "k")
			end
		elseif val == "n" then
			if mw.ustring.match(word[i+1], "[k]") then
				table.insert(result, "ŋ")
			else
				table.insert(result, "n̪")
			end
		elseif val == "o" then
			if mw.ustring.match(word[i-1], "[a]") then
				table.insert(result, "o̯")
			elseif mw.ustring.match(word[i+1], "[iú]") then
				table.insert(result, "ɔ̌")
			else
				table.insert(result, "ɔ")
			end
		elseif val == "r" then
			table.insert(result, "ɺ")
		elseif val == "s" then
			table.insert(result, "ɕ")
		elseif val == "t" then
			if mw.ustring.match(word[i-1], "[n]") and not mw.ustring.match(word[i+1], "[t]") then
				table.insert(result, "d̪")
			else
				table.insert(result, "t̪")
			end
		elseif val == "u" then
			table.insert(result, "ːʊ̯")
		elseif val == "y" then 
			table.insert(result, "j")
		elseif val == "z" then
			table.insert(result, "θ̱")
			
		else
			table.insert(result, val)
		end
	end
	
	return table.concat(result)
end

return export