Module talk:Constraints

From Wikidata
Jump to navigation Jump to search

Current problems[edit]

  • Missing SPARQL queries.
  • I18n: translators are bound to the order of parameters which can make translations unreliable. We should use $1 etc. instead of %s.

Matěj Suchánek (talk) 16:54, 13 July 2017 (UTC)[reply]


This currently generates an error on Property talk:P5086. I couldn't find a recent diff changing anything though. Maybe the format on P5086 is wrong.
--- Jura 07:49, 22 May 2018 (UTC)[reply]

✓ Fixed Matěj Suchánek (talk) 15:01, 22 May 2018 (UTC)[reply]

Problem in range constraint processing (can't process 0 or 1 as boundary)[edit]

I found problem in range constraint processing. I want to set range [1, ∞) at chromosome count (P5230) like w:en:List of organisms by chromosome count. Chromosome count is 1, 2, ... 100 or more. But 1 is automatically interpreted as no value by this module because the following codes and shown like so at Property_talk:P5230.

local cSomevalue           = 0
local cNovalue             = 1
	elseif (type == cRange) then
		local min = getOneOfQualifiers(constraint, pMinQuantity, pMinDate)
		if min == cNovalue then
			min = "−∞"
		end
		if min == cSomevalue then
			min = i18n("now")

The same phenomenon is happening at atomic number (P1086). The range [0, 155] is automatically interpreted as Range from “now” to “155”. Solution?--Was a bee (talk) 04:47, 9 June 2018 (UTC)[reply]

To change the constants. Hopefully, this will not cause any problems. Matěj Suchánek (talk) 09:07, 9 June 2018 (UTC)[reply]
Thank you very much. It works nicely. --Was a bee (talk) 10:50, 9 June 2018 (UTC)[reply]

Date regexp constraint[edit]

As date is stored as string (although not recognized this way) - we can change how the module handles format constraint (Q21502404) on line number 116 local cFormatapplicable = {"math","commonsMedia","string","external-id","url","monolingualtext","tabular-data","geo-shape","musical-notation"} on local cFormatapplicable = {"math","commonsMedia","string","external-id","url","monolingualtext","tabular-data","geo-shape","musical-notation","time"}

See d:Wikidata:Project_chat#Zero_date_year and Sandbox-TimeValue (P578)property constraint (P2302)format constraint (Q21502404)format as a regular expression (P1793)(?!\+0000)[+-]\d{4}-[01]\d-[0123]\dT00:00:00Z Carn (talk) 10:22, 27 May 2020 (UTC)[reply]

Module:Constraints:685: attempt to index field 'P18' (a nil value)[edit]

Hello, on all talk pages of properties that use lexeme requires language constraint (Q55819106), one can see this error "Module:Constraints:685: attempt to index field 'P18' (a nil value)" See for example Property_talk:P5978. Is it possible to fix the module so that no error appears when no image is present? Pamputt (talk) 20:58, 15 March 2021 (UTC)[reply]

@Pamputt: looks fixed? Is this still the case? Multichill (talk) 16:53, 12 March 2022 (UTC)[reply]
Yes, this is fixed. Thank you. Pamputt (talk) 01:21, 13 March 2022 (UTC)[reply]

I tried to add support for the new constraint type (cLabelLanguage), but didn't quite manage to get everything done. It needs to recognize the qualifier Wikimedia language code (P424) (pLanguageCode). At some point I got to "function at line .. has more than 60 upvalues". If you have time to figure it out or at least make that it doesn't display an error message, that would be helpful. --- Jura 13:35, 21 September 2021 (UTC)[reply]

This fixes it. I'll see if I can replace all those locals with a table. Multichill (talk) 15:58, 12 March 2022 (UTC)[reply]
✓ Done @Jura1: this should fix it. Multichill (talk) 16:52, 12 March 2022 (UTC)[reply]
I see that the constraint allows multiple qualifiers. I have to update the code a bit for that.
@Jura1: can complex constraint label language (Q102746314) now be replaced with label in language constraint (Q108139345)?
I also started the same logic for description in language constraint (Q111204896) and filed phab:T303670. Multichill (talk) 18:47, 12 March 2022 (UTC)[reply]
@Tacsipacsi: ^ Multichill (talk) 22:05, 14 March 2022 (UTC)[reply]
As I noted at Help talk:Property constraints portal#Outdated help page on label language constraint, KrBot2 doesn’t support it, so it cannot be totally replaced, the complex constraint violations should be kept and adjusted (but adjusting is possible) in order to have the best of both worlds until the bot supports the new constraint. Maybe User:Ivan A. Krestinin can tell us for when the bot support can be expected. —Tacsipacsi (talk) 01:20, 15 March 2022 (UTC)[reply]

Single value and separator[edit]

Hi! Apparently, if a property X has a single-value constraint (Q19474404) qualified with separator (P4155) and an item Y has two or more values of the property X with the qualifiers listed in P4155, the item Y appears (wrongly) in the query for single-value violations, because the query doesn't take into account P4155. Could the query be edited in order to take into account P4155? Thanks! --Epìdosis 21:20, 9 March 2022 (UTC)[reply]

Type constraint with relation instance or subclass of(30208840)[edit]

Currently, the regular expressions for checking violations of subject type constraint (Q21503250)relation (P2309)instance of (Q21503252) and subject type constraint (Q21503250)relation (P2309)instance or subclass of (Q30208840) are identical. Cf. for instance Property talk:P12399 vs Property talk:P12391.

Anyway, instance of (Q21503252) and instance or subclass of (Q30208840) have different meanings, namely:

For what I can understand, the module currently interprets both of them according to the first meaning. In fact, in case relation == cInstanceOfSubclassOf the return value is pInstanceOf,pSubclassOf and, for what I can understand, pSubclassOf is then ignored. Also, the Lua variable is named cInstanceOfSubclassOf instead of cInstanceOrSubclassOf (which is another clue).

I think that the regex associated to instance or subclass of (Q30208840) returned by SPARQL.buildType() should have (wdt:P31)?/wdt:P279* instead of wdt:P31/wdt:P279*. Horcrux (talk) 12:08, 2 February 2024 (UTC)[reply]

✓ Done, check out [1] and [2]. --Horcrux (talk) 17:32, 14 April 2024 (UTC)[reply]