Modul:IPAc-en/data: Unterschied zwischen den Versionen

Aus Kryptowiki - Die freie Enzyklopädie der Kryptowährungen
Wechseln zu: Navigation, Suche
(switch to main data modules)
 
K (1 Version importiert)
 
(kein Unterschied)

Aktuelle Version vom 20. Januar 2018, 14:52 Uhr

Die Dokumentation für dieses Modul kann unter Modul:IPAc-en/data/Doku erstellt werden

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

local PRONUNCIATION_MODULE = 'Module:IPAc-en/pronunciation'
local PHONEME_MODULE = 'Module:IPAc-en/phonemes'

local function makeData(oldData)
	local newData = {}
	for i, old in ipairs(oldData) do
		local new = {}
		for k, v in pairs(old) do
			if k ~= 'aliases' and k ~= 'code' then
				new[k] = v
			end
		end
		newData[old.code] = new
		if old.aliases then
			for i, alias in ipairs(old.aliases) do
				newData[alias] = new
			end			
		end
	end
	return newData
end

local function main()
	local pronunciation = makeData(require(PRONUNCIATION_MODULE))
	local phonemes = 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.
	for id in pairs(pronunciation) do
		if phonemes[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

return main()

Spenden-Adressen:
Bitcoin Icon BTC: 1EoecgUZnAjamUYaKstqwbremQqbucTaoZ
Ethereum Icon ETH: 0x0D2Ab63dfe70a7fA12f9d66eCfEA9dDc8F5173A8
XEM Icon XEM: NBZPMU-XES6ST-ITEBR3-IHAPTR-APGI3Y-RAAMHV-VZFJ
Verge Icon XVG: DGYmzxoe3ryK6MnsR13GqR9r1NThpxPcKs