Jump to content

Module:IPAc-en/data

Permanently protected module
From Wikipedia, the free encyclopedia

-- This module processes data for [[Module:IPAc-en]]. It is intended to be
-- loaded with mw.loadData.

localPRONUNCIATION_MODULE='Module:IPAc-en/pronunciation'
localPHONEME_MODULE='Module:IPAc-en/phonemes'

localfunctionmakeData(oldData)
localnewData={}
fori,oldinipairs(oldData)do
localnew={}
fork,vinpairs(old)do
ifk~='aliases'andk~='code'then
new[k]=v
end
end
newData[old.code]=new
ifold.aliasesthen
fori,aliasinipairs(old.aliases)do
newData[alias]=new
end
end
end
returnnewData
end

localfunctionmain()
localpronunciation=makeData(require(PRONUNCIATION_MODULE))
localphonemes=makeData(require(PHONEME_MODULE))

-- Check that no pronunciation keys are also contained in the phonemes
-- data. This would cause silent, hard-to-debug errors if it went
-- unchecked, so make it cause a big red error message instead.
foridinpairs(pronunciation)do
ifphonemes[id]then
error(string.format(
"duplicate ID '%s' found in %s and %s",
id,
PRONUNCIATION_MODULE,
PHONEME_MODULE
))
end
end

return{
pronunciation=pronunciation,
phonemes=phonemes,
}
end

returnmain()