Module:User:Santi2222/el-IPA

local export = {}

function export.show(word, phonetic) if type(word) == 'table' then do_debug = word.args[4] word = word.args[1] end local orig_word = word word = mw.ustring.lower(word or mw.title.getCurrentTitle.text) local stress = "ˈ" local sep = "." local orthV = "[αάεέηήιίοόυύωώ]" -- (orthografic) vowels local orthC = "[βγδζλμνρ]" -- (orthografic) voiced consonants local V = "[aeiouáéíóú]" -- vowels local W = "[j]" local C = "[mpbfvθðntdszɾlkɡɣxźś]" -- consonants --simple phonemic transcription (vowels) --α word = mw.ustring.gsub(word, "αι", "e") word = mw.ustring.gsub(word, "αί", "é") word = mw.ustring.gsub(word, "αϊ", "a.i") word = mw.ustring.gsub(word, "αϋ", "a.i") word = mw.ustring.gsub(word, "αΐ", "a.í") word = mw.ustring.gsub(word, "αΰ", "a.í") word = mw.ustring.gsub(word, "αυ(" .. orthC .. ")", "av%1") word = mw.ustring.gsub(word, "αυ(" .. orthV .. ")", "av%1") word = mw.ustring.gsub(word, "αυ", "af") word = mw.ustring.gsub(word, "αύ(" .. orthC .. ")", "áv%1") word = mw.ustring.gsub(word, "αύ(" .. orthV .. ")", "áv%1") word = mw.ustring.gsub(word, "αύ", "áf") word = mw.ustring.gsub(word, "άι", "áj") word = mw.ustring.gsub(word, "άυ", "áj") word = mw.ustring.gsub(word, "ά", "á") word = mw.ustring.gsub(word, "α", "a") --ε word = mw.ustring.gsub(word, "ει", "i") word = mw.ustring.gsub(word, "εί", "í") word = mw.ustring.gsub(word, "εϊ", "e.i") word = mw.ustring.gsub(word, "εϋ", "e.i") word = mw.ustring.gsub(word, "εΐ", "e.í") word = mw.ustring.gsub(word, "εΰ", "ε.í") word = mw.ustring.gsub(word, "ευ(" .. orthC .. ")", "ev%1") word = mw.ustring.gsub(word, "ευ(" .. orthV .. ")", "ev%1") word = mw.ustring.gsub(word, "ευ", "ef") word = mw.ustring.gsub(word, "εύ(" .. orthC .. ")", "év%1") word = mw.ustring.gsub(word, "εύ(" .. orthV .. ")", "év%1") word = mw.ustring.gsub(word, "εύ", "éf") word = mw.ustring.gsub(word, "ε", "e") word = mw.ustring.gsub(word, "έι", "éj") word = mw.ustring.gsub(word, "έυ", "éj") word = mw.ustring.gsub(word, "έ", "é") --η word = mw.ustring.gsub(word, "ηυ(" .. orthC .. ")", "iv%1") word = mw.ustring.gsub(word, "ηυ(" .. orthV .. ")", "iv%1") word = mw.ustring.gsub(word, "ηυ", "if") word = mw.ustring.gsub(word, "ηύ(" .. orthC .. ")", "ív%1") word = mw.ustring.gsub(word, "ηύ(" .. orthV .. ")", "ív%1") word = mw.ustring.gsub(word, "ηύ", "íf") word = mw.ustring.gsub(word, "ή", "í") word = mw.ustring.gsub(word, "η", "i") --ο word = mw.ustring.gsub(word, "οι", "i") word = mw.ustring.gsub(word, "οί", "í") word = mw.ustring.gsub(word, "οϊ", "o.i") word = mw.ustring.gsub(word, "οΐ", "o.í") word = mw.ustring.gsub(word, "οϋ", "e.i") word = mw.ustring.gsub(word, "οΰ", "o.í") word = mw.ustring.gsub(word, "ου", "u") word = mw.ustring.gsub(word, "ού", "ú") word = mw.ustring.gsub(word, "ο", "o") word = mw.ustring.gsub(word, "όι", "ój") word = mw.ustring.gsub(word, "όυ", "ój") word = mw.ustring.gsub(word, "ό", "ó") --υ, ι, ω word = mw.ustring.gsub(word, "υι", "i") word = mw.ustring.gsub(word, "υ", "i") word = mw.ustring.gsub(word, "ύ", "í") word = mw.ustring.gsub(word, "ι", "i") word = mw.ustring.gsub(word, "ί", "í") word = mw.ustring.gsub(word, "ω", "o") word = mw.ustring.gsub(word, "ώ", "ó") --consonants (mp and nt will be dealt with later) --γ word = mw.ustring.gsub(word, "γγ", "nɡ") word = mw.ustring.gsub(word, "γκ", "ɡ") word = mw.ustring.gsub(word, "γξ", "nks") word = mw.ustring.gsub(word, "γχ", "nx") word = mw.ustring.gsub(word, "γ", "ɣ") --all others (θ is kept) word = mw.ustring.gsub(word, "β", "v") word = mw.ustring.gsub(word, "δ", "ð") word = mw.ustring.gsub(word, "ζ", "z") word = mw.ustring.gsub(word, "κ", "k") word = mw.ustring.gsub(word, "λ", "l") word = mw.ustring.gsub(word, "μ", "m") word = mw.ustring.gsub(word, "ν", "n") word = mw.ustring.gsub(word, "ξ", "ks") word = mw.ustring.gsub(word, "π", "p") word = mw.ustring.gsub(word, "ρ", "ɾ") word = mw.ustring.gsub(word, "σ", "s") word = mw.ustring.gsub(word, "ς", "s") word = mw.ustring.gsub(word, "τ", "t") word = mw.ustring.gsub(word, "φ", "f") word = mw.ustring.gsub(word, "χ", "x") word = mw.ustring.gsub(word, "ψ", "ps") --simplify orthografic double consonants (needs to be checked) word = mw.ustring.gsub(word, "nn", "n") word = mw.ustring.gsub(word, "ss", "s") word = mw.ustring.gsub(word, "ll", "l")

--initial mp and nt	word = mw.ustring.gsub(word,'(.?)mp(.?)',		function (before, after)			if before == '' then				return before .. 'b' .. after			end		end) word = mw.ustring.gsub(word,'(.?)nt(.?)',		function (before, after)			if before == '' then				return before .. 'd' .. after			end		end) --affricates word = mw.ustring.gsub(word, "tz", "ź") --wrong symbol, to be corrected at the end word = mw.ustring.gsub(word, "ts", "ś") --syllable division (needs to be checked) for _ = 1, 2 do		word = mw.ustring.gsub(word,			"(" .. V .. ")(" .. C .. W .. "?" .. V .. ")",			"%1.%2")	end for _ = 1, 2 do		word = mw.ustring.gsub(word,			"(" .. V .. C .. ")(" .. C .. V .. ")",			"%1.%2")	end for _ = 1, 2 do		word = mw.ustring.gsub(word,			"(" .. V .. C .. ")(" .. C .. C .. V .. ")",			"%1.%2")	end word = mw.ustring.gsub(word, "(" .. V .. ")(" .. V .. ")", "%1.%2")	word = mw.ustring.gsub(word, "([pbktdɡ])%.([lɾ])", ".%1%2") word = mw.ustring.gsub(word, "(" .. C .. ")%.s(" .. C .. ")", "%1s.%2") word = mw.ustring.gsub(word, "([aeoáéíóú])([aeoáéíóú])", "%1.%2") word = mw.ustring.gsub(word, "([ií])([ií])", "%1.%2") word = mw.ustring.gsub(word, "([uú])([uú])", "%1.%2") --palatals word = mw.ustring.gsub(word, "k([iíeé])", "c%1") word = mw.ustring.gsub(word, "ɡ([iíeé])", "ɟ%1") word = mw.ustring.gsub(word, "x([iíeé])", "ç%1") word = mw.ustring.gsub(word, "ɣ([iíeé])", "ʝ%1") --symplify "palatal + i + vowel" to "palatal + vowel" word = mw.ustring.gsub(word, "([cɟçʝ])i.([aáeéiíóoeú])", "%1%2")

--accentuation local syllables = mw.text.split(word, "%.") if mw.ustring.find(word, "[áéíóú]") then for i = 1, #syllables do			if mw.ustring.find(syllables[i], "[áéíóú]") then syllables[i] = "ˈ"..syllables[i] end end end word = table.concat(syllables,".") word = mw.ustring.gsub(word, ".ˈ", "ˈ")

--vowel quality (if phonetic) if phonetic then word = mw.ustring.gsub(word, "a", "ɐ") word = mw.ustring.gsub(word, "e", "e̞") word = mw.ustring.gsub(word, "o", "o̞") end --remove accents if phonetic then word = mw.ustring.gsub(word, "á", "ɐˑ") word = mw.ustring.gsub(word, "é", "e̞ˑ") word = mw.ustring.gsub(word, "ó", "o̞ˑ") word = mw.ustring.gsub(word, "ú", "uˑ") word = mw.ustring.gsub(word, "í", "iˑ") else word = mw.ustring.gsub(word, "á", "a") word = mw.ustring.gsub(word, "é", "e") word = mw.ustring.gsub(word, "ó", "o") word = mw.ustring.gsub(word, "ú", "u") word = mw.ustring.gsub(word, "í", "i") end --other phonetic stuff if phonetic then word = mw.ustring.gsub(word, "n.([cɟçʝ])", "ɲ̟.%1") word = mw.ustring.gsub(word, "n.([kɡɣx])", "ŋ.%1") word = mw.ustring.gsub(word, "m.f", "ɱ.f") end --correct symbols for affricates word = mw.ustring.gsub(word, "ź", "d͡z") word = mw.ustring.gsub(word, "ś", "t͡s") return word end

function export.phonetic(frame) return export.show(frame, true) end

return export