词条 | Module:WikidataCheck/sandbox |
释义 | local p = {} function p._wikidatacheck( config ) local property = config.property local value = config.value or "" local catbase = config.category local namespaces = config.namespaces local ok = false -- one-way flag to check if we're in a good namespace local ns = mw.title.getCurrentTitle().namespace for v in mw.text.gsplit( namespaces, ",", true ) do if tonumber( v ) == ns then ok = true end end if not ok then -- not in one of the approved namespaces return "" end local qid = mw.wikibase.getEntityIdForCurrentPage() if not qid then -- no Wikidata item return "" end local statements = mw.wikibase.getBestStatements( qid, property ) if not statements then -- no claim of that property return "" -- bad. Bot needs to add the property end if value == "" then return nil -- Using Wikidata end for _, statement in ipairs( statements ) do -- Now we try to iterate over all possible values? propValue = statement.mainsnak.datavalue.value if propValue == value then return "" -- yay! end end end function p.wikidatacheck( frame ) end return p 4 : " .. catbase .. " not in Wikidata|" .. catbase .. " not in Wikidata|" .. catbase .. " same as Wikidata|" .. catbase .. " different from Wikidata |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。