Module:User:Benwing2/gu-IPA

Hello, you have come here looking for the meaning of the word Module:User:Benwing2/gu-IPA. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Benwing2/gu-IPA, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Benwing2/gu-IPA in singular and plural. Everything you need to know about the word Module:User:Benwing2/gu-IPA you have here. The definition of the word Module:User:Benwing2/gu-IPA will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Benwing2/gu-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("gu")
local sc = require("Module:scripts").getByCode("Gujr")
local IPA_module = "Module:User:Benwing2/IPA"
local parameter_utilities_module = "Module:User:Benwing2/parameter utilities"

local u = require("Module:string/char")
local ufind = mw.ustring.find
local ugmatch = mw.ustring.gmatch
local ugsub = mw.ustring.gsub

local correspondences = {
     = "ŋ",  = "ɡ", 
     = "t͡ʃ",  = "d͡ʒ",  = "ɲ",
     = "ʈ",  = "ɖ",  = "ɳ",
     = "t̪",  = "d̪",
     = "j",  = "ɾ",  = "ʋ",  = "l̪",
     = "ʃ",  = "ʂ",  = "ɦ",
     = "ɭ",  = "f",  = "ɣ",  = "ð",  = "β", 
     = "ɽ",

     = "ə",  = "ɑ",  = "ɪ",
     = "i",  = "o",  = "eː",  = "ɾʊ",
     = "u",  = "u",  = "ɔ",  = "ɔ",  = "ɛ",  = "æ",
     = "ə̤",  = "a̤",  = "i̤",  = "ṳ",   = "ɛ̤",  = "ɔ̤", 
     = "om",  = "ʰ",
     = "‿ˈ", -- get rid of spaces
}

local vowels = "aāiīuūoɔɛeæãā̃ẽĩī̃õũū̃ː"
local weak_h = "()h"
local aspirate = "()"
local syllabify_pattern = "()(+)()"

local function find_consonants(text)
	local current = ""
	local cons = {}
	for cc in mw.ustring.gcodepoint(text .. " ") do
		local ch = u(cc)
		if ufind(current .. ch, "^$") or ufind(current .. ch, "^h$") then
			current = current .. ch
		else
			table.insert(cons, current)
			current = ch
		end
	end
	return cons
end

local function syllabify(text)
	for count = 1, 2 do
		text = ugsub(text, syllabify_pattern, function(a, b, c)
			b_set = find_consonants(b)
			table.insert(b_set, #b_set > 1 and 2 or 1, ".")
			return a .. table.concat(b_set) .. c end)
	end
	return text
end

local identical = "knlsfzθ"
for character in ugmatch(identical, ".") do
	correspondences = character
end

local function transliterate(text)
	return (lang:transliterate(text))
end

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

function export.toIPA(text)
	local result = {}
	local translit = text
	if lang:findBestScript(text):isTransliterated() then
		translit = transliterate(text)
	end
	if not translit then
		error('The term "' .. text .. '" could not be transliterated.')
	end
	
	local translit = ugsub(translit, "͠", "̃")
	local translit = ugsub(translit, "%-", ".")
	local translit = ugsub(translit, "ṣ()", "ś%1")
	
    local translit = syllabify(translit)
    local translit = ugsub(translit, 'jñ', 'gy')
    local translit = ugsub(translit, aspirate .. "h", '%1ʰ')
    local translit = ugsub(translit, weak_h, '%1ʱ')
	local translit = ugsub(translit, "%.ː", "ː.")
	
	for character in ugmatch(translit, ".") do
		table.insert(result, correspondences or character)
	end
	
	result = table.concat(result)
	local TILDE = u(0x0303) -- tilde =  ̃
	local result = ugsub(result, "ː" .. TILDE, TILDE .. "ː")

	result = ugsub(result, "%.‿", "‿")
    
	return "ˈ" .. result
end

function export.make(frame)
	local parent_args = frame:getParent().args

	local params = {
		 = {list = true, allow_holes = true, default = "+"},
		 = {},
	}

	local m_param_utils = require(parameter_utilities_module)

	local param_mods = m_param_utils.construct_param_mods {
		{group = {"q", "a", "ref"}},
	}

	local items, args = m_param_utils.process_list_arguments {
		params = params,
		param_mods = param_mods,
		raw_args = parent_args,
		termarg = 1,
		term_dest = "pron",
		track_module = "gu-IPA",
	}

	local pagename = args.pagename or mw.loadData("Module:headword/data").pagename

	for _, item in ipairs(items) do
		local respelling = item.pron or "+"
		if respelling == "+" then
			respelling = pagename
		end
		item.pron = "/" .. export.toIPA(respelling) .. "/"
	end
	
	return require(IPA_module).format_IPA_full {
		lang = lang,
		items = items,
		a = args.a.default,
		aa = args.aa.default,
		q = args.q.default,
		qq = args.qq.default,
	}
end

return export