உள்ளடக்கத்துக்குச் செல்

Module:si-IPA

கட்டற்ற பன்மொழி அகரமுதலியான விக்சனரியில் இருந்து.

Documentation for this module may be created at Module:si-IPA/doc

local export = {}

local lang = require("Module:languages").getByCode("si")
local sc = require("Module:scripts").getByCode("Sinh")
local m_IPA = require("Module:IPA")
local gsub = mw.ustring.gsub

local consonants = {
	['ක']='k', ['ඛ']='k', ['ග']='g', ['ඝ']='g', ['ඞ']='ŋ', ['ඟ']='ᵑg', 
	['ච']='t͡ʃ', ['ඡ']='t͡ʃ', ['ජ']='d͡ʒ', ['ඣ']='d͡ʒ', ['ඤ']='ɲ', ['ඥ']='gn', ['ඦ']='ᶮd͡ʒ', 
	['ට']='ʈ', ['ඨ']='ʈ', ['ඩ']='ɖ', ['ඪ']='ɖ', ['ණ']='ɳ', ['ඬ']='ᶯɖ',
	['ත']='t',  ['ථ']='t', ['ද']='d', ['ධ']='d', ['න']='n', ['ඳ']='ⁿd', 
	['ප']='p', ['ෆ']='f', ['ඵ']='p', ['බ']='b', ['භ']='b', ['ම']='m', ['ඹ']='ᵐb', 
	['ය']='j', ['ර']='r', ['ල']='l', ['ව']='w', 
	['ශ']='ʃ', ['ෂ']='ʃ', ['ස']='s', ['හ']='h', ['ළ']='ɭ'
}

local vowel_diacritics = {
	['ා'] = 'aː',	['ැ'] = 'æ',	['ෑ'] = 'æː',	['ි'] = 'i',	['ී'] = 'iː',	['ු'] = 'u',	['ූ'] = 'uː',
	['ෙ'] = 'e',	['ේ'] = 'eː', 	['ෛ'] = 'ai', 	['ො'] = 'o', 	['ෝ'] = 'oː', 	['ෞ'] = 'au',
	['ෘ'] = 'ru',	['ෟ'] = 'lu', 	['ෲ'] = 'ruː', 	['ෳ'] = 'luː',
	['්'] = ''		-- virama
}

local other = {
	-- vowels
	['අ']='a' ,  ['ආ']='aː' ,  ['ඇ']='æ' ,   ['ඈ']='æː' ,  ['ඉ']='i' ,  ['ඊ']='iː' ,  ['උ']='u' ,  ['ඌ']='uː' , 
	['එ']='e' ,  ['ඒ']='eː' ,  ['ඓ']='ai' ,  ['ඔ']='o' ,  ['ඕ']='oː' ,  ['ඖ']='au' , 
	['ඍ']='ru' ,  ['ඎ']='ruː' ,  ['ඏ']='lu' ,  ['ඐ']='luː' ,     
	-- other symbols
	['ං']='m̃' , -- anusvara
	['ඃ']='h' ,  -- visarga
	['්']='' ,  --hal kirīma, suppresses the inherent vowel "a"
	-- punctuation
	['෴']='' ,  -- kunddaliya (obsolete)    
}

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

local adjust2 = {
	['d͡ʒɲ']='ɟɲ',
	['t͡ʃt͡ʃ']='t̚t͡ʃ', ['d͡ʒd͡ʒ']='d̚d͡ʒ', ['ɲd͡ʒ']='n̠ʲd͡ʒ',
--	['hp']='pp', ['hk']='kk', ['hs']='ss', ['hʃ']='ʃʃ', ['hʂ']='ʂʂ',
}

function export.link(term)
	return require("Module:links").full_link{ term = term, lang = lang, sc = sc }
end

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 = 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
"https://ta.wiktionary.org/w/index.php?title=Module:si-IPA&oldid=1991045" இலிருந்து மீள்விக்கப்பட்டது