Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Nardog/8d
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local data = mw.loadData('Module:Sandbox/Nardog/8t') local univPatterns, keyPatterns = data.data.univPatterns, data.data.keyPatterns data = data.rawData local p = {} local match = mw.ustring.match local nowiki = mw.text.nowiki function p.main() local ret, count, sCount = {}, {}, {} -- Error detection do local symbols, dupes, invChars = {}, {}, {} local function checkSubs(t, s, name) for _, v in ipairs(t) do local matched = match(s, v.pat) if matched then table.insert(invChars, { name, matched, v.rep }) 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: "<span class="IPA">%s</span>" is defined more than once.\n', nowiki(v))) end for _, v in ipairs(invChars) do table.insert(ret, string.format( '*Error: A symbol for "%s" uses "<span class="IPA">%s</span>", which will be replaced by "<span class="IPA">%s</span>".\n', v[1], nowiki(v[2]), 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, '{| class="wikitable sortable"\n!Name!!Symbols!!Article!!Audio!!Group\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] = nowiki(w) end local obj = mw.title.new(article) local italics = obj.isRedirect and "''" or '' local audio = v.audio and string.format( '[[:File:%s|%s]] <small>([[Media:%s|play]])</small>', v.audio, v.audio, v.audio) or '' table.insert(ret, string.format( '|-\n|%s||class="IPA"|%s||%s%s[[%s]]%s%s||%s||%s\n', v.name, table.concat(symbols, ' , '), parenL, italics, article, italics, parenR, audio, s)) end end renderRows('sounds') renderRows('diacritics') table.insert(ret, '|}') return table.concat(ret) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Nardog/8d/doc
(
edit
)