Module:IPA symbol/overview explained

local data = mw.loadData('Module:IPA symbol/data')local univPatterns, keyPatterns = data.data.univPatterns, data.data.keyPatternsdata = data.rawData

local p =

function p.main(frame) local ret = local count, sCount =, -- Error detection do local symbols, dupes, invChars =,, local function checkSubs(t, s, name) for _, v in ipairs(t) do local matched = mw.ustring.match(s, v.pat) if matched then table.insert(invChars,) end end end local function check(s, checkKeyPats) sCount[s] = 0 for i, v in ipairs(data[s]) do for _, symbol in ipairs(v.symbols) do if symbols[symbol] then table.insert(dupes, symbol) else symbols[symbol] = true end checkSubs(univPatterns, symbol, v.name) if checkKeyPats then checkSubs(keyPatterns, symbol, v.name) end sCount[s] = sCount[s] + 1 end count[s] = i end end check('sounds', true) check('diacritics') if dupes[1] or invChars[1] then for _, v in ipairs(dupes) do table.insert(ret, string.format('*Error: "

%s" is defined more than once.\n', mw.text.nowiki(v))) end for _, v in ipairs(invChars) do table.insert(ret, string.format('*Error: A symbol for "%s" uses "%s", which will be replaced by "%s".\n', v[1], mw.text.nowiki(v[2]), mw.text.nowiki(v[3]))) end else table.insert(ret, 'No errors were found. ') end end table.insert(ret, string.format('%s entries (%s in "sounds", %s in "diacritics"), %s symbols (%s in "sounds", %s in "diacritics").\n\n', count.sounds + count.diacritics, count.sounds, count.diacritics, sCount.sounds + sCount.diacritics, sCount.sounds, sCount.diacritics)) table.insert(ret, 'Parentheses denote a link automatically inherited from the name field. In italics are redirects.\n') -- Table table.insert(ret, '
NameSymbolsArticleAudioGroup\n') local function renderRows(s) for _, v in ipairs(data[s]) do local parenL = v.article and or '(' local parenR = v.article and or ')' local article = v.article or v.name local symbols = for j, w in ipairs(v.symbols) do symbols[j] = mw.text.nowiki(w) end local audio = if v.audio then if frame.args.check_wikidata

'yes' then local rt = mw.title.new(article).redirectTarget rt = rt and rt.text or article local qId = mw.wikibase.getEntityIdForTitle(rt) local wdAudio = qId and mw.wikibase.getEntity(qId).claims wdAudio = wdAudio and wdAudio['P51'] if wdAudio then wdAudio = wdAudio[1].mainsnak.datavalue.value audio = wdAudio and wdAudio ~= v.audio and ' (≠ Wikidata)' or elseif qId then audio = ' (not on Wikidata)' end end audio = frame:expandTemplate .. audio end table.insert(ret, string.format('

-\n%s%s%s%s%s%s\n', v.name, table.concat(symbols, ' , '), parenL, article, parenR, audio, s)) end end renderRows('sounds') renderRows('diacritics') table.insert(ret, '
') return table.concat(ret)end

return p