Jump to content

Module:sh-IPA/testcases

From Wiktionary, the free dictionary

2 of 28 tests failed. (refresh)

TextExpectedActual
test:
Words chosen at random
Passedаеробиоло̀гија
aerobiològija
/aerobiolǒɡija//aerobiolǒɡija/
Passedаба̀жӯр
abàžūr
/abǎʒuːr//abǎʒuːr/
Passedђа̏вољӣ
đȁvoljī
/d͡ʑâʋoʎiː//d͡ʑâʋoʎiː/
Passedадсо̀рпцӣјскӣ
adsòrpcījskī
/adsǒrpt͡siːjskiː//adsǒrpt͡siːjskiː/
Passedадвентѝстичкӣ
adventìstičkī
/adʋentǐstit͡ʃkiː//adʋentǐstit͡ʃkiː/
Passedо̀риз
òriz
/ǒriz//ǒriz/
Passedа̏баџија
ȁbadžija
/âbad͡ʒija//âbad͡ʒija/
Passedгрје̏шка
grjȅška
/ɡrjêʃka//ɡrjêʃka/
Passedсло̀вӣнскӣ
slòvīnskī
/slǒʋiːnskiː//slǒʋiːnskiː/
Passedју̏трошњӣ
jȕtrošnjī
/jûtroʃɲiː//jûtroʃɲiː/
Passedћа̏ћа
ćȁća
/t͡ɕât͡ɕa//t͡ɕât͡ɕa/
PassedАборѝџиница
Aborìdžinica
/aborǐd͡ʒinit͡sa//aborǐd͡ʒinit͡sa/
False digraphs
Passedнаджи́вјети (над'жи́вјети)
nadžívjeti (nad'žívjeti)
/nadʒǐːʋjeti//nadʒǐːʋjeti/
Passedнадја̀чати
nadjàčati
/nadjǎt͡ʃati//nadjǎt͡ʃati/
Syllabic sonorants
Passedцр̑н
cȓn
/t͡sr̩̂ːn//t͡sr̩̂ːn/
Passedвр́ба
vŕba
/ʋř̩ːba//ʋř̩ːba/
Passedр̀ђати
r̀đati
/ř̩d͡ʑati//ř̩d͡ʑati/
Passedзар̀ђати
zar̀đati
/zař̩d͡ʑati//zař̩d͡ʑati/
Passedбрзѝна
brzìna
/br̩zǐna//br̩zǐna/
Passedмаса̀кр
masàkr
/masǎkr̩//masǎkr̩/
Passedбицѝкл
bicìkl
/bit͡sǐkl̩//bit͡sǐkl̩/
Passedкловн
klovn
/kloʋn̩//kloʋn̩/
Passedжа̏нр
žȁnr
/ʒânr̩//ʒânr̩/
Passedкре̏мљ
krȅmlj
/krêmʎ̩//krêmʎ̩/
Montenegrin letters
Passedс́у̏тра
śȕtra
/ɕûtra//ɕûtra/
Torlakian
Failedаба́ити
abáiti
/aˈbaiti//abǎːiti/
Failedпонаѕр́нѕити
ponadzŕndziti
/ponaˈdzr̩ndziti//ponadzř̩ːndziti/
Passedкьт
kăt
/kət//kət/

local tests = require("Module:UnitTests")

local to_IPA = require("Module:sh-IPA").to_IPA
local decompose = mw.ustring.toNFD
local ugsub = mw.ustring.gsub

local diacritic = "[" .. decompose("ȁàȃáāã"):gsub("a", "") .. "]"

local function make_entry_name(text)
	return ugsub(decompose(text), "([aeiourаеиоур])" .. diacritic, "%1")
end

local function link(text, script)
	return '<span class="' .. script .. '" lang="sh">[[' .. make_entry_name(text) .. '#Serbo-Croatian|' .. text .. ']]</span>'
end

local function tag(text, script)
	return '<span class="' .. script .. '" lang="sh">' .. text .. '</span>'
end

local function show_link_and_respelling(entry, respelling, script)
	return link(entry, script)
		.. (respelling and " (" .. tag(respelling, script) .. ")" or "")
end

local options = {
	display = function(text)
		return '<span class="IPA">' .. text .. '</span>'
	end
}

function tests:check(Cyrillic, Latin, IPA, Cyrillic_respelling, Latin_respelling)
	local IPA1, IPA2 =
		to_IPA(Cyrillic_respelling or Cyrillic), to_IPA(Latin_respelling or Latin)
	
	if IPA1 == IPA2 then
		self:equals(show_link_and_respelling(Cyrillic, Cyrillic_respelling, "Cyrl")
				.. "<br>" .. show_link_and_respelling(Latin, Latin_respelling, "Latn"),
				IPA1, IPA, options)
	else
		self:equals(show_link_and_respelling(Cyrillic, Cyrillic_respelling, "Cyrl"),
				IPA1, IPA, options)
		self:equals(show_link_and_respelling(Latin, Latin_respelling, "Latn"),
				IPA2, IPA, options)
	end
end

function tests:test()
	local examples = {
		"Words chosen at random",
		{ "аеробиоло̀гија", "aerobiològija", "/aerobiolǒɡija/" },
		{ "аба̀жӯр", "abàžūr", "/abǎʒuːr/" },
		{ "ђа̏вољӣ", "đȁvoljī", "/d͡ʑâʋoʎiː/" },
		{ "адсо̀рпцӣјскӣ", "adsòrpcījskī", "/adsǒrpt͡siːjskiː/" },
		{ "адвентѝстичкӣ", "adventìstičkī", "/adʋentǐstit͡ʃkiː/" },
		{ "о̀риз", "òriz", "/ǒriz/" },
		{ "а̏баџија", "ȁbadžija", "/âbad͡ʒija/" },
		{ "грје̏шка", "grjȅška", "/ɡrjêʃka/" },
		{ "сло̀вӣнскӣ", "slòvīnskī", "/slǒʋiːnskiː/" },
		{ "ју̏трошњӣ", "jȕtrošnjī", "/jûtroʃɲiː/" },
		{ "ћа̏ћа", "ćȁća", "/t͡ɕât͡ɕa/" },
		{ "Аборѝџиница", "Aborìdžinica", "/aborǐd͡ʒinit͡sa/" },
		"False digraphs",
		{ "наджи́вјети", "nadžívjeti", "/nadʒǐːʋjeti/", "над'жи́вјети", "nad'žívjeti", },
		{ "надја̀чати", "nadjàčati", "/nadjǎt͡ʃati/" },
		"Syllabic sonorants",
		{ "цр̑н", "cȓn", "/t͡sr̩̂ːn/" },
		{ "вр́ба", "vŕba", "/ʋř̩ːba/" },
		{ "р̀ђати", "r̀đati", "/ř̩d͡ʑati/" },
		{ "зар̀ђати", "zar̀đati", "/zař̩d͡ʑati/" },
		{ "брзѝна", "brzìna", "/br̩zǐna/" },
		{ "маса̀кр", "masàkr", "/masǎkr̩/" },
		{ "бицѝкл", "bicìkl", "/bit͡sǐkl̩/" },
		{ "кловн", "klovn", "/kloʋn̩/" }, --not sure of pitch accent
		{ "жа̏нр", "žȁnr", "/ʒânr̩/" },
		{ "кре̏мљ", "krȅmlj", "/krêmʎ̩/" },
		"Montenegrin letters",
		{ "с́у̏тра", "śȕtra", "/ɕûtra/" },
		"Torlakian",
		{ "аба́ити", "abáiti", "/aˈbaiti/" },
		{ "понаѕр́нѕити", "ponadzŕndziti", "/ponaˈdzr̩ndziti/" },
		{ "кьт", "kăt", "/kət/" },
	}
	
	self:iterate(examples, "check")
end

return tests