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
includedSELECT * WHERE {?x wikibase:hasViolationForConstraint ?y.}
LIMIT 10
Try it!
https://query.wikidata.org/#%2310%20statements%20with%20constraint%20violations%20that%20are%20currently%20included%0ASELECT%20%2A%20WHERE%20%7B%0A%3Fx%20wikibase%3AhasViolationForConstraint%20%3Fy.%0A%7D%20LIMIT%2010
#Map/timeline/image grid of items that have a statement with a
constraint violation#defaultView:MapSELECT 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!
https://query.wikidata.org/#%23Map%2Ftimeline%2Fimage%20grid%20of%20items%20that%20have%20a%20statement%20with%20a%20constraint%20violation%0A%23defaultView%3AMap%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3Fimage%20%3Fcoordinate_location%20%3Fpoint_in_time%20%3Fdate_of_birth%20WHERE%20%7B%0A%20%20%3Fs%20wikibase%3AhasViolationForConstraint%20%3Fy.%0A%20%20%3Fitem%20%3Fz1%20%3Fs.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP18%20%3Fimage.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP625%20%3Fcoordinate_location.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP585%20%3Fpoint_in_time.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP569%20%3Fdate_of_birth.%20%7D%0A%7D
#Bar chart of statements that have a constraint violation, grouped by
instance of the regarding item:#defaultView:BarChart#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_ofLabelORDER BY DESC(?count)LIMIT 30
Try it!
https://query.wikidata.org/#%23Bar%20chart%20of%20statements%20that%20have%20a%20constraint%20violation%2C%20grouped%20by%20instance%20of%20the%20regarding%20item%3A%0A%23defaultView%3ABarChart%0A%23TEMPLATE%3D%7B%20%22template%22%3A%20%7B%20%22en%22%3A%20%22Bar%20chart%20of%20statements%20that%20have%20a%20constraint%20violation%20grouped%20by%20%3Fproperty%20the%20regarding%20item%22%20%7D%2C%20%22variables%22%3A%20%7B%20%22%3Fproperty%22%3A%20%7B%20%22query%22%3A%22SELECT%20%3Fid%20%20WHERE%20%7B%20VALUES%20%3Fid%20%7B%20%20wd%3AP31%20wd%3AP17%20wd%3AP571%20wd%3AP361%20wd%3AP19%20%7D%20%7D%22%20%7D%20%7D%20%7D%0ASELECT%20%3Finstance_ofLabel%20%28COUNT%28%3Finstance_ofLabel%29%20AS%20%3Fcount%29%20WHERE%20%7B%0A%20%20%3Fs%20wikibase%3AhasViolationForConstraint%20%3Fy.%0A%20%20%3Fitem%20%3Fz1%20%3Fs.%0A%20%20BIND%28wdt%3AP31%20AS%20%3Fproperty%29%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20%3Fproperty%20%3Finstance_of.%20%7D%0A%7D%0AGROUP%20BY%20%3Finstance_ofLabel%0AORDER%20BY%20DESC%28%3Fcount%29%0ALIMIT%2030
The modules included on the property talk pages, Module:Constraints
https://www.wikidata.org/wiki/Module:Constraints,
Module:Constraints/SPARQL
https://www.wikidata.org/wiki/Module:Constraints/SPARQL etc. has been
updated with a new query link (thanks Matěj!)
See also:
- the adding to the ontology
https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/449329/1/docs/ontology.owl
- the Phabricator ticket https://phabricator.wikimedia.org/T192567, if
you have any issue to report
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
www.wikimedia.de
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.