Difference between revisions of "Module:IPAc-en/data"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (use ordered data for easier doc generation - will switch to main data modules momentarily) |
m (7 revisions imported) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
-- loaded with mw.loadData. | -- loaded with mw.loadData. | ||
| − | local PRONUNCIATION_MODULE = 'Module:IPAc-en/pronunciation | + | local PRONUNCIATION_MODULE = 'Module:IPAc-en/pronunciation' |
| − | local PHONEME_MODULE = 'Module:IPAc-en/phonemes | + | local PHONEME_MODULE = 'Module:IPAc-en/phonemes' |
local function makeData(oldData) | local function makeData(oldData) | ||
Latest revision as of 17:14, 26 September 2020
| 40x40px | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
-- 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()