ഫലകം:ml-IPA
local export = {}
local lang = require("Module:languages").getByCode("ml") local sc = require("Module:scripts").getByCode("Mlym") local m_IPA = require("Module:IPA") local gsub = mw.ustring.gsub
local consonants = { ['ക'] = 'k', ['ഖ'] = 'kʰ', ['ഗ'] = 'ɡ', ['ഘ'] = 'ɡʱ', ['ങ'] = 'ŋ', ['ച'] = 't͡ʃ', ['ഛ'] = 't͡ʃʰ', ['ജ'] = 'd͡ʒ', ['ഝ'] = 'd͡ʒʱ', ['ഞ'] = 'ɲ', ['ട'] = 'ʈ', ['ഠ'] = 'ʈʰ', ['ഡ'] = 'ɖ', ['ഢ'] = 'ɖʱ', ['ണ'] = 'ɳ', ['ത'] = 't̪', ['ഥ'] = 't̪ʰ', ['ദ'] = 'd̪', ['ധ'] = 'd̪ʱ', ['ന'] = 'n̪', ['പ'] = 'p', ['ഫ'] = 'f', ['ബ'] = 'b', ['ഭ'] = 'bʱ', ['മ'] = 'm', ['യ'] = 'j', ['ര'] = 'ɾ', ['ല'] = 'l', ['വ'] = 'ʋ', ['ശ'] = 'ʃ', ['ഷ'] = 'ʂ', ['സ'] = 's', ['ഹ'] = 'h', ['ള'] = 'ɭ', ['ഴ'] = 'ɻ', ['റ'] = 'r', ['ഩ'] = 'n', ['ഺ'] = 't'
}
local vowel_diacritics = { ['ാ'] = 'aː', ['ി'] = 'i', ['ീ'] = 'iː', ['ു'] = 'u', ['ൂ'] = 'uː', ['ൃ'] = 'ri', ['ൄ'] = 'riː', ['ൢ'] = 'li', ['ൣ'] = 'liː', ['െ'] = 'e', ['േ'] = 'eː', ['ൈ'] = 'ɐi̯', ['ൊ'] = 'o', ['ോ'] = 'oː', ['ൌ'] = 'ɐu̯', ['ൗ'] = 'ɐu̯', ['്'] = , ['഻'] = , ['഼'] = , --virama, supresses the inherent vowel "a" [] = 'ɐ' -- no diacritic }
local other = { -- independent vowels ['അ'] = 'ɐ', ['ആ'] = 'aː', ['ഇ'] = 'i', ['ഈ'] = 'iː', ['ൟ'] = 'iː', ['ഉ'] = 'u', ['ഊ'] = 'uː', ['ഋ'] = 'ri', ['ൠ'] = 'riː', ['ഌ'] = 'li', ['ൡ'] = 'liː', ['എ'] = 'e', ['ഏ'] = 'eː', ['ഐ'] = 'ai̯', ['ഒ'] = 'o', ['ഓ'] = 'oː', ['ഔ'] = 'au̯', -- Other symbols ['ർ'] = 'r', ['ൎ'] = 'r', ['ൽ'] = 'l', ['ൾ'] = 'ɭ', ['ൻ'] = 'n', ['ൺ'] = 'ɳ', ['ൿ'] = 'k', ['ൔ'] = 'm', ['ൕ'] = 'j', ['ൖ'] = 'ɻ', ['ം'] = 'm̃', ['ഀ'] = 'm̃', ['ഃ'] = 'h', ['ഁ'] = '̃', -- Chandrabindu ['ഽ'] = , -- Avagraha ['ഄ'] = , -- Vedic anusvara }
local adjust1 = { -- Assimilate the anusvara ['m̃([kɡŋ])'] = 'ŋ%1', ['m̃([td]͡[ʃʒ])'] = 'ɲ%1', ['m̃(ɲ)'] = 'ɲ%1', ['m̃([ʈɖɳ])'] = 'ɳ%1', ['m̃([td]̪)'] = 'n̪%1', ['m̃(n̪)'] = 'n̪%1', ['m̃([tdn])'] = 'n%1', ['m̃([pbmjɾlʋʃʂshɭɻr])'] = 'm%1', ['m̃([%s%p])'] = 'm%1', ['m̃$'] = 'm', ['ŋk'] = 'ŋɡ', ['ɲt͡ʃ'] = 'ɲd͡ʒ', ['ɳʈ'] = 'ɳɖ', ['rr'] = 'tt', ['n̪t̪'] = 'n̪d̪', ['mp'] = 'mb', ['n̪r'] = 'nd', ['ɾɾ'] = 'rr', ['rɾ'] = 'rr', ['ɾr'] = 'rr', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)k([ɐaeioui̯u̯ɨ̆])'] = '%1ɡ%2', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)t͡ʃ([ɐaeioui̯u̯ɨ̆])'] = '%1d͡ʒ%2', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)n̪([ɐaeioui̯u̯ɨ̆])'] = '%1n%2', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)ʈ([ɐaeioui̯u̯ɨ̆])'] = '%1ɖ%2', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)t̪([ɐaeioui̯u̯ɨ̆])'] = '%1d̪%2', ['([ɐaeioui̯u̯ɨ̆jnɳ]ː?)p([ɐaeioui̯u̯ɨ̆])'] = '%1b%2', ['([pt̪tʈʃkbɖʒmn̪nɳŋʋʂshʰʱ])ɾ'] = '%1r', ['([ptʃkbdɡmʋsh])n̪'] = '%1n', ['n̪([mpbkɡjlʋʃs])'] = 'n%1', ['ː̃']='̃ː', ['u്'] = 'ɨ̆', ['uː്'] = 'ɨː', ['ɐൗ'] = 'ɐu̯', }
local adjust2 = { ['d͡ʒɲ'] = 'ɟɲ', ['t̪([pbskɡ])'] = 'l%1', ['d̪([pbskɡ])'] = 'l%1', ['([pt̪tʈkbd̪dɖgmn̪nɳɲŋjlʋʃʒʂshʰʱ])ʋ'] = '%1ʋʷ', ['([pbkɡfʋh])l'] = '%1ɭ', ['t͡ʃt͡ʃ'] = 't̚t͡ʃ', ['d͡ʒd͡ʒ'] = 'd̚d͡ʒ', ['hp'] = 'pp', ['hk'] = 'kk', ['hs'] = 'ss', ['hʃ'] = 'ʃʃ', ['hʂ'] = 'ʂʂ', ['ɲd͡ʒ'] = 'n̠ʲd͡ʒ', }
function export.link(term) return require("Module:links").full_link{ term = term, lang = lang, sc = sc } end
function export.to_IPA(text) local VIRAMA = '്' -- final virama rules text = gsub(text, VIRAMA .. "([%,%.%!%?%:%;]?)$", VIRAMA .. "ɨ̆%1") text = gsub(text, VIRAMA .. "([%,%.%!%?%:%;]?) ", VIRAMA .. "ɨ̆%1 ")
text = mw.ustring.gsub(text, "ɨ̆ ([%,%.%!%?%:%;]?)([ ɐaeiou])", "‿ %1%2") -- ŭ is elided before vowels
text = gsub( text, '([ക-ഺ])(഻?)([ാ-്]?)', function(c, n, d) return ((consonants[c..n] or consonants[c]) or c) .. vowel_diacritics[d] end)
text = gsub(text, '[ം-ൡ]', other)
for k, v in pairs(adjust1) do text = gsub(text, k, v) end
-- If an independent vowel is after another vowel, assume diphthong text = gsub(text, "([ɐaeiou]ː?)•", "%1") text = gsub(text, '.', other)
-- Phonetic transcription text2 = text for k, v in pairs(adjust2) do text2 = 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 = m_IPA.format_IPA_full( lang, { { pron = '/' .. transcriptions[1] .. '/' } }) else IPA_text = m_IPA.format_IPA_full( lang, { { pron = '/' .. transcriptions[1] .. '/' }, { pron = '[' .. transcriptions[2] .. ']' } }) end
return '* ' .. (qualifier and require("Module:qualifier").format_qualifier{qualifier} .. ' ' or ) .. IPA_text
end
return export