This template is within the scope of WikiProject Wikidata, a collaborative effort to improve Wikipedia's integration with
Wikidata. If you would like to participate, please visit the
project page.WikidataWikipedia:WikiProject WikidataTemplate:WikiProject WikidataWikidata articles
This
edit request to
Module:WikidataCheck has been answered. Set the |answered= or |ans= parameter to no to reactivate your request.
I am trying to change all important modules using mw.wikibase.getEntity() which is deprecated to mw.wikibase.getEntityObject(). You can find more details here
[1]. If you could change it on this module, that would be great!
Thank you a lot! --
Lucie Kaffee (WMDE) (
talk) 13:33, 2 March 2015 (UTC)
Lucie Kaffee (WMDE) (
talk)
13:33, 2 March 2015 (UTC)reply
...but row #2 is not (necessarily?) right: missing local param is a normal thing, this means that the value has been migrated to Wikidata, and no human review is needed (unlike row #3). If, on the other hand, one attempts to work around this by falling back to Wikidata property if local param is missing - like MusicBrainz templates do - then #2 becomes #4, which is again not right - the values are not really the "same", there is e.g. no need to delete the local param as redundant. I'd argue that in case #2 no tracking needs to be done. I believe this would make sense both for MusicBrainz and {{Official website}} (I'd like to use WikidataCheck in the latter).
GregorB (
talk)
11:59, 1 April 2015 (UTC)reply
I have implemented this. Better late than never, I guess. A missing local value is no longer categorized as different. —
JJMC89 (
T·C)
05:13, 1 October 2016 (UTC)reply
@
Happy5214: the code should be upgraded for somevalue/novalue. That is, if the property is set to 'novalue' or 'somevalue', then currently error is shown. You can take a look at
sandbox: "Lua error in Module:WikidataCheck at line 31: attempt to index field 'datavalue' (a nil value).", and the value is set
here (currently the last one - IMDb identifier). Code sample is also in
coordinates module at makeWikidataCategories. --Edgars2007 (
talk/
contribs)
16:40, 11 December 2015 (UTC)reply
I'd really appreciate if the code comment "This should eventually iterate over all possible values?" was implemented. I guess I'll eventually learn LUA if I have to, but if an expert is already able and willing, you'd have my gratitude. --
99of9 (
talk)
04:48, 20 June 2017 (UTC)reply
This
edit request to
Module:WikidataCheck has been answered. Set the |answered= or |ans= parameter to no to reactivate your request.
I have figured out how to do the above request, and implemented it in the
Module:WikidataCheck/sandbox. If it looks ok, please copy the sandbox code into the main template. I have tested this by running the sandbox code
here, and the examples I tried seemed to work, so I have now reverted that to use the main module. --
99of9 (
talk)
06:46, 20 June 2017 (UTC)reply
There is an issue with:
Special:Diff/786592438. Previously, if value was empty, pages would be categorized into a "not in Wikidata" category if there was no Wikidata for the page or if the linked Wikidata did not not have any claims matching property. With the change, the check for an empty value was moved up and pages with linked Wikidata but without claims matching property are no longer categorized into a "not in Wikidata" category (though it still does properly categorize when there is no linked Wikidata at all).
50.53.1.21 (
talk)
00:40, 13 January 2018 (UTC)reply
Instead of filtering claims to match against value by just property, we should probably also filter by claims by rank as it probably does not make much sense to compare value to deprecated claims. The easiest way to do this is by using getBestStatements with property instead of directly accessing claimsproperty from an entity object.
50.53.1.21 (
talk)
00:40, 13 January 2018 (UTC)reply
I no longer maintain this module. I'm probably of no help here. If you still need someone to look over it by this weekend, ping me again and I'll try to look at it. -
happy521404:59, 17 January 2018 (UTC)reply
Is it possible to add a catsort option (say parameter |catsort=) that, when having input, adds the catsort value? Sometimes I use maintenance categories this way: "when situation is A, catsort under pagename, when situation is B, catsort under '*'". This way the category is dispersing softly. It also can be worked on for example to make the '*' subsort empty. -
DePiep (
talk)
13:47, 29 January 2017 (UTC)reply
Custom qid
I've got a version in the sandbox which accepts |qid= for arbitrary access to other Wikidata items. Seems to be working but I will test further. — Martin (
MSGJ ·
talk)
17:52, 17 June 2021 (UTC)reply
I'm not sure if anyone is maintaining this module, but I wanted to suggest that some extra functionality is added. I have coded this in
Template:Wikidata alignment but it would be better added to this module I think.
It shows visually (hidden by default) using 4 different icons (), the comparison between the local value and Wikidata value. I've copied my example from the documentation page below.
This screenshot shows four fields in an infobox.
The NGA number is defined locally but missing from Wikidata. A link to import this value via
QuickStatements is provided.
The admiralty number is not defined locally, so the Wikidata value is used by default.
The ARLHS number stored on Wikidata is slightly different to the local value. The Wikidata value is displayed in red alongside.
The USCG number defined locally matches the local parameter.
Thank you for building this module. It's a great help for comparing Wikidata and English Wikipedia data to find issues. @
Mike Peel is using the results to feed the Mismatch Finder, which is a tool for easier reviewing of mismatches between Wikidata and other data sources. When reviewing mismatches in the Mismatch Finder I am coming across quite a few differences that I think are not really issues that should be flagged. I was wondering if the module could be amended to ignore some of those differences. You can try it yourself by going to
https://mismatch-finder.toolforge.org and clicking the "random mismatches" button to see a few of the things that come up.
Here are some example of things that I think should not be flagged as different:
Twitter user name that only differs in capitalization
IMDB ID where Wikidata has a convention of keeping the "tt" in the identifier and enwp doesn't
Open Library ID where Wikidata keeps the "OL" in the identifier but enwp doesn't
This is similar to what I was using in
Template:Wikidata alignment with the "equivalent" parameter. I think the functionality could be merged into this template if it looks okay. Johnuniq did express reservations on the talk page though — Martin (
MSGJ ·
talk)
16:01, 7 September 2023 (UTC)reply
--------------------------------------------------------------------------------- sourced takes a table representing a statement that may or may not have references-- it looks for a reference sourced to something not containing the word "wikipedia"-- it returns a boolean = true if it finds a sourced reference.--------------------------------------------------------------------------------- Dependencies: none-------------------------------------------------------------------------------localsourced=function(claim)ifclaim.referencesthenforkr,vrinpairs(claim.references)dolocalref=mw.wikibase.renderSnaks(vr.snaks)ifnotref:find("Wiki")thenreturntrueendendendend
function p.wikidatacheck(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
local property = config.property
local value = config.value or ""
local catbase = config.category
local namespaces = config.namespaces
local nocatsame = config.nocatsame or ""
local ignorecase = config.ignorecase or ""
local qid = config.qid or ""
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 entity
if qid == "" then
entity = mw.wikibase.getEntityObject()
else
entity = mw.wikibase.getEntityObject(qid)
end
if not entity then -- no Wikidata item
return "[[Category:" .. catbase .. " not in Wikidata]]"
end
if value == "" then
return nil -- Using Wikidata
end
local claims = entity.claims or {}
local hasProp = claims[property]
if not hasProp then -- no claim of that property
return "[[Category:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property
end
if ignorecase ~= "" then
value = string.lower( value )
end
for i, v in ipairs(hasProp) do -- Now we try to iterate over all possible values?
propValue = (v.mainsnak.datavalue or {}).value
if ignorecase ~= "" then
propValue = string.lower( propValue )
end
if propValue == value then
if nocatsame == "" then
return "[[Category:" .. catbase .. " same as Wikidata]]" -- yay!
else
return nil -- if nocatsame, the "same as" category is not added
end
end
end
return "[[Category:" .. catbase .. " different from Wikidata]]" -- needs human review :(
end
return p
+
local p = {}
function p.wikidatacheck(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
local property = config.property
local value = config.value or ""
local catbase = config.category
local namespaces = config.namespaces
local nocatsame = config.nocatsame or ""
local ignorecase = config.ignorecase or ""
local qid = config.qid or ""
local onlysourced = config.onlysourced or false
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 entity
if qid == "" then
entity = mw.wikibase.getEntityObject()
else
entity = mw.wikibase.getEntityObject(qid)
end
if not entity then -- no Wikidata item
return "[[Category:" .. catbase .. " not in Wikidata]]"
end
if value == "" then
return nil -- Using Wikidata
end
local claims = entity.claims or {}
local hasProp = claims[property]
if not hasProp then -- no claim of that property
return "[[Category:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property
end
if ignorecase ~= "" then
value = string.lower( value )
end
for i, v in ipairs(hasProp) do -- Now we try to iterate over all possible values?
propValue = (v.mainsnak.datavalue or {}).value
if ignorecase ~= "" then
propValue = string.lower( propValue )
end
local sourced = false -- check for external refs a la Module:WikidataIB onlysourced
for j, vr in ipairs(v.references) do
local ref = mw.wikibase.renderSnaks(vr.snaks)
if not ref:find("Wiki") then
sourced = true
break
end
end
if propValue == value and (not onlysourced or sourced) then
if nocatsame == "" then
return "[[Category:" .. catbase .. " same as Wikidata]]" -- yay!
else
return nil -- if nocatsame, the "same as" category is not added
end
end
end
return "[[Category:" .. catbase .. " different from Wikidata]]" -- needs human review :(
end
return p
Caveat: not entirely sure how best to test this (there doesn't seem to be a /testcases subpage), and I haven't written MediaWiki-lua before, so bugs are not unlikely.
DefaultFree (
talk)
05:30, 21 November 2023 (UTC)reply
In the absence of any negative feedback, I've gone ahead and implemented this in the sandbox. To test, I switched {{Infobox network service provider}} from {{WikidataCheck}} to {{WikidataCheck/sandbox|onlysourced=yes}}, and it seems to have updated categorizations as expected - now the categories are much more actionable for making corrections to data.
Could someone review these diffs and apply them?
Thanks for pointing this out, and apologies for introducing a bug. It turns out Lua treats the empty string as truthy, causing this new logic to apply in all cases, not just when requested with |onlysourced=yes. I'm not able to edit the non-sandbox module, but I believe this should fix it: [2]DefaultFree (
talk)
10:37, 30 November 2023 (UTC)reply