Jump to content

Module:ang-pron/testcases

From Wiktionary, the free dictionary

All tests passed. (refresh)

TextExpectedActual
test_phonemic:
Passedhabban, pos=verb/ˈxɑb.bɑn//ˈxɑb.bɑn/
Passedēaġe/ˈæ͜ɑː.je//ˈæ͜ɑː.je/
Passedsenġan, pos=verb/ˈsen.jɑn//ˈsen.jɑn/
Passedeċġ, pos=noun/ejj//ejj/
Passedālīefan/ɑːˈli͜yː.fɑn//ɑːˈli͜yː.fɑn/
Passedoferdōn/ˌo.ferˈdoːn//ˌo.ferˈdoːn/
Passedæx, pos=noun/æks//æks/
Passedbeforan/beˈfo.rɑn//beˈfo.rɑn/
Passedāsāƿan, pos=verb/ɑːˈsɑː.wɑn//ɑːˈsɑː.wɑn/
Passedġeong (respelled ġung)/junɡ//junɡ/
Passedsċeolde (respelled sċolde)/ˈʃol.de//ˈʃol.de/
Passedsċeadu (respelled sċadu), pos=noun/ˈʃɑ.du//ˈʃɑ.du/
Passedġeolu/ˈje͜o.lu//ˈje͜o.lu/
Passedsellan, pos=verb/ˈsel.lɑn//ˈsel.lɑn/
Passedfeallan, pos=verb/ˈfæ͜ɑl.lɑn//ˈfæ͜ɑl.lɑn/
Passedwasċan/ˈwɑʃ.ʃɑn//ˈwɑʃ.ʃɑn/
Passedhusċ/xuʃ//xuʃ/
Passedforesċēawung/fo.reˈʃæ͜ɑː.wunɡ//fo.reˈʃæ͜ɑː.wunɡ/
Passedġeddung/ˈjed.dunɡ//ˈjed.dunɡ/
Passedunġewintred (respelled un-ġewintred)/ˈun.jeˌwin.tred//ˈun.jeˌwin.tred/
Passedfleaxen/ˈflæ͜ɑk.sen//ˈflæ͜ɑk.sen/
Passededcwician (respelled ed<cwician)/edˈkwi.ki.ɑn//edˈkwi.ki.ɑn/
Passedān/ɑːn//ɑːn/
Passedān and twēntiġ/ɑːn ɑnd ˈtweːn.tij//ɑːn ɑnd ˈtweːn.tij/
Passedā́n and twēntiġ/ˈɑːn ɑnd ˈtweːn.tij//ˈɑːn ɑnd ˈtweːn.tij/
Passedbēacniendlīċ (respelled bēacni.endlīċ)/ˈbæ͜ɑːk.ni.end.liːt͡ʃ//ˈbæ͜ɑːk.ni.end.liːt͡ʃ/
Passedbedul (respelled bédul)/ˈbe.dul//ˈbe.dul/
Passedbeorhtost/ˈbe͜orx.tost//ˈbe͜orx.tost/
Passedġeāgniendlīċ (respelled ġe<āg.ni.endlīċ)/jeˈɑːɡ.ni.end.liːt͡ʃ//jeˈɑːɡ.ni.end.liːt͡ʃ/
Passed-estre/es.tre//es.tre/
Passedaldorlēas/ˈɑl.dorˌlæ͜ɑːs//ˈɑl.dorˌlæ͜ɑːs/
Passedunclǣne/ˈunˌklæː.ne//ˈunˌklæː.ne/
Passedundōn/unˈdoːn//unˈdoːn/
Passedunġesewenlīċ/ˈun.jeˌse.wen.liːt͡ʃ//ˈun.jeˌse.wen.liːt͡ʃ/
TextExpectedActual
test_phonetic:
Passedhabban[ˈhɑb.bɑn][ˈhɑb.bɑn]
Passedsenġan, pos=verb[ˈsen.d͡ʒɑn][ˈsen.d͡ʒɑn]
Passedsenċġan[ˈsen.d͡ʒɑn][ˈsen.d͡ʒɑn]
Passedeċġ, pos=noun[ed͡ʒ][ed͡ʒ]
Passedālīefan[ɑːˈli͜yː.vɑn][ɑːˈli͜yː.vɑn]
Passedoferdōn[ˌo.verˈdoːn][ˌo.verˈdoːn]
Passedæx, pos=noun[æks][æks]
Passedbeforan[beˈfo.rɑn][beˈfo.rɑn]
Passedġeong (respelled ġung)[juŋɡ][juŋɡ]
Passedsċeolde (respelled sċolde)[ˈʃoɫ.de][ˈʃoɫ.de]
Passedsellan, pos=verb[ˈseɫ.ɫɑn][ˈseɫ.ɫɑn]
Passedfeallan, pos=verb[ˈfæ͜ɑɫ.ɫɑn][ˈfæ͜ɑɫ.ɫɑn]
Passedhēafdes, pos=noun[ˈhæ͜ɑːv.des][ˈhæ͜ɑːv.des]
Passedsiġehrēþiġ (respelled siġe-hrēþiġ)[ˈsi.jeˌr̥eː.ðij][ˈsi.jeˌr̥eː.ðij]
Passedswīþferhþ (respelled swī́þfèrhþ)[ˈswiːθˌferˠxθ][ˈswiːθˌferˠxθ]
Passedmiht, pos=noun[miçt][miçt]
Passedbeorht[be͜orˠxt][be͜orˠxt]
Passednēah[næ͜ɑːx][næ͜ɑːx]
Passedrihte[ˈriç.te][ˈriç.te]
Passedfeohtan, pos=verb[ˈfe͜ox.tɑn][ˈfe͜ox.tɑn]
Passedfeorr[fe͜orˠ][fe͜orˠ]
Passedfæþm[fæðm][fæðm]
Passedwīnġeard (respelled wīn-ġeard), pos=noun[ˈwiːnˌjæ͜ɑrˠd][ˈwiːnˌjæ͜ɑrˠd]
Passedwynsum[ˈwyn.sum][ˈwyn.sum]
Passedċearfull[ˈt͡ʃæ͜ɑr.fuɫ][ˈt͡ʃæ͜ɑr.fuɫ]
Passedwyrgþu[ˈwyrˠɣ.θu][ˈwyrˠɣ.θu]
Passedālīefednes, pos=verb[ɑːˈli͜yː.ved.nes][ɑːˈli͜yː.ved.nes]
Passedpohha[ˈpox.xɑ][ˈpox.xɑ]
Passedadesa[ˈɑ.de.sɑ][ˈɑ.de.sɑ]
Passedhlǣfdīġe (respelled hlǣf-dīġe)[ˈl̥æːvˌdiː.je][ˈl̥æːvˌdiː.je]
Passedǣttren[ˈæːt.tren][ˈæːt.tren]
Passedsċeacga (respelled sċacga)[ˈʃɑɡ.ɡɑ][ˈʃɑɡ.ɡɑ]
Passeddrūsian[ˈdruː.zi.ɑn][ˈdruː.zi.ɑn]
Passedhālsian[ˈhɑːɫ.si.ɑn][ˈhɑːɫ.si.ɑn]
Passedclǣnsian (respelled clǣn[z]ian)[ˈklæːn.zi.ɑn][ˈklæːn.zi.ɑn]

local tests = require "Module:UnitTests"
local m_IPA = require "Module:ang-pron"

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

local function tag_IPA(phonemic)
	return function (IPA)
		if phonemic then
			IPA = '/' .. IPA .. '/'
		else
			IPA = '[' .. IPA .. ']'
		end
		return '<span class="IPA">' .. IPA .. '</span>'
	end
end

local function remove_diacritics(term)
	term = mw.ustring.toNFD(term)
	return term:gsub("\204[\128-\191]", "") -- codepoints U+300-33F
end

local function link(term)
	return '<span class="Latn" lang="ang">[[' .. remove_diacritics(term) .. "#Old English|" .. term
		.. ']]</span>'
end

local phonemic_options = { display = tag_IPA(true), show_difference = true }
function tests:check_phonemic(spelling, respelling, expected, transcription_options)
	local pos = transcription_options.pos
	self:equals(link(spelling) ..
		(spelling ~= respelling and (" (respelled " .. require("Module:script_utilities").tag_text(respelling, lang) .. ")" ) or "") ..
		(pos and ", pos=" .. pos or ""),
		m_IPA.phonemic(respelling, pos), expected, phonemic_options)
end

local phonetic_options = { display = tag_IPA(false), show_difference = true }
function tests:check_phonetic(spelling, respelling, expected, transcription_options)
	local pos = transcription_options.pos
	self:equals(link(spelling) ..
		(spelling ~= respelling and (" (respelled " .. require("Module:script_utilities").tag_text(respelling, lang) .. ")" ) or "") ..
		(pos and ", pos=" .. pos or ""),
		m_IPA.phonetic(respelling, pos), expected, phonetic_options)
end

-- Tab-separated words used in [[Module:ang-pron/testcases]]:
-- word, phonemic transcription, part of speech.
-- The word can be in the form `spelling:respelling` for words needing respelling.
-- The part of speech and preceding tab can be omitted.
local phonemic_examples = [[
habban	ˈxɑb.bɑn	verb
ēaġe	ˈæ͜ɑː.je
senġan	ˈsen.jɑn	verb
eċġ	ejj	noun
ālīefan	ɑːˈli͜yː.fɑn
oferdōn	ˌo.ferˈdoːn
æx	æks	noun
beforan	beˈfo.rɑn
āsāƿan	ɑːˈsɑː.wɑn	verb
ġeong:ġung	junɡ
sċeolde:sċolde	ˈʃol.de
sċeadu:sċadu	ˈʃɑ.du	noun
ġeolu	ˈje͜o.lu
sellan	ˈsel.lɑn	verb
feallan	ˈfæ͜ɑl.lɑn	verb
wasċan	ˈwɑʃ.ʃɑn -- In some existing transcriptions, gemination of /ʃ/ is only phonetic.
husċ	xuʃ
foresċēawung	fo.reˈʃæ͜ɑː.wunɡ
ġeddung	ˈjed.dunɡ
unġewintred:un-ġewintred	ˈun.jeˌwin.tred
fleaxen	ˈflæ͜ɑk.sen
edcwician:ed<cwician	edˈkwi.ki.ɑn
ān	ɑːn
ān and twēntiġ	ɑːn ɑnd ˈtweːn.tij
ā́n and twēntiġ	ˈɑːn ɑnd ˈtweːn.tij
bēacniendlīċ:bēacni.endlīċ	ˈbæ͜ɑːk.ni.end.liːt͡ʃ
bedul:bédul	ˈbe.dul
beorhtost	ˈbe͜orx.tost
ġeāgniendlīċ:ġe<āg.ni.endlīċ	jeˈɑːɡ.ni.end.liːt͡ʃ
-estre	es.tre
aldorlēas	ˈɑl.dorˌlæ͜ɑːs
unclǣne	ˈunˌklæː.ne -- un- before nouns and adjectives is stressed
undōn	unˈdoːn -- un- before verbs is unstressed
unġesewenlīċ	ˈun.jeˌse.wen.liːt͡ʃ -- un- before "verbals" is stressed
]]

-- Same as above, but for phonetic (not phonemic) transcription.
local phonetic_examples = [[
habban	ˈhɑb.bɑn
senġan	ˈsen.d͡ʒɑn	verb
senċġan	ˈsen.d͡ʒɑn
eċġ	ed͡ʒ	noun
ālīefan	ɑːˈli͜yː.vɑn
oferdōn	ˌo.verˈdoːn
æx	æks	noun
beforan	beˈfo.rɑn
ġeong:ġung	juŋɡ
sċeolde:sċolde	ˈʃoɫ.de
sellan	ˈseɫ.ɫɑn	verb -- Should maybe have clear l (ˈsel.lɑn), because e is not diphthongized to eo.
feallan	ˈfæ͜ɑɫ.ɫɑn	verb
hēafdes	ˈhæ͜ɑːv.des	noun
siġehrēþiġ:siġe-hrēþiġ	ˈsi.jeˌr̥eː.ðij
swīþferhþ:swī́þfèrhþ	ˈswiːθˌferˠxθ
miht	miçt	noun
beorht	be͜orˠxt
nēah	næ͜ɑːx
rihte	ˈriç.te
feohtan	ˈfe͜ox.tɑn	verb
feorr	fe͜orˠ
fæþm	fæðm
wīnġeard:wīn-ġeard	ˈwiːnˌjæ͜ɑrˠd	noun
wynsum	ˈwyn.sum
ċearfull	ˈt͡ʃæ͜ɑr.fuɫ
wyrgþu	ˈwyrˠɣ.θu
ālīefednes	ɑːˈli͜yː.ved.nes	verb
pohha	ˈpox.xɑ
adesa	ˈɑ.de.sɑ
hlǣfdīġe:hlǣf-dīġe	ˈl̥æːvˌdiː.je
ǣttren	ˈæːt.tren
sċeacga:sċacga	ˈʃɑɡ.ɡɑ
drūsian	ˈdruː.zi.ɑn                 --s would be voiced here because the word is from *drūsijaną
hālsian	ˈhɑːɫ.si.ɑn                 --s thought to be voiceless here because the word is contracted (from PG hailisōną)
clǣnsian:clǣn[z]ian	ˈklæːn.zi.ɑn    --exception with voicing despite contraction
]]

local function parse(examples)
	local parsed_examples = {}
	for line in examples:gsub("%s*%-%-[^\n]*", ""):gmatch "[^\n]+" do
		local word, phonemic, POS = line:match "^([^\t]+)\t([^\t]+)\t?(.*)"
		local spelling, respelling = word:match "^(.*):(.*)$"
		spelling = spelling or word
		respelling = respelling or word
		if POS == "" then
			POS = nil
		end
		table.insert(parsed_examples, { spelling, respelling, phonemic, { pos = POS }})
	end
	return parsed_examples
end

function tests:test_phonemic()
	self:iterate(parse(phonemic_examples), "check_phonemic")
end

function tests:test_phonetic()
	self:iterate(parse(phonetic_examples), "check_phonetic")
end

return tests