Module:ml-IPA

Hello, you have come here looking for the meaning of the word Module:ml-IPA. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:ml-IPA, but we will also tell you about its etymology, its characteristics and you will know how to say Module:ml-IPA in singular and plural. Everything you need to know about the word Module:ml-IPA you have here. The definition of the word Module:ml-IPA will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:ml-IPA, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


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',
	 = 'z',  = 'd',  = 'w',
	
}

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
	)'] = 'ŋ%1',
	͡)'] = 'ɲ%1',  = 'ɲ%1',
	)'] = 'ɳ%1',
	̪)'] = 'n̪%1',  = 'n̪%1',
	)'] = 'n%1',
	)'] = 'm%1',
	)'] = 'm%1',  = 'm',
	 = 'ŋɡ',  = 'ɲd͡ʒ',  = 'ɳɖ',  =  'tt',  = 'n̪d̪',  = 'mb',  = 'nt',
	 = 'rr',  = 'rr',  = 'rr',
	ː?)k()'] = '%1ɡ%2',
	ː?)t͡ʃ()'] = '%1d͡ʒ%2', 
	ː?)n̪()'] = '%1n%2', 
	ː?)ʈ()'] = '%1ɖ%2', 
	ː?)t̪()'] = '%1d̪%2',
	ː?)p()'] = '%1b%2',
	)ɾ'] = '%1r', 
	)n̪'] = '%1n',
	)'] = 'n%1',
	 = 'pp',  = 'kk',  = 'ss',  = 'ʃʃ',  = 'ʂʂ',
	)l'] = '%1ɭ',
	 =  '(ʰ)',  =  '(ʱ)', 
	='̃ː',  = 'nt',
	 = 'ɨ̆',  = 'ɨː',  =  'ɐu̯',
	 = 'z',  = 'd',  = 'w',  = 'ə',  = 'æː',  = 'ɔ',  = 'ɔː', -- English loans
}

local adjust2 = {
	 = 'ɟɲ',
	)'] = 'l%1', )'] = 'l%1',					-- in free variation not universal change
	 = 'nd',
	)ʋ'] = '%1ʋʷ',
	 = 't̚t͡ʃ',  = 'd̚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, "ɨ̆ (?)()", "‿ %1%2") -- ŭ is elided before vowels
	
	text = gsub(
		text,
		'()(഻?)(?)',
		function(c, n, d)
			return ((consonants or consonants) or c) .. vowel_diacritics
		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, "(ː?)•", "%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 or page_title
	local qualifier = args or nil

	local transcriptions = export.to_IPA(text)
	local IPA_text
	if not transcriptions then
		IPA_text = m_IPA.format_IPA_full {
			lang = lang,
			items = {{ pron = "/" .. transcriptions .. "/" }},
		}
	else
		IPA_text = m_IPA.format_IPA_full {
			lang = lang,
			items = {{ pron = "/" .. transcriptions .. "/" }, { pron = " .. "]" }},
		}
	end

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

return export