মডিউল:IPAc-en/তথ্য

উইকিপিডিয়া, মুক্ত বিশ্বকোষ থেকে
পরিভ্রমণে ঝাঁপ দিন অনুসন্ধানে ঝাঁপ দিন

ব্যবহার[সম্পাদনা]

-- This module processes data for [[মডিউল:IPAc-en]]. It is intended to be
-- loaded with mw.loadData.

local PRONUNCIATION_MODULE = 'মডিউল:IPAc-en/উচ্চারণ'
local PHONEME_MODULE = 'মডিউল:IPAc-en/ফৌনীম'

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(
				"%s এবং %s মধ্যে '%s' অনুলিপি আইডি পাওয়া গিয়েছে",
				id,
				PRONUNCIATION_MODULE,
				PHONEME_MODULE
			))
		end
	end

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

return main()