query-fdc7670c03011e886243114158d4a5c5

rq turtle/ttl

Example constraint violations for various types SELECT ?example ?itemLabel ?p ?numOccurs ?constraint ?constraintTypeLabel WHERE { { SELECT (SAMPLE(?item) AS ?item) ?p ?constraint (COUNT(?stmt) AS ?numOccurs) WHERE { ?stmt wikibase:hasViolationForConstraint ?constraint. ?item ?p ?stmt ;

wdt:P31 wd:Q5 .

wdt:P31 wd:Q43229 .

        wdt:P31 wd:Q515 . # city
} 
GROUP BY ?p ?constraint

ORDER BY DESC(?numOccurs)

LIMIT 30

} ?constraint ps:P2302 ?constraintType . BIND(URI(CONCAT(STR(?item), "#", STRAFTER(STR(?p), STR(p:)))) AS ?example) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } ORDER BY DESC(?numOccurs)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Example constraint violations for various types
SELECT ?example ?itemLabel ?p ?numOccurs ?constraint ?constraintTypeLabel
WHERE {
  {
    SELECT (SAMPLE(?item) AS ?item) ?p ?constraint (COUNT(?stmt) AS ?numOccurs)
    WHERE {
      ?stmt wikibase:hasViolationForConstraint ?constraint.
      ?item ?p ?stmt ;
#          wdt:P31 wd:Q5 .
#          wdt:P31 wd:Q43229 .
            wdt:P31 wd:Q515 . # city
    } 
    GROUP BY ?p ?constraint
#    ORDER BY DESC(?numOccurs)
#    LIMIT 30
  }
  ?constraint ps:P2302 ?constraintType .
  BIND(URI(CONCAT(STR(?item), "#", STRAFTER(STR(?p), STR(p:)))) AS ?example)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?numOccurs)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?constraint"):::projected v6("?constraintType") v7("?example"):::projected v6("?item") v6("?numOccurs"):::projected v5("?p"):::projected v2("?stmt") c6(["bd:serviceParam"]):::iri c3(["wd:Q515"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"wikibase:hasViolationForConstraint"--> v3 v6 -->v5--> v2 v6 --"p:direct/P31"--> c3 bind2[/"sample(?item)"/] v6 --o bind2 bind2 --as--o v6 bind3[/"count(?stmt)"/] v2 --o bind3 bind3 --as--o v6 v3 --"p:statement/P2302"--> v6 bind4[/"concat(str(?item),'#',substring-after(str(?p),str('p:')))"/] v6 --o bind4 v5 --o bind4 bind4 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end