Module:it-pronunciation/testcases

local tests = require "Module:UnitTests"

setmetatable(_G, { __index = require "Module:it-pronunciation" })

local function tag_IPA(transcription) if transcription:find "^Error" then return transcription else return ' ' .. transcription .. ' '	end end

local examples = { { "càne", "ˈka.ne", "ˈkäː.n̺e̞" }, { "bène", "ˈbɛ.ne", "ˈbɛː.n̺e" }, { "sóno", "ˈso.no", "ˈs̪oː.n̺o" }, { "sòno", "ˈsɔ.no", "ˈs̪ɔː.n̺o" }, { "ho", "ɔ", "" }, {"all'", "all", ""}, "English letter sequences", { "smoking", "ˈzmo.kiŋ", "" }, { "gangster", "ˈgaŋ.ster", "" }, { "hòckey", "ˈɔ.ke.i", "" }, { "hockeìstico", "o.keˈis.ti.ko", "" }, { "crawl", "krɔl", "" }, "y", { "yo-yo", "ˈjo.jo", "" }, { "whisky", "ˈwis.ki", "" }, "x", { "Craxi", "ˈkrak.si", "" }, "-izzare", { "analizzare", "a.na.lidˈd͡za.re", ""}, { "nazionalizzare", "nat.t͡sjo.na.lidˈd͡za.re", "" }, { "zonizzare", "d͡zo.nidˈd͡za.re", "", true }, { "rizzare", "ritˈt͡sa.re", ""}, "c, g, sc", { "cèlo", "ˈt͡ʃɛ.lo", "ˈt͡ʃɛː.lo" }, { "ciaccòna", "t͡ʃakˈkɔ.na", "t͡ʃäkˈkɔː.n̺ä" }, { "fàccio", "ˈfat.t͡ʃo", "ˈfät͡ʃ.t͡ʃo" }, -- ˈfat.t͡ʃo is too phonetic; other alternative, ˈfa.t͡ʃːo { "che", "ke", "k̟e" }, { "òcchio", "ˈɔk.kjo", "ˈɔk̟.k̟jo" }, -- Good test for syllabification. { "òcchi", "ˈɔk.ki", "ˈɔk̟.k̟i" }, { "òggi", "ˈɔd.d͡ʒi", "ˈɔd͡ʒ.d͡ʒi" }, -- ˈɔd.d͡ʒi is too phonetic; other alternative, ˈɔ.d͡ʒːi { "Sciàlpi", "ˈʃal.pi", "ˈʃäl.pi" }, { "lasciàre", "laʃˈʃa.re", "läʃˈʃäː.r̺e̞" }, { "scleràre", "skleˈra.re", "s̪kleˈr̺äː.r̺e̞" }, { "ùscio", "ˈuʃ.ʃo", "ˈuʃ.ʃo" }, "gn, gl", { "ógni", "ˈoɲ.ɲi", "ˈoɲ.ɲi" }, { "gnòcco", "ˈɲɔk.ko", "ˈɲɔk.ko" }, { "gnagnà", "ɲaɲˈɲa", "ɲäɲˈɲä" }, -- probably not a real word { "vòglio", "ˈvɔʎ.ʎo", "ˈvɔʎ.ʎo" }, { "gli", "ʎi", "ʎi" }, { "inglése", "inˈɡle.se", "iŋˈɡleː.s̪e" }, "ng, nq, nch", { "anche", "ˈan.ke", "ˈäŋ.k̟e" }, { "dúnque", "ˈdun.kwe", "ˈduŋ.kwe" }, { "vóngola", "ˈvon.ɡo.la", "ˈvoŋ.ɡo.lä" }, "s", { "sguardo", "ˈzɡwar.do", "ˈzɡwär.do" }, { "sregolato", "zre.ɡoˈla.to", "zre.ɡoˈläː.to" }, { "gira-sole", "d͡ʒi.raˈso.le", "" }, { "desìdero", "deˈsi.de.ro", "" }, { "ròsa", "ˈrɔ.za", "" }, "z, zz", { "fòrza", "ˈfɔr.t͡sa", "ˈfɔr̺.t̪͡s̪ä" }, { "ragàzza", "raˈɡat.t͡sa", "r̺äˈɡät̪͡s̪.t̪͡s̪ä" }, { "mèzzo", "ˈmɛd.d͡zo", "ˈmɛd̪͡z̪.d̪͡z̪o" }, { "mèzzo", "ˈmɛd.d͡zo", "ˈmɛd̪͡z̪.d̪͡z̪o", { 1 } }, { "zanzara", "d͡zanˈd͡za.ra", "d̪͡z̪änˈd̪͡z̪äː.r̺ä", true }, -- Italian orthography says the z is geminate, while the English -- and Italian Wiktionaries say it isn't. It sounds geminate in the soundfile. { "nazione", "natˈt͡sjo.ne", "n̺ätˈt͡sjoː.n̺e" }, { "spazzi", "ˈspat.t͡si", "ˈspät.t͡si" }, { "zìo", "ˈt͡si.o", "" }, { "agenzìa", "a.d͡ʒenˈt͡si.a", "" }, { "grazie", "ˈɡrat.t͡sje", "" }, { "azienda", "adˈd͡zjen.da", "", { 1 } }, { "romanzière", "ro.manˈd͡zjɛ.re", "", { 1 } }, -- intervocalic "autogeminazione" Autogeminazione { "spazi", "ˈspat.t͡si", "ˈspät.t͡si" }, { "spazî", "ˈspat.t͡si", "ˈspät.t͡si" }, { "ozòno", "odˈd͡zɔ.no", "", true }, "semivowels", { "quéllo", "ˈkwel.lo", "ˈkwel.lo" }, { "grànchio", "ˈɡran.kjo", "ˈɡräŋ.k̟jo" }, { "capiènza", "kaˈpjɛn.t͡sa", "käˈpjɛn̺.t͡sä" }, { "niènte", "ˈnjɛn.te", "ˈnjɛn̪.t̪e" }, -- or [n̺ʲ-]? { "sùo", "ˈsu.o", "ˈsuː.o" }, { "può", "ˈpwɔ", "ˈpwɔ" }, { "nuòvo", "ˈnwɔ.vo", "ˈn̺wɔː.vo" }, { "devi-are", "de.viˈa.re", "" }, { "televisione", "te.le.viˈzjo.ne", "" }, "Handling of words without accents", { "sono", "ˈso.no", "ˈsoː.n̺o" }, { "cane", "ˈka.ne", "ˈkäː.n̺e̞" }, { "carta", "ˈkar.ta", "ˈkär̺.t̪ä" }, "Syllabification", { "sottosvillupo", "sot.to.zvilˈlu.po", "sot.to.zvilˈluː.po" }, { "manùbrio", "maˈnu.brjo", "mäˈn̺u.brjo" }, -- Is u long here? { "àulico", "ˈau.li.ko", "" } --	-- For new examples:	{ "", "", "" },	-- respelling, phonemic, phonetic }

function tests:test_to_phonemic self:iterate(examples,		function (self, example, expected, _, voiced_z)			local success, result = pcall(to_phonemic,example,example)			if not success then				result = ("Error: %s"):format(result)			else				result = result.phonemic			end			--local voiced_text			if not voiced_z then				voiced_text = ""			elseif type(voiced_z) == "boolean" then				if voiced_z then					voiced_text = " (all z sequences are voiced)"				else					voiced_text = " (no z sequences are voiced)"				end			else				voiced_text = (" (z sequence%s %s %s voiced)"):format(					voiced_z[2] and "s" or "",					table.concat(voiced_z, ", "),					voiced_z[2] and "are" or "is")			end			self:equals(example, result, expected, { display = tag_IPA })		end) end

--function tests:test_to_phonetic	self:iterate(examples,		function (self, example, _, expected, voiced_z)			if expected == "" then				return			end			local success, result = pcall(to_phonetic, example, voiced_z)			if not success then				result = ("Error: %s"):format(result)			end			local voiced_text			if not voiced_z then				voiced_text = ""			elseif type(voiced_z) == "boolean" then				if voiced_z then					voiced_text = " (all z sequences are voiced)"				else					voiced_text = " (no z sequences are voiced)"				end			else				voiced_text = (" (z sequence%s %s %s voiced)"):format(					voiced_z[2] and "s" or "",					table.concat(voiced_z, ", "),					voiced_z[2] and "are" or "is")			end			self:equals(example .. voiced_text, result, expected, { display = tag_IPA })		end) end

return tests