Modul:ar-pronunciation

2 teszt sikertelen. (frissítés)

Szöveg Várt Tényleges Megjegyzések
test1_transliteration:
Sikeres tilivizyōn ti.li.viz.joːn ti.li.viz.joːn
Sikeres ʾinglīziyy ʔinɡliː.zijj ʔinɡliː.zijj
Szöveg Várt Tényleges Megjegyzések
test_Arabic:
Sikeres طَبَّ(ṭabba) tˤab.ba tˤab.ba
Sikeres رُوسِيَا(rūsiyā) ruː.si.jaː ruː.si.jaː
Sikeres أَنْتَ(ʔanta) ʔan.ta ʔan.ta
Sikeres ذٰلِكَ(ḏālika) ðaː.li.ka ðaː.li.ka
Sikeres صَغِير(ṣaḡīr) sˤa.ɣiːr sˤa.ɣiːr
Sikeres إِصْبَع(ʔiṣbaʕ) ʔisˤ.baʕ ʔisˤ.baʕ
Sikeres عَلَى(ʕalā) ʕa.laː ʕa.laː
Sikeres جَزِيرَة(jazīra) d͡ʒa.ziː.ra d͡ʒa.ziː.ra
Sikeres أَرْبَعَة(ʔarbaʕa) ʔar.ba.ʕa ʔar.ba.ʕa
Sikeres حُبّ(ḥubb) ħubb ħubb
Sikeres عَرَبِيّ(ʕarabiyy) ʕa.ra.bijj ʕa.ra.bijj
Sikeres خَاصّ(ḵāṣṣ) xaːsˤsˤ xaːsˤsˤ
Sikeres خَاصَّة(ḵāṣṣa) xaːsˤ.sˤa xaːsˤ.sˤa
Sikertelen Parancsfájlhiba tesztelés közben: package.lua:80: module 'Module:Unicode data/combining classes' not found
stack traceback:
	[C]: ?
	[C]: in function 'error'
	package.lua:80: in function 'load'
	package.lua:99: in function <package.lua:89>
	(tail call): ?
	mw.lua:496: in function 'executeModule'
	mw.lua:768: in function 'loadData'
	Modul:Unicode_data:390: in function 'combining_class'
	Modul:Unicode_data:397: in function 'is_combining'
	Modul:UnitTests:42: in function 'find_noncombining'
	Modul:UnitTests:56: in function 'highlight_difference'
	Modul:UnitTests:171: in function 'equals'
	Modul:ar-pronunciation/testcases:16: in function 'func'
	Modul:UnitTests:225: in function 'iterate'
	Modul:ar-pronunciation/testcases:69: in function <Modul:ar-pronunciation/testcases:24>
	(tail call): ?
	[C]: in function 'xpcall'
	Modul:UnitTests:286: in function <Modul:UnitTests:251>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	[C]: ?

local export = {}

local lang = require("Module:languages").getByCode("ar")
local sc = require("Module:scripts").getByCode("Arab")

local str_gsub = string.gsub
local str_gmatch = string.gmatch
local ugsub = mw.ustring.gsub
local ugmatch = mw.ustring.gmatch

local correspondences = {
	["ʾ"] = "ʔ",
	["ṯ"] = "θ",
	["j"] = "d͡ʒ",
	["ḥ"] = "ħ",
	["ḵ"] = "x",
	["ḏ"] = "ð",
	["š"] = "ʃ",
	["ṣ"] = "sˤ",
	["ḍ"] = "dˤ",
	["ṭ"] = "tˤ",
	["ẓ"] = "ðˤ",
	["ž"] = "ʒ",
	["ʿ"] = "ʕ",
	["ḡ"] = "ɣ",
	["ḷ"] = "ɫ",
	["ū"] = "uː",
	["ī"] = "iː",
	["ā"] = "aː",
	["y"] = "j",
	["g"] = "ɡ",
	["ē"] = "eː",
	["ō"] = "oː",
	[""] = "",
}

--[[
-- Not really needed
local identical = "btrzsfqklmnhwaui"
for character in str_gmatch(identical, ".") do
	correspondences[character] = character
end
--]]

local vowels = "aāeēiīoōuū"
local vowel = "[" .. vowels .. "]"
local long_vowels = "āēīōū"
local long_vowel = "[" .. long_vowels .. "]"
local consonant = "[^" .. vowels .. ". -]"
local syllabify_pattern = "(" .. vowel .. ")(" .. consonant .. "?)(" .. consonant .. "?)(" .. vowel .. ")"
local tie = "‿"
local closed_syllable_shortening_pattern =
	"(" .. long_vowel .. ")(" .. tie .. ")" .. "(" .. consonant .. ")"

local function syllabify(text)
	text = ugsub(text, "%-(" .. consonant .. ")%-(" .. consonant .. ")", "%1.%2")
	text = str_gsub(text, "%-", ".")
	
	-- Add syllable breaks.
	for count = 1, 2 do
		text = ugsub(
			text,
			syllabify_pattern,
			function(a, b, c, d)
				if c == "" and b ~= "" then
					c, b = b, ""
				end
				
				return a .. b .. "." .. c .. d
			end
		)
	end
	
	-- Add ties between word-final vowels and word-initial consonant clusters.
	text = ugsub(
		text,
		"(" .. vowel .. ") (" .. consonant .. ")%.?(" .. consonant .. ")",
		"%1" .. tie .. "%2.%3"
	)
	
	return text
end

local function closed_syllable_shortening(text)
	local shorten = {
		["ā"] = "a",
		["ē"] = "e",
		["ī"] = "i",
		["ō"] = "o",
		["ū"] = "u",
	}
	
	text = ugsub(text,
		closed_syllable_shortening_pattern,
		function (vowel, tie, consonant)
			return shorten[vowel] .. tie .. consonant
		end)
	
	return text
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(list, silent_error)
	local translit
	
	if list.tr then
		translit = list.tr
	elseif list.Arabic then
		--	Returns an error if the word contains alphabetic characters that are not Arabic.
		require("Module:script utilities").checkScript(list.Arabic, "Arab")
		
		translit = transliterate(list.Arabic)
		
		if not translit then
			if silent_error then
				return ''
			else
				error('Module:ar-translit failed to generate a transliteration from "' .. list.Arabic .. '".')
			end
		end
	else
		if silent_error then
			return ''
		else
			error('No Arabic text or transliteration was provided to the function "toIPA".')
		end
	end
	
	translit = str_gsub(translit, "llāh", "ḷḷāh")
	translit = ugsub(translit, "([iī] ?)ḷḷ", "%1ll")
	
	-- Remove the transliterations of any tāʾ marbūṭa not marked with a sukūn.
	translit = str_gsub(translit, "%(t%)", "")
	-- Prodelision after tāʾ marbūṭa
	translit = ugsub(translit, "(" .. vowel .. ") " .. vowel, "%1 ")
	
	translit = syllabify(translit)
	translit = closed_syllable_shortening(translit)
	
	local output = ugsub(translit, ".", correspondences)

	output = str_gsub(output, "%-", "")
	
	return output
end

function export.show(frame)
	local params = {
		[1] = {},
		["tr"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local Arabic = args[1]
	local transliteration = args.tr
	
	if not ( Arabic or transliteration ) then
		if mw.title.getCurrentTitle().nsText == "Sablon" then
			Arabic = "كَلِمَة"
		else
			error('Please provide vocalized Arabic in the first parameter of {{[[Template:ar-IPA|ar-IPA]]}}, or transliteration in the "tr" parameter.')
		end
	end
	
	local pron = export.toIPA{ Arabic = Arabic, tr = transliteration }
	
	return require("Module:IPA").format_IPA_full(lang, { { pron = "/" .. pron .. "/" } } )
end

return export