请输入您要查询的百科知识:

 

词条 Module:Sandbox/Tom.Reding/sandbox
释义

local p = {}

p.conf = {

[ 'ACM-DL'] = { 'ACM DL', 864, p.acmLink },

[ 'autores.uy'] = { 'autores.uy', 2558, p.autoresuyLink },

[ 'BALaT'] = { 'BALaT', 3293, p.balatLink },

[ 'BIBSYS'] = { 'BIBSYS', 1015, p.bibsysLink },

[ 'Bildindex'] = { 'Bildindex', 2092, p.bildLink },

[ 'BNE'] = { 'BNE', 950, p.bneLink },

[ 'BNF'] = { 'BNF', 268, p.bnfLink },

[ 'Botanist'] = { 'Botanist', 428, p.botanistLink },

[ 'BPN'] = { 'BPN', 651, p.bpnLink },

[ 'CINII'] = { 'CiNii', 271, p.ciniiLink },

[ 'DBLP'] = { 'DBLP', 2456, p.dblpLink },

[ 'DSI'] = { 'DSI', 2349, p.dsiLink },

[ 'GND'] = { 'GND', 227, p.gndLink },

[ 'HDS'] = { 'HDS', 902, p.hdsLink },

[ 'IAAF'] = { 'IAAF', 1146, p.iaafLink },

[ 'ICIA'] = { 'ICIA', 1736, p.iciaLink },

[ 'ISNI'] = { 'ISNI', 213, p.isniLink },

[ 'Joconde'] = { 'Joconde' , 347, p.jocondeLink },

[ 'KULTURNAV'] = { 'KulturNav', 1248, p.kulturnavLink },

[ 'LCCN'] = { 'LCCN', 244, p.lccnLink },

[ 'LIR'] = { 'LIR', 886, p.lirLink },

[ 'LNB'] = { 'LNB', 1368, p.lnbLink },

[ 'Léonore'] = { 'Léonore', 640, p.leonoreLink },

[ 'MBA'] = { 'MusicBrainz', 434, p.mbaLink, category = 'MusicBrainz' },

[ 'MBAREA'] = { 'MusicBrainz', 982, p.mbareaLink, category = 'MusicBrainz area' },

[ 'MBI'] = { 'MusicBrainz', 1330, p.mbiLink, category = 'MusicBrainz instrument' },

[ 'MBL'] = { 'MusicBrainz', 966, p.mblLink, category = 'MusicBrainz label' },

[ 'MBP'] = { 'MusicBrainz', 1004, p.mbpLink, category = 'MusicBrainz place' },

[ 'MBRG'] = { 'MusicBrainz release group', 436, p.mbrgLink, category = 'MusicBrainz release group' },

[ 'MBS'] = { 'MusicBrainz', 1407, p.mbsLink, category = 'MusicBrainz series' },

[ 'MBW'] = { 'MusicBrainz work', 435, p.mbwLink, category = 'MusicBrainz work' },

[ 'MGP'] = { 'MGP', 549, p.mgpLink },

[ 'NARA'] = { 'NARA', 1225, p.naraLink },

[ 'NCL'] = { 'NCL', 1048, p.nclLink },

[ 'NDL'] = { 'NDL', 349, p.ndlLink },

[ 'NKC'] = { 'NKC', 691, p.nkcLink },

[ 'NLA'] = { 'NLA', 409, p.nlaLink },

[ 'NSK'] = { 'NSK', 1375, p.nskLink },

[ 'ORCID'] = { 'ORCID', 496, p.orcidLink },

[ 'PIC'] = { 'PIC', 2750, p.picLink },

[ 'RID'] = { 'ResearcherID', 1053, p.ridLink },

[ 'RKDartists'] = { 'RKD', 650, p.rkdartistsLink },

[ 'RKDID'] = { 'RKDimages ID', 350, p.rkdidLink },

[ 'RSL'] = { 'RSL', 947, p.rslLink },

[ 'SBN'] = { 'ICCU', 396, p.sbnLink },

[ 'SELIBR'] = { 'SELIBR', 906, p.selibrLink },

[ 'SIKART'] = { 'SIKART', 781, p.sikartLink },

[ 'SNAC-ID'] = { 'SNAC', 3430, p.snacLink },

[ 'SUDOC'] = { 'SUDOC', 269, p.sudocLink },

[ 'S2AuthorId' ] = { 'S2AuthorId', 4012, p.s2authoridLink, category = 'Semantic Scholar author' },

[ 'TA98'] = { 'TA98', 1323, p.ta98Link },

[ 'TE'] = { 'TE', 1693, p.teLink },

[ 'TH'] = { 'TH', 1694, p.thLink },

[ 'TLS'] = { 'TLS', 1362, p.tlsLink },

[ 'ULAN'] = { 'ULAN', 245, p.ulanLink },

[ 'USCongress'] = { 'US Congress', 1157, p.uscongressLink },

[ 'VIAF'] = { 'VIAF', 214, p.viafLink },

}

function p.getCatForId( id )

local title = mw.title.getCurrentTitle()

local namespace = title.namespace

local catName =

local idcat = p.conf[id].category

if namespace == 0 then

catName = 'Wikipedia articles with ' .. idcat .. ' identifiers'

elseif namespace == 2 and not title.isSubpage then

catName = 'User pages with ' .. idcat .. ' identifiers'

else

catName = 'Miscellaneous pages with ' .. idcat .. ' identifiers'

end

return 'Category:' .. catName .. ''

end

function spairs(t)

    -- collect the keys    local keys = {}    for k in pairs(t) do keys[#keys+1] = k end

    -- return the iterator function    local i = 0    return function()        i = i + 1        if keys[i] then            return keys[i], t[keys[i]]        end    end

end

function p.docConfTable( frame )

local wikiTable = '{| class="wikitable sortable"\' ..

'! rowspan=2 | Parameter\' ..

'! rowspan=2 | Label\' ..

'! rowspan=2; data-sort-type=number | Wikidata property\' ..

'! colspan=4 | Tracking categories and page counts\' ..

'|-\' ..

'! Articles\' ..

'! User pages\' ..

'! Misc. pages\' ..

'! Faulty IDs\' ..

'|-\'

local lang = mw.getContentLanguage()

local wikitable2 =

for param, paramData in spairs( p.conf ) do

local link, pid, category = paramData[1], paramData[2], paramData.category or param

wikitable2 = wikitable2 .. '\' .. link .. '+' .. pid .. '+' .. category

-- local args = { id = 'f', pid }-- local wpl = frame:expandTemplate{ title = 'Wikidata property link', args = args }-- --cats-- local articleCat = 'Wikipedia articles with '..category..' identifiers'-- local userCat = 'User pages with '..category..' identifiers'-- local miscCat = 'Miscellaneous pages with '..category..' identifiers'-- local faultyCat = 'Wikipedia articles with faulty '..category..' identifiers'-- --counts-- local articleCount = lang:formatNum( mw.site.stats.pagesInCategory(articleCat, 'pages') )-- local userCount = lang:formatNum( mw.site.stats.pagesInCategory(userCat, 'pages') )-- local miscCount = lang:formatNum( mw.site.stats.pagesInCategory(miscCat, 'pages') )-- local faultyCount = lang:formatNum( mw.site.stats.pagesInCategory(faultyCat, 'pages') )-- --concat-- wikiTable = wikiTable..'\'..-- '|-\'..-- '||'..param..-- '||'..link..-- '||data-sort-value='..pid..'|'..wpl..-- '||style="text-align: right;"|'..articleCount..''..-- '||style="text-align: right;"|'.. userCount..''..-- '||style="text-align: right;"|'.. miscCount..''..-- '||style="text-align: right;"|'.. faultyCount..''-- end-- return wikiTable .. '\|}'
   end   return wikitable2

end


function p.conftest(frame)

return p.getCatForId( 'S2AuthorId' )

end

function p.test(frame)

local parentArg = mw.text.trim(frame.args[1])

-- parentArg = mw.ustring.gsub(parentArg, 'venomou$', 'venomous') --trying to combine this-- parentArg = mw.ustring.gsub(parentArg, 'venomou([^s])', 'venomous%1') --and this into 1 rule-- parentArg = mw.ustring.gsub(parentArg, 'venomou([$^s])', 'venomous%1') --doesn't work at all-- parentArg = mw.ustring.gsub(parentArg, 'venomou(%f[\\0])', 'venomous%1') --eol only-- parentArg = mw.ustring.gsub(parentArg, 'venomou(%f[\\0^s])', 'venomous%1') --eol only

--parentArg = mw.ustring.gsub(parentArg, 'venomou(%f[\\0 ])', 'venomous%1') --eol or space

-- parentArg = mw.ustring.gsub(parentArg, 'venomou(%f[^s])', 'venomous%1') --doesn't work at all

return parentArg

end

function p.test2(frame)

local test = frame.args[1] or frame.args[2]

if test == nil then return 'nil'

elseif test == then return 'null'

else return test end

--results:

-- blah1, blah2 => blah1

-- blah1, nil => blah1

-- nil, blah2 => blah2

-- null, blah2 => null

-- nil, nil => nil

end

function p.l(frame)

local a = '1'

local b = '12'

return #a..' '..#b --result: 1 2

end

function p.m(frame)

local regex = '^E([1-8])%.(%d%d?)%.%d%d?%.%d%d?%.%d%.%d%.%d%d?%d?$'

local m, n = string.match('E1.23.45.67.8.9.0', regex)

return m..n

end

function p.getD(frame)

local d = mw.wikibase.getDescription('Q200352')

if d == nil then return 'nil'

elseif d == then return 'null'

else return 'idk'

end

end

function p.navyear(frame)

--Expects a PAGENAME of the form "Some sequential 2015 example cat", where {{{1}}}=Some sequential, {{{2}}}=2015, {{{3}}}=example cat,

--and an optional 'minumum year' {{{4}}}=1758

local arg1 = frame.args[1]

local arg2 = tonumber(frame.args[2])

local arg3 = frame.args[3]

return '{| class="toccolours hlist" style="text-align: center; margin: auto;"\' ..

'|\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2-5)..' '..arg3, (arg2-5) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2-4)..' '..arg3, (arg2-4) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2-3)..' '..arg3, (arg2-3) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2-2)..' '..arg3, (arg2-2) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2-1)..' '..arg3, (arg2-1) } }..'\' ..

'*'..arg2..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2+1)..' '..arg3, (arg2+1) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2+2)..' '..arg3, (arg2+2) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2+3)..' '..arg3, (arg2+3) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2+4)..' '..arg3, (arg2+4) } }..'\' ..

'*'..frame:expandTemplate{ title = 'LinkCatIfExists2', args = { arg1..' '..(arg2+5)..' '..arg3, (arg2+5) } }..'\' ..

'|}'

end

function p.expensivePtest(frame)

local var1 = mw.wikibase.getEntity('P864')

local var2 = mw.wikibase.getEntity('P2558')

return ' end '

end

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 0:43:12