Module:amf-IPA

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


local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("amf")
local m_para = require("Module:parameters")
local utilities = require("Module:amf-utilities")

local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower
local gmatch = mw.ustring.gmatch

local correspondences = {
	c = "tʃ",
	g = "ɡ",
	j = "dʒ",
	y = "j",
	B = "ɓ",
	C = "tʃʼ",
	D = "ɗ",
	E = "ɛ",
	G = "ɠ",
	N = "ɲ",
	O = "ɔ",
	S = "ʃ",
	T = "tʼ",
	Q = "ʔ",
	L = "ː",		-- long
	X = "\204\164",	-- breathy
	H = "\204\165",	-- voiceless
}

local V = "aeiouEO"

-- custom version of utilities.combine
local function combine(syllables)
	local a,f = syllables.accent, syllables.falling
	local diacritic = f and "\204\130" or "\204\129"
	local word = "" -- do not use table.concat to avoid modifying input
	for i,syl in ipairs(syllables) do
		if i == a then
			syl = syl:gsub("","%0"..diacritic)
		end
		word = word .. syl
	end
	word = word:gsub("",correspondences)
	return mw.ustring.toNFC(word)
end

local function pron(text)
	text = utilities.syllabify(text)
	if text.accent == 0 then
		text.accent = 1
	end
	for i, syl in ipairs(text) do
		text = syl:gsub("()%1", "%1L")
	end
	text = text:gsub("^()", "ʔ%1")
	return text
end

local function phon(text,last)
	local C = "rCDB"
	for i=1,#text do
		if i>1 and text:sub(-1,-1):match("") then
			text = text:gsub("^", {r="ɾ", C="c", D="d", B="β"})
				:gsub("^ba", "βa")
		end
		if text:sub(-1,-1) == "n" and i<#text and text:sub(1,1):match("") then
			text = text:gsub("n$", "ŋ")
		end
		text = text:gsub("^T()", "tsʼ%1")
		text = text:gsub("n()$", "ŋ%1")
	end
	text = text:gsub("^Du", "ʔu")
		:gsub("^ha", "a̤")
		:gsub("^q", {qa="qʼa",qe="qʰe",qi="qʰi",qE="qʰE",qO="qʰO",qo="ʔo",qu="ʔu"})
		:gsub("^()", "%1ʰ")
		:gsub("tʰsʼ", "tsʼ")
	text = text:gsub("$", {p="p̚",b="b̚",B="ɓ̚",m="m̥",n="n̥",r="r̥",l="l̥"})
	if text.accent ~= #text then
		text = text:gsub("^q()$", "qʰ%1")
	end
	if last then -- make the utterance-final vowel (short/long/diphthong) breathy if stressed, voiceless if unstressed
		text = text:gsub("+R?$", function(vowels)
			vowels = vowels:gsub("","%1"..(text.accent == #text and "X" or "H"))
			return vowels
		end)
	end
	return text
end

function export.make(frame)
	local args = m_para.process(frame:getParent().args,{
		 = { list = true, default = mw.loadData("Module:headword/data").pagename }
	})
	local results = {}
	for _, term in ipairs(args) do
		local phonemic, phonetic = {}, {}
		local words = mw.text.split(term, " ", true)
		for i,word in ipairs(words) do
			local syllabified = pron(word)
			phonemic = combine(syllabified)
			phonetic = combine(phon(syllabified,i==#words))
		end
		phonemic = table.concat(phonemic, " ")
		phonetic = table.concat(phonetic, " ")
		table.insert(results, { pron = "/" .. phonemic .. "/" })
		if phonemic ~= phonetic then
			table.insert(results, { pron = "" })
		end
	end
	return m_IPA.format_IPA_full { lang = lang, items = results }
end

return export