Module:User:Sinonquoi/ta-IPA

local export = {}

local lang = require("Module:languages").getByCode("ta") local sc = require("Module:scripts").getByCode("Taml") local m_IPA = require("Module:IPA")

local gsub = mw.ustring.gsub local gmatch = mw.ustring.gmatch local find = mw.ustring.find local u = mw.ustring.char

local correspondences = { ["ṅ"] = "ŋ", ["g"] = "ɡ", ["k"] = "k", ["ṇ"] = "ɳ", ["ḍ"] = "ɖ", ["ṭ"] = "ʈ", ["ṉ"] = "n", ["n"] = "n̪", ["d"] = "d̪", ["t"] = "t̪", ["m"] = "m", ["b"] = "b", ["p"] = "p",

["ñ"] = "ɲ", ["c"] = "t͡ʃ", ["ṟ"] = "r", ["ḻ"] = "ɻ", ["v"] = "ʋ", ["r"] = "ɾ̪", ["ṣ"] = "ʂ", ["j"] = "d͡ʒ", ["ś"] = "ʃ", ["h"] = "h", ["ḵ"] = "x", ["m"] = "m", ["y"] = "j",

["a"] = "a", ["e"] = "e", ["i"] = "i", ["o"] = "o", ["u"] = "u", ["ā"] = "aː", ["ē"] = "eː", ["ī"] = "iː", ["ō"] = "oː", ["ū"] = "uː", }

local vowels = "aeiou"

local voiced_cons = "tkṭpc"

local voicing = { ["t"] = "d", ["k"] = "g", ["ṭ"] = "ḍ", ["p"] = "b", ["c"] = "j", }

local nasals = "nṇñṅṉm"

local function transliterate(text) return lang:transliterate(text) end

function export.link(term) return require("Module:links").full_link{ term = term, lang = lang, sc = sc } end

function export.toIPA(text) local translit = transliterate(text) if not translit then error('The term could not be transliterated.') end -- VOICED AFTER NASAL translit = gsub(translit, "([n])([t])", function(a,b) return a .. voicing[b] end) translit = gsub(translit, "([ṇ])([ṭ])", function(a,b) return a .. voicing[b] end) translit = gsub(translit, "([ṅ])([k])", function(a,b) return a .. voicing[b] end) translit = gsub(translit, "([ñ])([c])", function(a,b) return a .. voicing[b] end) translit = gsub(translit, "([m])([p])", function(a,b) return a .. voicing[b] end) -- VOICING translit = gsub(translit, "([aeiouāēīōū])([ptkcṭ])([aeiouāēīōū])", function(a,b,c)    	return a .. voicing[b] .. c end) -- ற் gemination and ன்ற translit = gsub(translit, "[ṟ][ṟ]", "ṭṭr") translit = gsub(translit, "[ṉ][ṟ]", "ṇḍr") -- VOICELESS GEMINATION translit = gsub(translit, "(k)[k]", "%1ː") translit = gsub(translit, "(t)[t]", "%1ː") translit = gsub(translit, "(c)[c]", "%1ː") translit = gsub(translit, "(ṭ)[ṭ]", "%1ː") translit = gsub(translit, "(p)[p]", "%1ː") local result = gsub(translit, ".", correspondences) return result end

function export.make(frame) local args = frame:getParent.args local pagetitle = mw.title.getCurrentTitle.text local p, results = {}, {}, {} if args[1] then for index, item in ipairs(args) do			table.insert(p, (item ~= "") and item or nil) end else p = { pagetitle } end for _, Tamil in ipairs(p) do table.insert(results, { pron = "/" .. export.toIPA(Tamil) .. "/" }) end return m_IPA.format_IPA_full { lang = lang, items = results } end

return export