Module:ybi-IPA

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

Yamphu IPA pronunciation module. See {{ybi-IPA}}.


local export = {}

local lang = require("Module:languages").getByCode("ybi")
local m_IPA = require("Module:IPA")

local decode_entities = require("Module:string utilities").decode_entities
local gsub = mw.ustring.gsub
local gmatch = mw.ustring.gmatch
local find = mw.ustring.find
local toNFC = mw.ustring.toNFC

local correspondences = {
	 = "ː",
	 = "ŋ",
	 = "ɡ",
	 = "k",
	 = "p",
	 = "b",
	 = "t͡s",
	 = "d͡z",
	 = "ɲ",
	 = "ʈ",
	 = "ɖ",
	 = "t",
	 = "d",
	 = "j",
	 = "w",
	 = "l",
	 = "s",
	 = "ʃ",
	 = "s",
	 = "h",
	 = "n",
	 = "̃",
	 = "ʔ",
	 = "r",
	 = "ɳ",
	 = "ʔ",
	 = "",
	 = "",

	 = "ʌ",
	 = "i",
	 = "u",
	 = "e",
	 = "o",
	 = "ɛ",
	 = "ɔ",

	 = "a",
	 = "iː",
	 = "uː",
	 = "eː",
	 = "oː",

	 = "ː",

	 = " ",
	 = ",",
	 = 'ː',
}

local vowels = "aiueoôêɔɛaːāīūēōô̄ê̄ˑ"
local weak_h_c = "gjdṇḍbvrṟwy"
local primary_stress = "ˈ"
local secondary_stress = "ˌ"
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 = mw.ustring.char(cc)
		if find(current .. ch, "^$") or find(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 = gsub(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)
		text = gsub(text, "(" .. vowels .. ")(?=" .. vowels .. ")", "%1.")
	end
	for count = 1, 2 do
		text = gsub(text, "(" .. vowels .. ")(" .. vowels .. ")", "%1.%2")
	end
	return text
end

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

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

function export.toIPA(text, phonetic)
	local translit = lang:transliterate(text)

	if not translit then
		error('The term "' .. text .. '" could not be transliterated.')
	end
	translit = decode_entities(translit)

	if phonetic then
		translit = gsub(translit, 'c(h?)c(h)', 't̚t͡sʰ')
		translit = gsub(translit, 'cc', 't̚t͡s')
		translit = gsub(translit, 'j(h?)j(h)', 'd̚d͡zʱ')
		translit = gsub(translit, 'jj', 'd̚d͡z')
	end

	translit = gsub(translit, "*", "")
	translit = gsub(translit, "͠", "̃")
	translit = gsub(translit, "̃", "̃")
	translit = gsub(translit, '̄', 'ː')
	translit = gsub(translit, "%-", " ")
	translit = syllabify(translit)

	-- aspiration rules
	translit = gsub(translit, aspirate .. "h", '%1ʰ')
	translit = gsub(translit, weak_h, '%1ʱ')
	translit = gsub(translit, '()%.h', '.%1ʱ')
	translit = gsub(translit, aspirate .. '%.h', '.%1ʰ')
	translit = gsub(translit, "%.ː", "ː.")

	translit = gsub(translit, ".", correspondences)

	-- formatting
	translit = gsub(translit, "ː̃", "̃ː")
	translit = gsub(translit, "ː.̃", "̃ː.")
	translit = gsub(translit, "%.$", " ")
	translit = gsub(translit, "%.?%-", ".")
	translit = gsub(translit, "ː%.̃", "̃ː.")

	translit = toNFC(translit)

	return translit
end

function export.make(frame)
	local args = frame:getParent().args
	local pagetitle = mw.title.getCurrentTitle().text

	local p, results = {}, {}

	if args then
		for _, item in ipairs(args) do
			table.insert(p, (item ~= "") and item or nil)
		end
	else
		p = { pagetitle }
	end

	for _, term in ipairs(p) do
		table.insert(results, { pron = "/" .. export.toIPA(term) .. "/" })
		if export.toIPA(term, true) ~= export.toIPA(term) then
			table.insert(results, { pron = "" })
		end
	end
	
	mw.logObject(results)

	return m_IPA.format_IPA_full { lang = lang, items = results }
end

return export