query-31b421d9f1376e64c7b0ec61647d2040
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 1000 .
bd:serviceParam bd:sample.sampleType "RANDOM" .
}
} GROUP BY ?value
ORDER BY DESC(?count)
LIMIT 2000
} AS %values
WITH { SELECT (SUM(?count) AS ?sum) ?class (SAMPLE(?value) AS ?instance) (SAMPLE(?example) AS ?sample) WHERE { INCLUDE %values . service https://query.wikidata.org/sparql { ?value wdt:P31 ?class } } GROUP BY ?class } AS %classes
WHERE { INCLUDE %classes . service https://query.wikidata.org/sparql { 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
- https://query.wikidata.org/sparql
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 (SUM(?count) AS ?sum) ?class (SAMPLE(?value) AS ?instance) (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
}
} GROUP BY ?class
}.
service <https://query.wikidata.org/sparql> {
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)