query-a8334ea549abc1e2c4ee4208dca2aa3b

rq turtle/ttl

Most common values for "depicts" (P180) SELECT ?sum ?class ?class_label ?instance ?instance_label ?sample

WITH { SELECT (COUNT(DISTINCT(?file)) AS ?count) ?value (SAMPLE(?file) AS ?example) WHERE { service bd:sample { ?file wdt:P180 ?value . bd:serviceParam bd:sample.limit 10 . bd:serviceParam bd:sample.sampleType "RANDOM" . }
} GROUP BY ?value ORDER BY DESC(?count) LIMIT 2000
} AS %values

WHERE { INCLUDE %values . service https://query.wikidata.org/sparql { { SELECT (SUM(?count) AS ?sum) ?class (SAMPLE(?value) AS ?instance) (SAMPLE(?example) AS ?sample) WHERE { ?value wdt:P31 ?class } GROUP BY ?class } OPTIONAL {?instance rdfs:label ?instance_label FILTER (lang(?instance_label) = 'en') } . OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } . } } ORDER BY DESC(?sum)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Most common values for "depicts" (P180)
SELECT ?sum ?class ?class_label ?instance ?instance_label ?sample


WHERE {
     { 
  SELECT (COUNT(DISTINCT(?file)) AS ?count) ?value (SAMPLE(?file) AS ?example) WHERE {
     service bd:sample {
       ?file wdt:P180 ?value . 
        bd:serviceParam bd:sample.limit 10 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     }  
  } GROUP BY ?value
  ORDER BY DESC(?count)
  LIMIT 2000           
}.
    service <https://query.wikidata.org/sparql> {
      {
         SELECT (SUM(?count) AS ?sum) ?class (SAMPLE(?value) AS ?instance) (SAMPLE(?example) AS ?sample) WHERE {
            ?value wdt:P31 ?class
         } GROUP BY ?class 
      }
      OPTIONAL {?instance rdfs:label ?instance_label FILTER (lang(?instance_label) = 'en') } .
      OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } .
    }
} 
ORDER BY DESC(?sum)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?class"):::projected v6("?class_label"):::projected v5("?count") v5("?example") v3("?file") v9("?instance"):::projected v7("?instance_label"):::projected v10("?sample"):::projected v9("?sum"):::projected v4("?value") c3(["bd:serviceParam"]):::iri c7(["RANDOM"]):::literal c5(["10^^xsd:integer"]):::literal subgraph s1["http://www.bigdata.com/rdf#sample"] style s1 stroke-width:4px; v3 --"wdt:P180"--> v4 c3 --"bd:sample.limit"--> c5 c3 --"bd:sample.sampleType"--> c7 end bind2[/"count(?file)"/] v3 --o bind2 bind2 --as--o v5 bind3[/"sample(?file)"/] v3 --o bind3 bind3 --as--o v5 subgraph s2["https://query.wikidata.org/sparql"] style s2 stroke-width:4px; v4 --"wdt:P31"--> v8 bind7[/"sum(?count)"/] v5 --o bind7 bind7 --as--o v9 bind8[/"sample(?value)"/] v4 --o bind8 bind8 --as--o v9 bind9[/"sample(?example)"/] v5 --o bind9 bind9 --as--o v10 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v9 -."rdfs:label".-> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."rdfs:label".-> v6 end end