মডিউল:ta-IPA
এই মডিউলের জন্য মডিউল:ta-IPA/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
local export = {}
local consonants = {
['க']='k', ['ங']='ŋ', ['ச']='t͡ɕ', ['ஞ']='ɲ', ['ட']='ʈ', ['ண']='ɳ', ['த']='t̪',
['ந']='n̪', ['ப']='p', ['ம']='m', ['ய']='j', ['ர']='ɾ', ['ல']='l', ['வ']='ʋ',
['ழ']='ɻ', ['ள']='ɭ', ['ற']='r', ['ன']='n', ['ஶ']='ɕ', ['ஜ']='d͡ʑ', ['ஷ']='ʂ',
['ஸ']='s', ['ஹ']='h', ['ஃப']='f', ['ஃஜ']='z', ['ஃக']='x',
['ஃ']='',
['க3']='ɡ', ['ட3']='ɖ', ['ப3']='b', ['த3']='d̪', ['ச1']='t͡ɕ', ['ச5']='s'
}
local numbers_sa = {
['1']='1', ['2']='2', ['3']='3', ['4']='4',
['¹']='1', ['²']='2', ['³']='3', ['⁴']='4',
['₁']='1', ['₂']='2', ['₃']='3', ['₄']='4'
}
local diacritics = {
['ா']= 'aː', ['ி']='ɪ', ['ீ']='iː', ['ு']='ʊ', ['ூ']='uː', ['ெ']='ɛ',
['ே']='eː', ['ை']='ɐɪ̯', ['ொ']='ɔ', ['ோ']='oː', ['ௌ']='ɐʊ̯',
['்']='', --halant, supresses the inherent vowel "a"
-- no diacritic
[''] = 'ɐ'
}
local nonconsonants = {
-- independent vowels
['அ']='ɐ', ['ஆ']='aː', ['இ']='ɪ', ['ஈ']='iː', ['உ']='ʊ', ['ஊ']='uː',
['எ']='ɛ', ['ஏ']='eː', ['ஐ']='ɐɪ̯', ['ஒ']='ɔ', ['ஓ']='oː', ['ஔ']='ɐʊ̯',
-- other symbols
['ஃ']='',
}
local adjust1 = {
['ŋk']='ŋɡ', ['ɳʈ']='ɳɖ', ['n̪t̪']='n̪d̪', ['mp']='mb', ['ɲt͡ɕ']='ɲd͡ʑ',
['([aɐeiouɛɪɔʊɯi̯u̯jɾlɭɻnɳ]ː?)k([aɐeioɛɪɔʊuɯi̯u̯])']='%1ɡ%2',
['([aɐeiouɛɪɔʊɯi̯u̯jɾlɭɻnɳ]ː?)ʈ([aɐeioɛɪɔʊɯui̯u̯])']='%1ɖ%2',
['([aɐeiouɛɪɔʊɯi̯u̯jɾlɭɻnɳ]ː?)t̪([aɐeioɛɪɔʊɯui̯u̯])']='%1d̪%2',
['([aɐeiouɛɪɔʊɯi̯u̯jɾlɭɻnɳ]ː?)p([aɐeioɛɪɔʊɯui̯u̯])']='%1b%2'
}
local adjust2 = {
['t͡ɕ'] = 's', ['sː'] = 't͡ɕː',
['ʊ([%s%p])']='ɯ%1', ['ʊ$']='ɯ', ['ɪ([%s%p])']='i%1', ['ɪ$']='i', ['$t͡ɕ']='s', ['([%s%p])t͡ɕ([aɐeiouɯi̯u̯])']='%1s',
['ɲs']='ɲd͡ʑ', ['rr']='tr', ['rː']='tr', ['nr']='ndr',
['t͡ɕ([aɐeioɯuɛɪɔʊi̯u̯])']='s%1',
['([aɐeioɯuɛɪɔʊi̯u̯]ː?)t͡ɕ([aɐeiouɛɪɔʊɯi̯u̯])']='%1s%2',
}
function export.to_IPA(text)
text = mw.ustring.gsub(
text,
'(ஃ?)([க-ஹ])([ா-்]?)([1234¹²³⁴₁₂₃₄]?)',
function(h, c, d, n)
n = numbers_sa[n] or n
return ((consonants[h..c..n] or consonants[h..c]) or (consonants[h] .. (consonants[c..n] or consonant[c] or c))) .. diacritics[d]
end)
text = mw.ustring.gsub(text, '[அ-ஔ]', nonconsonants)
for k, v in pairs(adjust1) do
local count = 1
while count <= 2 do --twice
text = mw.ustring.gsub(text, k, v)
count = count + 1
end
end
--convert consonant gemination to triangular colon
text = mw.ustring.gsub(text, "([kŋɲʈɳpmjʋɻɭrnɕʂshfzx])%1", "%1ː")
text = mw.ustring.gsub(text, "([tnɾl]̪)%1", "%1ː")
text = mw.ustring.gsub(text, "([td]͡[ɕʑ])%1", "%1ː")
--if an independent vowel is after another vowel, assume diphthong
text = mw.ustring.gsub(text, "([aeiouɛɪɔʊ]ː?)•", "%1")
text2 = text --phonetic
for k, v in pairs(adjust2) do
text2 = mw.ustring.gsub(text2, k, v)
end
return (text == text2 and { text } or { text, text2 })
end
function export.show(frame)
local args = frame:getParent().args
local page_title = mw.title.getCurrentTitle().text
local text = args[1] or page_title
local qualifier = args["q"] or nil
local transcriptions = export.to_IPA(text)
local IPA_text
if not transcriptions[2] then
IPA_text = require("Module:IPA").format_IPA_full {
lang = require("Module:languages").getByCode("ta"),
items = {{ pron = "/" .. transcriptions[1] .. "/" }},
}
else
IPA_text = require("Module:IPA").format_IPA_full {
lang = require("Module:languages").getByCode("ta"),
items = {{ pron = "/" .. transcriptions[1] .. "/" }, { pron = "[" .. transcriptions[2] .. "]" }},
}
end
return "* " .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. " " or "")
.. IPA_text
end
return export