Module:ang-pron/testcases

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 ' ' .. IPA .. ' '	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 ' " .. term		.. ' ' 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