query-e640667bc54a3bb69e24a82e4819bf45

rq turtle/ttl

Propertiesinstance of (P31)occupation (P106)CageMatch worker ID (P2728)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT  ?wrestler ?wrestlerLabel ?refLabel (SAMPLE(?link) AS ?link) 
WHERE {
# Wikidata entries with CageMatch worker ID in occupation as reference
# where the CageMatch worker ID was forgotten in the identifiers section
# (this query should return 0 results)

   ?wrestler wdt:P31 wd:Q5 .          # human
   ?wrestler wdt:P106 wd:Q13474373 .  # occupation professional wrestler

   ?article schema:about ?wrestler .  # limit to wrestlers with EN Wikipedia article
   ?article schema:inLanguage "en" .  # to quicken search - for now
   ?article schema:isPartOf <https://en.wikipedia.org/> .

   ?wrestler p:P106 ?cgid_query . # build statement with p:
   ?cgid_query ps:P106 ?occ .     # retrieve obj within statement with ps:
   ?cgid_query prov:wasDerivedFrom ?refnode . # build ref node 
   ?refnode pr:P2728 ?ref .       # ref node should be Cagematch worker ID

# only look for entries without the CageMatch ID in the identifiers section
# bind to format as clickable URL 
  MINUS {
   ?wrestler wdt:P2728 ?cgid .
   BIND(IRI(REPLACE(?cgid, '^(.+)$', ?url)) AS ?link).
      }
   SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
      }
   }
GROUP BY ?wrestler ?wrestlerLabel ?refLabel
ORDER BY ?wrestlerLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?article") v8("?cgid") v4("?cgid_query") v10("?link"):::projected v5("?occ") v7("?ref") v6("?refnode") v2("?wrestler"):::projected v1("?wrestlerLabel"):::projected c7(["en"]):::literal c9([https://en.wikipedia.org/]):::iri c16(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c4(["wd:Q13474373"]):::iri v2 --"p:direct/P31"--> c2 v2 --"p:direct/P106"--> c4 v3 --"schema:about"--> v2 v3 --"schema:inLanguage"--> c7 v3 --"schema:isPartOf"--> c9 v2 --"p:P106"--> v4 v4 --"p:statement/P106"--> v5 v4 --"prov:wasDerivedFrom"--> v6 v6 --"p:reference/P2728"--> v7 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P2728"--> v8 bind1[/"replace(?cgid,'^(.+)$',?url)"/] v8 --o bind1 null --o bind1 bind1 --as--o v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c16 --"wikibase:language"--> c7 end bind3[/"sample(?link)"/] v10 --o bind3 bind3 --as--o v10