মডিউল: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', ['ீ']='iː', ['ு']='u', ['ூ']='uː', ['ெ']='e',
['ே']='eː', ['ை']='aɪ̯', ['ொ']='o', ['ோ']='oː', ['ௌ']='aʊ̯',
['்']='', --halant, supresses the inherent vowel "a"
-- no diacritic
[''] = 'ɐ'
}
local nonconsonants = {
-- independent vowels
['அ']='ɐ', ['ஆ']='aː', ['இ']='i', ['ஈ']='iː', ['உ']='u', ['ஊ']='uː',
['எ']='e', ['ஏ']='eː', ['ஐ']='ɐi̯', ['ஒ']='o', ['ஓ']='oː', ['ஔ']='ɐu̯',
-- other symbols
['ஃ']='',
}
local adjust1 = {
['ŋk']='ŋɡ', ['ɳʈ']='ɳɖ', ['n̪t̪']='n̪d̪', ['mp']='mb', ['ɲt͡ɕ']='ɲd͡ʑ',
['([aɐeiouɯi̯u̯jɾlɭɻnɳ]ː?)k([aɐeiouɯ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͡ɕː',
['u([%s%p])']='ɯ%1', ['u$']='ɯ', ['$t͡ɕ']='s', ['([%s%p])t͡ɕ([aɐeiouɯi̯u̯])']='%1s',
['ɲs']='ɲd͡ʑ', ['rr']='tr', ['rː']='tr', ['nr']='ndr',
['t͡ɕ([aɐeioɯui̯u̯])']='s%1',
['([aɐeioɯui̯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('মডিউল:আধ্বব').format_IPA_full(
require('Module:languages').getByCode('ta'),
{ { pron = '/' .. transcriptions[1] .. '/' } })
else
IPA_text = require('মডিউল:আধ্বব').format_IPA_full(
require('Module:languages').getByCode('ta'),
{ { pron = '/' .. transcriptions[1] .. '/' }, { pron = '[' .. transcriptions[2] .. ']' } })
end
return '* ' .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. ' ' or '')
.. IPA_text
end
return export