Script errors

edit

This module has placed several pages in Category:Pages with script errors. Please fix it. Dragons flight (talk) 07:22, 20 May 2013 (UTC)Reply

  Fixed And next time, please see if the error is simple enough to fix yourself. -happy5214 08:04, 20 May 2013 (UTC)Reply

change mw.wikibase.getEntitiy (deprecated) to mw.wikibase.getEntityObject

edit

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

  Not done: please make your requested changes to the module's sandbox first; see WP:TESTCASES. — {{U|Technical 13}} (etc) 15:55, 2 March 2015 (UTC)Reply
I did. Please check Module:WikidataCheck/sandbox. mw.wikibase.getEntity() will be changed in a not backwards compatible way in two weeks, so it would be great to implement the changes before that. --Lucie Kaffee (WMDE) (talk) 15:06, 24 March 2015 (UTC)Reply
  Done. Also Lucie Kaffee (WMDE), if you make 1 more edit anywhere on en.wiki you'll be able to edit semi-protected pages. Stickee (talk) 00:26, 25 March 2015 (UTC)Reply

Tracking categories

edit
Tracking categories currently work like this:
Local param Wikidata property Tracking cat
exists missing Not in Wikidata
missing exists Different
exists exists and different Different
exists exists and same Same

...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

Ping @Happy5214: any opinion on the above? GregorB (talk) 15:32, 15 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

Somevalue/novalue

edit

@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

Loop over all property values

edit

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

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

  Done --Canley (talk) 11:40, 20 June 2017 (UTC)Reply
Thanks very much. --99of9 (talk) 13:18, 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 claims[property] from an entity object. 50.53.1.21 (talk) 00:40, 13 January 2018 (UTC)Reply
Another thing to consider is whether page cache entry should get purged when the linked Wikidata entry is updated (some related discussion at Template talk:Authority control/Archive 6#Technical improvement). Currently the code uses getEntityObject which binds Wikidata entry updates to the linked page caching. Since this code only attempts to check data, I believe we should avoid such (presumably the same Wikidata values will get used elsewhere in the template/module code and that probably in general should bind such changes) by using getBestStatements or getAllStatements (with getEntityIdForCurrentPage) over entity:getBestStatements, entity:getAllStatements or entity.claims (with getEntity or getEntityObject). 50.53.1.21 (talk) 00:40, 13 January 2018 (UTC)Reply
I addressed the above issues in the sandbox, however, I have not done any real testing of the changes. 50.53.1.21 (talk) 07:10, 13 January 2018 (UTC)Reply

Thank you for your work but please do test it before using {{edit template-protected}}. User:Happy5214: would you like to review these changes? — Martin (MSGJ · talk) 09:37, 15 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. -happy5214 04:59, 17 January 2018 (UTC)Reply
@MSGJ, Happy5214, and 99of9: Sadly there is no real good way for me to test this. It almost requires me to submit another {{edit template-protected}} (or similar) to an existing template using this template/module to test it (and another to revert it back when the testing is complete). 99of9 (talk · contribs) did something similar in Special:Diff/786559931 and Special:Diff/786560495 (see above comments). If you have a better way to test such, I am all ears. 50.53.1.21 (talk) 19:28, 17 January 2018 (UTC)Reply

Stray right bracket

edit

Why is the invocation of this module HERE printing a stray ] character? wbm1058 (talk) 23:13, 20 July 2018 (UTC)Reply

@Wbm1058: It has nothing to do with this module. The reference to Category:People from Oakdale, California had an extra closing bracket. -happy5214 23:46, 20 July 2018 (UTC)Reply
  Facepalm thanks! stuff like that isn't easy to spot! wbm1058 (talk) 23:49, 20 July 2018 (UTC)Reply

Add catsort option

edit

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

edit

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

  Added — Martin (MSGJ · talk) 12:57, 18 June 2021 (UTC)Reply

New functionality

edit

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.

Does this look useful to add here? — Martin (MSGJ · talk) 09:54, 24 September 2021 (UTC)Reply

Case-sensitivity and other stylistic differences

edit

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

LydiaPintscher (talk) 15:03, 7 September 2023 (UTC)Reply

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
The module already has an option to ignore case, which I added in July. It was implemented in Template:Twitter and others; a full list may be found here. -- Zyxw (talk) 06:46, 1 December 2023 (UTC)Reply

Checking sourced properties only?

edit

I recently added {{WikidataCheck}} to {{Infobox network service provider}}, which uses {{wdib}} (with |osd=yes) rather than {{#property}} in order to comply with a 2018 RFC requiring Wikidata-imported infobox data to be sourced. {{WikidataCheck}} seems to be checking against *all* Wikidata properties, not just sourced ones. Is there any appetite for adding a source check similar to Module:WikidataIB's?

-------------------------------------------------------------------------------
-- 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
-------------------------------------------------------------------------------
local sourced = function(claim)
	if claim.references then
		for kr, vr in pairs(claim.references) do
			local ref = mw.wikibase.renderSnaks(vr.snaks)
			if not ref:find("Wiki") then
				return true
			end
		end
	end
end

DefaultFree (talk) 22:08, 20 November 2023 (UTC)Reply

Proposal:
collapsed original diff
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 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! DefaultFree (talk) 03:06, 29 November 2023 (UTC)Reply

  Done * Pppery * it has begun... 01:21, 30 November 2023 (UTC)Reply
@DefaultFree and Pppery: This change is populating many of the subcategories of Category:Wikipedia categories tracking Wikidata differences. For an example, see the article for Robert Conrad which is now in Category:The Interviews name ID different from Wikidata, even though both {{The Interviews name}} and Television Academy Foundation interviewee ID (P5773) contain the same ID. This appears to be occurring with all unsourced properties. I think the update to Module:WikidataCheck should be reverted until this can be fixed in Module:WikidataCheck/sandbox. -- Zyxw (talk) 10:26, 30 November 2023 (UTC)Reply
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
Thanks. I tested your change in Module:WikidataCheck/sandbox with four different templates and it appears to solve the problem, so I am going to add it in Module:WikidataCheck. -- Zyxw (talk) 11:25, 30 November 2023 (UTC)Reply