Module:bfq-IPA

local export = {}

local consonants = { ['க​']='k', ['க​']='kʰ', ['க​'] = 'ɡ', ['க​'] ='ɡʱ', ['ங்']='ŋ', ['ச​']='t͡ʃ', ['ச​']='t͡ʃʰ', ['ச​']='d͡ʒ', ['ச​']='d͡ʒʱ', ['ஞ​']='ɲ', ['ட']='ʈ', ['ட']='ʈʰ', ['ட']='ɖ', ['ட']='ɖʱ', ['ண​']='ɳ', ['த']='t̪', ['த']='t̪ʰ', ['த']='d̪', ['த']='d̪ʱ', ['ந​']='n̪', ['ப​']='p', ['ப​']='pʰ', ['ப​']='b', ['ப​']='bʱ', ['ம']='m', ['ஜ​']='j', ['ர​']='ɾ', ['ல​']='l', ['வ​']='ʋ', ['ஶ']='ʃ', ['ஷ']='ʂ', ['ஸ​']='s', ['ஹ​']='h', ['ள​']='ɭ', ['ழ']='ɻ', ['ற']='r', }

local vowel_diacritics = { ['ா']= 'aː', ['ி']='i', ['ீ']='iː', ['ு']='u', ['ூ']='uː', ['ெ']='e', ['ே']='eː', ['ை']='ɐi̯', ['ொ']='o', ['ோ']='oː', ['ௌ']='ɐu̯', ['்']='',	-- Virama - suppresses the inherent vowel "a" [''] = 'ɐ'	-- No diacritic; inherent vowel }

local other = { -- independent vowels ['அ']='ɐ', ['ஆ']='aː', ['இ']='i', ['ஈ']='iː', ['உ']='u', ['ஊ']='uː', ['எ']='e', ['ஏ']='eː', ['ஐ']='ɐi̯', ['ஒ']='o', ['ஓ']='oː', ['ஔ']='ɐu̯', -- Other symbols ['ஃ']='',

}

local adjust1 = { -- Assimilate the anusvara ['m̃([kɡŋ])']='ŋ%1', ['m̃([td]͡[ʃʒ])']='ɲ%1', ['m̃(ɲ)']='ɲ%1', ['m̃([ʈɖɳ])']='ɳ%1', ['m̃([td]̪)']='n̪%1', ['m̃([td]͡[sz])']='n̪%1', ['m̃(n̪)']='n̪%1', ['m̃([pbmjɾlʋʃʂshɭ])']='m%1', ['m̃([%s%p])']='m%1', ['m̃$']='m' }

local adjust2 = { -- Account for differences in phonemes vs. phones }

function export.to_IPA(text)

text = mw.ustring.gsub(		text,		'([ಕ-ಹ])(಼?)([ಾ-್]?)',		function(c, n, d)			return ((consonants[c..n] or consonants[c]) or c) .. vowel_diacritics[d]		end)

text = mw.ustring.gsub(text, '[ಂ-ೡ]', other)

for k, v in pairs(adjust1) do		text = mw.ustring.gsub(text, k, v)	end

-- If an independent vowel is after another vowel, assume diphthong text = mw.ustring.gsub(text, "([ɐaeiou]ː?)•", "%1")

-- Phonetic transcription text2 = text 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("bfq"), items = , }	else IPA_text = require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("bfq"), items = {{ pron = "/" .. transcriptions[1] .. "/" }, { pron = "[" .. transcriptions[2] .. "]" }},		}	end

return "* " .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. " " or "") .. IPA_text end

return export