Modul:zu-IPA

Üdvözlöm, Ön a Modul:zu-IPA szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:zu-IPA szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:zu-IPA szót egyes és többes számban mondani. Minden, amit a Modul:zu-IPA szóról tudni kell, itt található. A Modul:zu-IPA szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:zu-IPA és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:zu-IPA/doc lapon tudod dokumentálni

local export = {}

local lang = require("Module:languages").getByCode("zu")


local u = mw.ustring.char

local ACUTE     = u(0x0301)
local CIRC      = u(0x0302)
local MACRON    = u(0x0304)
local CARON     = u(0x030C)
local SYLL      = u(0x0329)

local letters_phonemes = {
	 = "a",
	 = "e",
	 = "i",
	 = "o",
	 = "u",
	
	 = "ǀ",  = "ǀʰ",  = "ᵑǀ",  = "ᶢǀʱ",  = "ᵑǀʱ",
	 = "ǃ",  = "ǃʰ",  = "ᵑǃ",  = "ᶢǃʱ",  = "ᵑǃʱ",
	 = "ǁ",  = "ǁʰ",  = "ᵑǁ",  = "ᶢǁʱ",  = "ᵑǁʱ",
	
	 = "ɓ",  = "b",  = "mb",
	 = "d",  = "ɮ",
	 = "f",
	 = "ɡ",  = "nɡ",
	 = "h",  = "ɦ",  = "ɬ",
	 = "dʒ",  = "ɲdʒ", 
	 = "ɠ",  = "kʰ",  = "kx",  = "nk",  = "k",
	 = "l",
	 = "m",  = "mʱ",
	 = "n",  = "nʱ",  = "nɬ",
	 = "ɲ",
	 = "p",  = "pʰ",
	 = "r", 
	 = "s",  = "ʃ",
	 = "t",  = "tʰ",
	 = "tʃ",  = "ɲtʃ",
	 = "v",
	 = "w",  = "wʱ",
	 = "j",  = "jʱ",
	 = "z",
	 = "ʔ",
	
	 = "m" .. SYLL,
	 = "m" .. ACUTE .. SYLL,
	 = "ˈ",
	
	 = "ː",
	 = ACUTE .. "ː",
	 = CIRC .. "ː",
	 = CARON .. "ː",
}

local function IPA_word(term)
	local rest = mw.ustring.toNFD(term)
	local phonemes = {}
	
	while mw.ustring.len(rest) > 0 do
		-- Find the longest string of letters that matches a recognised sequence in the list
		local longestmatch = ""
		
		for letter, phoneme in pairs(letters_phonemes) do
			if mw.ustring.sub(rest, 1, mw.ustring.len(letter)) == letter and mw.ustring.len(letter) > mw.ustring.len(longestmatch) then
				longestmatch = letter
			end
		end
		
		-- Convert the string to IPA
		if mw.ustring.len(longestmatch) > 0 then
			table.insert(phonemes, letters_phonemes)
			rest = mw.ustring.sub(rest, mw.ustring.len(longestmatch) + 1)
		else
			table.insert(phonemes, mw.ustring.sub(rest, 1, 1))
			rest = mw.ustring.sub(rest, 2)
		end
	end
	
	return mw.ustring.toNFC(table.concat(phonemes))
end


function export.IPA(frame)
	local args = frame:getParent().args
	local term
	local tone_needed = ""
	if args then
		term = args
	else
		term = mw.ustring.lower(mw.title.getCurrentTitle().subpageText)
		tone_needed = "<sup title=\"tones missing\">?</sup>"
	end
	
	if not (mw.ustring.find(term, '"') or mw.ustring.find(term, "$")) then
		-- Penultimate lengthening
		term = require("Module:zu-common").split_syllables(term)
		
		if term then
			term = mw.ustring.gsub(term, "$", { = "ā",  = "ē",  = "ī",  = "ō",  = "ū",  = "ā́",  = "ḗ",  = "ī́",  = "ṓ",  = "ū́"})
		end
		
		term = table.concat(term)
	end
	
	term = IPA_word(term)
	return require("Module:IPA").format_IPA_full(lang, {{pron = "/" .. term .. "/"}}) .. tone_needed
end


return export