Hello all,

We started integrating the constraint violations into the Query Service. That means you can build queries using the constraint violations, with the predicate wikibase:hasViolationForConstraint. This will hopefully help you to watch better the quality of Wikidata content.

Please note that this is a first step. Not all constraint violations are exposed yet, only the ones that can be checked fast enough. We're working on having more available in WDQS.

You can base your queries on these few examples:

#10 statements with constraint violations that are currently included
?x wikibase:hasViolationForConstraint ?y.
} LIMIT 10

Try it!

#Map/timeline/image grid of items that have a statement with a constraint violation
SELECT DISTINCT ?item ?itemLabel ?image ?coordinate_location ?point_in_time ?date_of_birth WHERE {
  ?s wikibase:hasViolationForConstraint ?y.
  ?item ?z1 ?s.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P625 ?coordinate_location. }
  OPTIONAL { ?item wdt:P585 ?point_in_time. }
  OPTIONAL { ?item wdt:P569 ?date_of_birth. }

Try it!

#Bar chart of statements that have a constraint violation, grouped by instance of the regarding item:
#TEMPLATE={ "template": { "en": "Bar chart of statements that have a constraint violation grouped by ?property the regarding item" }, "variables": { "?property": { "query":"SELECT ?id  WHERE { VALUES ?id {  wd:P31 wd:P17 wd:P571 wd:P361 wd:P19 } }" } } }
SELECT ?instance_ofLabel (COUNT(?instance_ofLabel) AS ?count) WHERE {
  ?s wikibase:hasViolationForConstraint ?y.
  ?item ?z1 ?s.
  BIND(wdt:P31 AS ?property)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item ?property ?instance_of. }
GROUP BY ?instance_ofLabel

Try it!

The modules included on the property talk pages, Module:Constraints, Module:Constraints/SPARQL etc. has been updated with a new query link (thanks Matěj!)

See also:

If you have any question, feel free to ping me.

Léa Lacroix
Project Manager Community Communication for Wikidata

Wikimedia Deutschland e.V.
Tempelhofer Ufer 23-24
10963 Berlin

Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e. V.

Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter der Nummer 23855 Nz. Als gemeinnützig anerkannt durch das Finanzamt für Körperschaften I Berlin, Steuernummer 27/029/42207.