Icona de documentació de mòdul Documentació del mòdul[mostra] [modifica] [refresca]

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Mòdul de suport per la plantilla:xib-pron. Vegeu Viccionari:Pronúncia de l'ibèric per a més informació.

local export = {}

local letters_ipa = {
	["a"] = "a",
	["e"] = "e",
	["i"] = "i",
	["o"] = "o",
	["u"] = "u",
	
	['ai']='aj',
	['ei']='ej',
	['au']='aw',
	
	["b"] = "b",
	["k"] = "ɡ",
	["g"] = "ɡ",
	["t"] = "d",
	["d"] = "d",
	
	["l"] = "l",
	["lt"] = "ll",
	["ld"] = "ll",
	
	["n"] = "n",
	["nb"] = "m",
	["m"] = "nn",
	["ḿ"] = "na",
	
	["ŕ"] = "r",
	["r"] = "ɾ",
	
	["ś"] = "s",
	["s"] = "t͡s",
}

local function letters_to_ipa(word)
	local phonemes = {}
	
	while mw.ustring.len(word) > 0 do
		local longestmatch = ""
		
		for letter, ipa in pairs(letters_ipa) do
			if mw.ustring.len(letter) > mw.ustring.len(longestmatch) and mw.ustring.sub(word, 1, mw.ustring.len(letter)) == letter then
				longestmatch = letter
			end
		end
		
		if mw.ustring.len(longestmatch) > 0 then
			table.insert(phonemes, letters_ipa[longestmatch])
			word = mw.ustring.sub(word, mw.ustring.len(longestmatch) + 1)
		else
			table.insert(phonemes, mw.ustring.sub(word, 1, 1))
			word = mw.ustring.sub(word, 2)
		end
	end
	
	return table.concat(phonemes)
end

local function convert_words(words, dual_script)
	words = mw.ustring.lower(words)
	words = mw.ustring.gsub(words,'[,?!:;()\'"%-]', '')
	
	if dual_script or mw.ustring.find(words, "[dg]") then
		dual_script = true
		letters_ipa["k"] = "k"
		letters_ipa["t"] = "t"
	end
	
	local result = {}
	
	for word in mw.text.gsplit(words, " ") do
		table.insert(result, letters_to_ipa(word))
	end
	
	local ret = {}
	ret[1] = table.concat(result, " ")
	if not dual_script and mw.ustring.find(ret[1], '[ɡd]') then
		ret[2] = mw.ustring.gsub(ret[1], '[ɡd]', {["ɡ"] = "k", ["d"] = "t"})
	end
	return ret
end

function export.show(words)
	local dual
	if type(words) == "table" then -- assume a frame
		if words.args.dual ~= nil and words.args.dual ~= '' then
			dual = true
		end
		words = words.args[1]
		if words == nil or words == '' then
			words = mw.title.getCurrentTitle().text
		end
	end
	
	return "/" .. table.concat(convert_words(words, dual), "/, /") .. "/"
end

return export