query-fc31f102b1cce074a257256802669d91

rq turtle/ttl

Most common classes for "depicts" (P180) on Commons SELECT (SUM(?count) AS ?sum) ?class ?class_label (SAMPLE(?value) AS ?instance) (SAMPLE(?value_label) AS ?instance_label) (SAMPLE(?example) AS ?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 1000 . 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 { ?value wdt:P31 ?class OPTIONAL {?value rdfs:label ?value_label FILTER (lang(?value_label) = 'en') } . OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } . } } GROUP BY ?class ?class_label 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 classes for "depicts" (P180) on Commons
SELECT (SUM(?count) AS ?sum) ?class ?class_label (SAMPLE(?value) AS ?instance) (SAMPLE(?value_label) AS ?instance_label) (SAMPLE(?example) AS ?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 1000 .
        bd:serviceParam bd:sample.sampleType "RANDOM" .
     }  
  } GROUP BY ?value
  ORDER BY DESC(?count)
#  LIMIT 2000           
}.
    service <https://query.wikidata.org/sparql> {
      ?value wdt:P31 ?class
      OPTIONAL {?value rdfs:label ?value_label FILTER (lang(?value_label) = 'en') } .
      OPTIONAL {?class rdfs:label ?class_label FILTER (lang(?class_label) = 'en') } .
    }
} GROUP BY ?class ?class_label 
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"):::projected v5("?example"):::projected v3("?file") v9("?instance") v10("?instance_label") v11("?sample") v9("?sum") v4("?value"):::projected v7("?value_label"):::projected c3(["bd:serviceParam"]):::iri c7(["RANDOM"]):::literal c5(["1000^^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 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."rdfs:label".-> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v8 -."rdfs:label".-> v6 end end bind8[/"sum(?count)"/] v5 --o bind8 bind8 --as--o v9 bind9[/"sample(?value)"/] v4 --o bind9 bind9 --as--o v9 bind10[/"sample(?value_label)"/] v7 --o bind10 bind10 --as--o v10 bind11[/"sample(?example)"/] v5 --o bind11 bind11 --as--o v11