User:MartinPoulter/queries/collections

From Wikidata
Jump to navigation Jump to search

Contents

How many Wikidata things have the "in collection" property[edit]

The following query uses these:

  • Properties: collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
    1 SELECT (COUNT(?obj) AS ?count)  WHERE {
    2 ?obj p:P195 ?s.
    3 ?s ps:P195 ?collection.
    4 MINUS { ?s pq:P582 [] }
    5 }
    

As of 25 November 2017: 314,221. An extra 1,150 if we allow relations that have an end date.

Collection sizes[edit]

The following query uses these:

  • Properties: part of (P361) View with Reasonator View with SQID, instance of (P31) View with Reasonator View with SQID, country (P17) View with Reasonator View with SQID, collection or exhibition size (P1436) View with Reasonator View with SQID, applies to part (P518) View with Reasonator View with SQID
     1 SELECT ?collection ?collectionLabel ?partofLabel ?countryLabel ?size ?partLabel WHERE {
     2 ?collection p:P1436 ?s.
     3   ?s ps:P1436 ?size
     4   OPTIONAL {?s pq:P518 ?part}
     5   OPTIONAL {?collection wdt:P361 ?partof . # Get the organisation the collection is part of
     6             MINUS{ ?partof wdt:P31 wd:Q13406463 } } # but not Wikimedia list articles
     7   OPTIONAL {?collection wdt:P17 ?country}
     8 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
     9   FILTER (?size > 100)
    10 } ORDER BY DESC(?size)
    

Number of items in Wikidata with each collection property[edit]

The following query uses these:

  • Properties: part of (P361) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
    1 SELECT (COUNT(?obj) AS ?count) ?collection ?collectionLabel ?partofLabel WHERE {
    2 ?obj p:P195 ?s.
    3 ?s ps:P195 ?collection.
    4 MINUS { ?s pq:P582 [] }
    5 OPTIONAL { ?collection wdt:P361 ?partof }
    6 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    7 } GROUP BY ?collection ?collectionLabel ?partofLabel
    8 ORDER BY DESC(?count)
    9 LIMIT 100
    

Most common properties of objects in a given collection[edit]

The following query uses these:

Properties that items from two collections have in common[edit]

The following query uses these:

  • Properties: collection (P195) View with Reasonator View with SQID, depicts (P180) View with Reasonator View with SQID, creator (P170) View with Reasonator View with SQID, time period (P2348) View with Reasonator View with SQID, movement (P135) View with Reasonator View with SQID, genre (P136) View with Reasonator View with SQID, inspired by (P941) View with Reasonator View with SQID, material used (P186) View with Reasonator View with SQID, location of final assembly (P1071) View with Reasonator View with SQID
     1 #defaultView:ScatterChart
     2 SELECT (?count1 AS ?in_Tate) (?count2 AS ?in_Smithsonian) (CONCAT(?propertyLabel,": ",?thingLabel)AS ?attribute) WHERE {
     3 { SELECT (COUNT(?obj1) AS ?count1) ?property ?thing WHERE {
     4  ?obj1 wdt:P195 wd:Q430682. #Tate
     5  VALUES ?prop1 {wdt:P180 wdt:P170 wdt:P2348 wdt:P135 wdt:P136 wdt:P941 wdt:P186 wdt:P1071}
     6  ?obj1 ?prop1 ?thing.
     7  ?property ?ref ?prop1 ; 
     8            rdf:type wikibase:Property .
     9   } GROUP BY ?property ?thing }
    10 { SELECT (COUNT(?obj2) AS ?count2) ?property ?thing WHERE {
    11  ?obj2 wdt:P195 wd:Q1192305. #Smithsonian
    12  VALUES ?prop1 {wdt:P180 wdt:P170 wdt:P2348 wdt:P135 wdt:P136 wdt:P941 wdt:P186 wdt:P1071}
    13  ?obj2 ?prop1 ?thing.
    14  ?property ?ref ?prop1 ;
    15            rdf:type wikibase:Property .
    16   } GROUP BY ?property ?thing }
    17  FILTER (?count2 >2 )
    18  FILTER (?count1 >2 )
    19 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?property rdfs:label ?propertyLabel .?thing rdfs:label ?thingLabel }
    20 }
    

Refined version of above that just focuses on artists in common[edit]

The following query uses these:

  • Properties: collection (P195) View with Reasonator View with SQID, creator (P170) View with Reasonator View with SQID
     1 #defaultView:ScatterChart
     2 SELECT (?count1 AS ?in_Tate) (?count2 AS ?in_NPG) ?artist WHERE {
     3 { SELECT (COUNT(?obj1) AS ?count1) ?creator WHERE {
     4  ?obj1 wdt:P195 wd:Q430682. #Tate
     5  ?obj1 wdt:P170 ?creator.
     6   } GROUP BY ?creator }
     7 { SELECT (COUNT(?obj2) AS ?count2) ?creator WHERE {
     8  ?obj2 wdt:P195 wd:Q238587. #National Portrait Gallery
     9  ?obj2 wdt:P170 ?creator.
    10   } GROUP BY ?creator }
    11  FILTER (?creator != wd:Q4233718) # exclude anonymous works
    12 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?creator rdfs:label ?artist }
    13 }
    

Manuscripts[edit]

Image gallery of notable manuscripts (which have an image on Wikimedia Commons)[edit]

The following query uses these:

Features: ImageGrid (Q24515278) View with Reasonator View with SQID

 1 #defaultView:ImageGrid
 2 SELECT ?link (MIN(?image) AS ?img) ?qLabel (COUNT(DISTINCT ?sitelink) AS ?linkcount) WHERE {
 3   ?q (wdt:P31/wdt:P279*) wd:Q87167.
 4   FILTER (?q != wd:Q145780) # Exclude Dead Sea Scrolls: too broad
 5   ?sitelink schema:about ?q.
 6   ?q wdt:P18 ?image.
 7   BIND(URI(CONCAT("http://example.org/test/manuscripts/index.php?q=manuscript/",SUBSTR(STR(?q),32))) AS ?link)
 8   SERVICE wikibase:label {
 9     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
10     ?q rdfs:label ?qLabel.
11   }
12 }
13 GROUP BY ?link ?qLabel
14 ORDER BY DESC(?linkcount)
15 LIMIT 100

The most notable manuscripts and their collections[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, language of work or name (P407) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
     1 SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collectionLabel; separator="; ") AS ?where) ?enwp (GROUP_CONCAT(DISTINCT ?langLabel; separator=", ") AS ?languages) ?linkcount
     2 WHERE { {SELECT ?q (COUNT(?sitelink) AS ?linkcount) WHERE {  ?q (wdt:P31/wdt:P279*) wd:Q87167. ?sitelink schema:about ?q }
     3    GROUP BY ?q  }
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5       MINUS {?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?q wdt:P407 ?lang }
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     9     ?q rdfs:label ?qLabel. ?collection rdfs:label ?collectionLabel . ?lang rdfs:label ?langLabel
    10   }
    11  OPTIONAL{?enwp schema:about ?q ; schema:isPartOf <https://en.wikipedia.org/> }
    12  # other props: inventory number; part of ; full work (P953); Commons cat; described at (P973)
    13 }
    14 GROUP BY ?q ?qLabel ?enwp ?linkcount
    15 ORDER BY DESC(?linkcount)
    

Notable manuscripts and their collections (full query)[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, image (P18) View with Reasonator View with SQID, language of work or name (P407) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID, inventory number (P217) View with Reasonator View with SQID
     1 SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collplusinv; separator=" !!! ") AS ?where) (GROUP_CONCAT(DISTINCT ?lang; separator=" ") AS ?languages) ?linkcount (SAMPLE(?image) AS ?image)
     2 WHERE { {SELECT ?q (COUNT(?sitelink) AS ?linkcount) WHERE { ?q (wdt:P31/wdt:P279*) wd:Q87167. OPTIONAL {?sitelink schema:about ?q} }
     3    GROUP BY ?q  }
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5       MINUS {?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?s pq:P217 ?inventory}
     7 OPTIONAL{ ?q wdt:P18 ?image }
     8 BIND( IF(BOUND(?inventory), CONCAT(STR(?collection)," ",?inventory), STR(?collection)) AS ?collplusinv).
     9  SERVICE wikibase:label {
    10    bd:serviceParam wikibase:language "en,fr,it,de,es,ru,bg,ca,cs,nl,zh,ja".
    11    ?q rdfs:label ?qLabel.
    12  }
    13 OPTIONAL{ ?q wdt:P407 ?lang }
    14 # other props: part of, exemplar
    15 }
    16 GROUP BY ?q ?qLabel ?linkcount
    17 ORDER BY DESC(?linkcount)
    

Collections of manuscripts[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, official website (P856) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
     1 SELECT ?collection ?l (GROUP_CONCAT(DISTINCT ?officialweb) AS ?webs) (COUNT(DISTINCT ?q) AS ?mcount)
     2 WHERE {
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection. MINUS {?s pq:P582 []}.
     5 MINUS { ?s ps:P195 wd:Q1322278 }
     6 OPTIONAL{ ?collection wdt:P856 ?officialweb } 
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "en".
     9 ?collection rdfs:label ?l
    10   }
    11 }
    12 GROUP BY ?collection ?l
    13 ORDER BY UCASE(?l)
    

Languages of manuscripts[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, language of work or name (P407) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
     1 SELECT ?lang ?langLabel ?langDescription (COUNT(DISTINCT ?q) AS ?mcount)
     2 WHERE {
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5 MINUS { ?s ps:P195 wd:Q1322278 }
     6 ?q wdt:P407 ?lang 
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "en"
     9   }
    10 }
    11 GROUP BY ?lang ?langLabel ?langDescription
    12 ORDER BY UCASE(?langLabel)
    

Top ten languages by number of manuscripts[edit]

SELECT (SUBSTR(STR(?lang),32) AS ?wd) (COUNT(DISTINCT ?q) AS ?mcount)
WHERE {
?q (wdt:P31/wdt:P279*) wd:Q87167.
?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
MINUS { ?s ps:P195 wd:Q1322278 }
?q wdt:P407 ?lang 
}
GROUP BY ?lang
ORDER BY DESC(?mcount)
LIMIT 10

Try it!

Materials used in manuscripts[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, material used (P186) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
     1 SELECT ?material ?l ?d (COUNT(DISTINCT ?q) AS ?mcount)
     2 WHERE {
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5 MINUS { ?s ps:P195 wd:Q1322278 }
     6 ?q wdt:P186 ?material
     7   SERVICE wikibase:label {
     8     bd:serviceParam wikibase:language "en".
     9     ?material rdfs:label ?l; schema:description ?d
    10   }
    11 }
    12 GROUP BY ?material ?l ?d
    

Map of manuscript collections[edit]

The following query uses these:

Features: Map (Q24515275) View with Reasonator View with SQID

 1 #defaultView:Map
 2 SELECT ?link ?collectionLabel ?coords
 3 WHERE {
 4 {SELECT DISTINCT ?collection ?coords WHERE {?q (wdt:P31/wdt:P279*) wd:Q87167;
 5   wdt:P195 ?collection .
 6 ?collection wdt:P625 ?coords.
 7 } }
 8 BIND (URI(CONCAT("/collection/",SUBSTR(STR(?collection),32))) AS ?link).
 9 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
10 }

Manuscripts lacking a collection[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, subclass of (P279) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID
     1 SELECT DISTINCT ?q ?qLabel ?qDescription ?enwp 
     2 WHERE { 
     3 ?q (wdt:P31/wdt:P279*) wd:Q87167.   
     4 MINUS { ?q wdt:P195 []}
     5   SERVICE wikibase:label {
     6     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     7   }
     8  OPTIONAL{?enwp schema:about ?q ; schema:isPartOf <https://en.wikipedia.org/> }
     9 }
    10 ORDER BY DESC(?qLabel)
    

Objects with "instance of papyrus" (which shouldn't be the case)[edit]

SELECT * WHERE {
?item wdt:P31 wd:Q125576
}

Try it!

Bodleian things and their online digitizations[edit]

SELECT ?thing ?thingLabel ?inv ?url WHERE {
VALUES ?in {wd:Q82133 wd:Q2210813} # Bodleian and Sackler
?thing p:P195 ?s; wdt:P953 ?url FILTER(CONTAINS(STR(?url),"ox.ac.uk")).
?s ps:P195 ?in
OPTIONAL { ?s pq:P217 ?inv }
MINUS {?thing wdt:P1433 []}
MINUS {?thing wdt:P361 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?thingLabel

Try it!

Bodleian items with no image and no Commons category[edit]

SELECT ?item ?itemLabel ?url WHERE {
VALUES ?in {wd:Q82133 wd:Q2210813} # Bodleian and Sackler
?item wdt:P195 ?in; wdt:P953 ?url
MINUS {?item wdt:P18 []}
MINUS {?item wdt:P373 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Try it!

Ashmolean Museum[edit]

Things in the collection of the Ashmolean museum[edit]

SELECT ?type ?typeLabel (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400;
      wdt:P31 ?type.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?type ?typeLabel ORDER BY DESC(?count)

Try it!

People associated with Ashmolean items[edit]

Used to make people_in_ashmolean.json

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (COUNT(?item) AS ?count) (YEAR(SAMPLE(?time)) AS ?year) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item ?prop ?person.
?person wdt:P31 wd:Q5.
OPTIONAL {?person wdt:P18 ?image}
OPTIONAL {?person wdt:P569 ?birth}
OPTIONAL {?person wdt:P1317 ?fl}
OPTIONAL {?person wdt:P2348/wdt:P580 ?erastart}
BIND(IF(BOUND(?birth), ?birth, IF(BOUND(?fl), ?fl, ?erastart) ) AS ?time). 
SERVICE wikibase:label {bd:serviceParam wikibase:language "en"}
} GROUP BY ?person ?personLabel ?personDescription ORDER BY ?year

Try it!

Things depicted (but not places)[edit]

Used to make depicted.json

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item wdt:P180 ?person.
MINUS {?person wdt:P625 []}
OPTIONAL {?person wdt:P18 ?image}
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". }
} GROUP BY ?person ?personLabel ?personDescription ORDER BY UCASE(?personLabel)

Try it!

Locations associated with Ashmolean items[edit]

#defaultView:Map{"hide": ["?latlong", "?layer"]}
SELECT (URI(CONCAT("http://economicsnetwork.ac.uk/test/era2/location.php?q=",SUBSTR(STR(?place),32) ) ) as ?link) ?placeX ?placeLabel ?layer (SAMPLE(?coords) AS ?latlong)
WHERE {
?item wdt:P195 wd:Q636400;
    wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
VALUES ?property {wd:P180 wd:P1071} # wdt:P921 wdt:P189 wdt:P138
?property wikibase:directClaim ?prop.
?item ?prop ?place.
?place wdt:P625 ?coords.
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". 
?property rdfs:label ?layer. ?place rdfs:label ?placeLabel; schema:description ?placeX}
} GROUP BY ?place ?placeLabel ?placeX ?layer

Try it!

Ashmolean items associated with a given person or location[edit]

SELECT ?prop ?item ?itemLabel ?inventory (GROUP_CONCAT(?typeLabel; separator=", ") AS ?types) ?from (YEAR(?latest) AS ?to) ?precision WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item ?prop wd:Q48129717; wdt:P31 ?type.
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
OPTIONAL {?item p:P571/psv:P571 [ wikibase:timePrecision ?precision; wikibase:timeValue ?year ] }
BIND(IF (BOUND(?earliest), YEAR(?earliest), YEAR(?year)) AS ?from)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
?item rdfs:label ?itemLabel. ?type rdfs:label ?typeLabel }
} GROUP BY ?prop ?item ?itemLabel ?inventory ?from ?latest ?precision
ORDER BY DESC(?prop) ?from ?to

Try it!

Ashmolean people associated with a given location or era[edit]

SELECT ?person ?personLabel ?personDescription (SAMPLE(?image) AS ?img) (YEAR(SAMPLE(?time)) AS ?year) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url), "http://jameelcentre") ).
?item ?prop ?person.
?person wdt:P31 wd:Q5.
?person ?prop2 wd:Q1490.
OPTIONAL {?person wdt:P18 ?image}
OPTIONAL {?person wdt:P569 ?birth}
OPTIONAL {?person wdt:P1317 ?fl}
OPTIONAL {?person wdt:P2348/wdt:P580 ?erastart}
BIND(IF(BOUND(?birth), ?birth, IF(BOUND(?fl), ?fl, ?erastart) ) AS ?time). 
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
} GROUP BY ?person ?personLabel ?personDescription ORDER BY ?year

Try it!

Locations associated with a given person[edit]

SELECT DISTINCT (SUBSTR(STR(?place),32) as ?link) ?propertyLabel ?placeLabel
WHERE {
wd:Q198984 ?prop ?place. ?place wdt:P625 [].
?property ?ref ?prop; rdf:type wikibase:Property.
SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"}
}

Try it!

Ten nearest places to a place[edit]

SELECT DISTINCT (SUBSTR(STR(?place),32) as ?link) ?placeLabel
WHERE {
wd:Q1191 wdt:P625 ?loc2. #Starting point
{ SELECT DISTINCT ?place ?coords WHERE 
 {?item wdt:P195 wd:Q636400;
    wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
VALUES ?property {wd:P180 wd:P1071}
?property wikibase:directClaim ?prop.
?item ?prop ?place.
?place wdt:P625 ?coords
 } }
BIND(geof:distance(?coords, ?loc2) AS ?distNum).
SERVICE wikibase:label {bd:serviceParam wikibase:language "en". 
?place rdfs:label ?placeLabel}
} ORDER BY ?distNum OFFSET 1 LIMIT 10

Try it!

Materials of things in the Ashmolean collection[edit]

This is used to make materials.json

SELECT (SUBSTR(STR(?material), 32) as ?material) ?materialLabel ?materialDescription (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P186 ?material;
wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
} GROUP BY ?material ?materialLabel ?materialDescription ORDER BY UCASE(?materialLabel)

Try it!

Ashmolean items for a given material[edit]

SELECT ?item ?itemLabel ?inventory (GROUP_CONCAT(?typeLabel; separator=", ") AS ?types) (YEAR(?earliest) AS ?from) (YEAR(?latest) AS ?to) WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item wdt:P186 wd:Q37681; wdt:P31 ?type;
wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".
?item rdfs:label ?itemLabel. ?type rdfs:label ?typeLabel}
} GROUP BY ?item ?itemLabel ?inventory ?earliest ?latest
ORDER BY ?from ?to ?itemLabel

Try it!

Types of things in the Ashmolean collection[edit]

used to make types.json

SELECT (SUBSTR(STR(?type), 32) as ?type) ?typeLabel ?typeDescription (COUNT(?item) AS ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P31 ?type; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} GROUP BY ?type ?typeLabel ?typeDescription ORDER BY UCASE(?typeLabel)

Try it!

Items of a given type[edit]

SELECT ?item ?itemLabel ?inventory (YEAR(?earliest) AS ?from) (YEAR(?latest) AS ?to) WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
?item wdt:P31 wd:Q1066288; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
OPTIONAL {?item p:P571 [pq:P1319 ?earliest; pq:P1326 ?latest] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .
?item rdfs:label ?itemLabel }
} ORDER BY ?from ?to ?itemLabel

Try it!

Ashmolean items without a label[edit]

As of 31 March 2018, gives zero results.

SELECT ?item WHERE {
?item wdt:P195 wd:Q636400.
MINUS {?item rdfs:label []}
}

Try it!

Ashmolean items without no inception date and no time period[edit]

SELECT ?item ?inventory WHERE {
?item p:P195 [ps:P195 wd:Q636400; pq:P217 ?inventory].
MINUS {?item wdt:P571 []}
MINUS {?item wdt:P2348 []}
}

Try it!

Ashmolean things named "Figure of " but with no depiction property[edit]

Also includes "Standing figure of...", "Seated figure of..."

SELECT ?item ?itemLabel ?url WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url
MINUS {?item wdt:P180 []}
?item rdfs:label ?itemLabel filter( lang(?itemLabel)="en" ) filter( CONTAINS(?itemLabel, "igure of ") )
}

Try it!

Jameel items ordered by number of statements[edit]

SELECT ?item ?count WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item wikibase:statements ?count.
} ORDER BY DESC(?count)

Try it!

Count of links from Jameel items to items that have a location[edit]

SELECT (COUNT(?loc) as ?count) WHERE {
?item wdt:P195 wd:Q636400; wdt:P973 ?url FILTER (STRSTARTS(STR(?url),"http://jameelcentre") ).
?item ?prop ?loc. ?loc wdt:P625 [] FILTER (?loc != wd:Q636400)
}

Try it!

Historic China[edit]

See also Wikidata:WikiProject_East_Asia/China_Biographical_Database_import

Things from dynasties of the imperial era, with their collections and shelfmarks[edit]

The following query uses these:

  • Properties: instance of (P31) View with Reasonator View with SQID, time period (P2348) View with Reasonator View with SQID, country (P17) View with Reasonator View with SQID, country of origin (P495) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, material used (P186) View with Reasonator View with SQID, inventory number (P217) View with Reasonator View with SQID
     1 SELECT ?dynastyLabel ?thing ?thingLabel (GROUP_CONCAT(DISTINCT ?typel; separator=", ") AS ?what) (GROUP_CONCAT(DISTINCT ?matl; separator=", ") AS ?materials) ?thingDescription ?collectionLabel ?inventoryNo WHERE {
     2 ?dynasty wdt:P31 wd:Q50068795.
     3 VALUES ?prop {wdt:P2348 wdt:P17 wdt:P495}.
     4 ?thing ?prop ?dynasty;
     5        wdt:P31 ?type;
     6        wdt:P195 ?collection.
     7  ?type rdfs:label ?typel FILTER(lang(?typel) = "en").
     8 OPTIONAL {?thing wdt:P186 ?material. ?material rdfs:label ?matl FILTER(lang(?matl) = "en") }.
     9 OPTIONAL {?thing wdt:P217 ?inventoryNo }
    10 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
    11 } GROUP BY ?dynastyLabel ?thing ?thingLabel?thingDescription ?collectionLabel ?inventoryNo
    12 ORDER BY ?dynastyLabel
    

Timeline of states of Imperial period[edit]

The following query uses these:

Time periods[edit]

Historic periods and corresponding numbers of things in collections[edit]

The following query uses these:

  • Properties: time period (P2348) View with Reasonator View with SQID, collection (P195) View with Reasonator View with SQID, end time (P582) View with Reasonator View with SQID
     1 SELECT ?period ?periodLabel ?periodDescription (COUNT(?q) AS ?mcount)
     2 WHERE {
     3 ?q wdt:P2348 ?period.
     4 ?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
     5   SERVICE wikibase:label {
     6     bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
     7   }
     8  OPTIONAL{?enwp schema:about ?collection; schema:isPartOf <https://en.wikipedia.org/> }
     9 }
    10 GROUP BY ?period ?periodLabel ?periodDescription
    11 ORDER BY DESC(?mcount)
    

History of Japan[edit]

Periods of Japanese history and what they were named after[edit]

SELECT ?era ?eraLabel (YEAR(?start_time) AS ?start) (YEAR(?end_time) AS ?end) ?namedLabel ?namedDescription WHERE {
?era wdt:P31 wd:Q6428674; wdt:P361 wd:Q130436; # eras of the history of Japan
  wdt:P580 ?start_time.
MINUS { ?era wdt:P2348/wdt:P361 wd:Q130436 } # exclude sub-eras
OPTIONAL { ?era wdt:P582 ?end_time }
OPTIONAL { ?era wdt:P138 ?named }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?start DESC(?end)

Try it!

Periods of Japanese history and calendar eras within them[edit]

SELECT ?era ?eraLabel (YEAR(?start_time) AS ?start) (YEAR(?end_time) AS ?end) ?subera ?suberaLabel 
 (YEAR(?sub_start_time) AS ?sub_start) (YEAR(?sub_end_time) AS ?sub_end) WHERE {
?era wdt:P31 wd:Q6428674; wdt:P361 wd:Q130436; # eras of the history of Japan
  wdt:P580 ?start_time.
MINUS { ?era wdt:P2348/wdt:P361 wd:Q130436 } # exclude sub-eras
OPTIONAL { ?era wdt:P582 ?end_time }
OPTIONAL { ?subera wdt:P2348 ?era; wdt:P361 wd:Q130436; wdt:P580 ?sub_start_time;
  wdt:P582 ?sub_end_time }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
} ORDER BY ?start DESC(?end)

Try it!

Wikidata maintenance[edit]

How many items have an inventory number but no collection?[edit]

The following query uses these:

How many items have an inventory number with a collection in a qualifier but no collection?[edit]

The following query uses these:

As of 25 November 2017, 358

Collections and inventory numbers of items an inventory number with a collection in a qualifier but no collection[edit]

The following query uses these:

  • Properties: collection (P195) View with Reasonator View with SQID, inventory number (P217) View with Reasonator View with SQID
    1 SELECT ?obj ?collection ?inventory WHERE {
    2 ?obj p:P217 ?s.
    3   ?s pq:P195 ?collection; ps:P217 ?inventory
    4 MINUS {?obj wdt:P195 []}
    5 }
    

Semantic search[edit]

Synonyms[edit]

SELECT DISTINCT ?name WHERE {
VALUES ?rel {rdfs:label skos:altLabel}
VALUES ?rel2 {rdfs:label skos:altLabel}
?target ?rel "Confucius"@en;
 ?rel2 ?name FILTER ( lang(?name)="en" )
}

Try it!

Names for types of coin[edit]

SELECT DISTINCT ?name WHERE {
 ?sub wdt:P279+/rdfs:label "coin"@en.
 {?sub rdfs:label ?name} UNION {?sub skos:altLabel ?name} FILTER (lang(?name)="en")
  FILTER ( !CONTAINS(?name, "coin") )
}

Try it!

Things semantically related to a given topic[edit]

SELECT DISTINCT ?related ?relatedLabel ?relatedDescription WHERE {
VALUES ?target {wd:Q42}
{ ?target ?prop ?related } UNION { ?related ?prop ?target }
filter (CONTAINS(STR(?related),'/entity/Q') ).
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY UCASE(?relatedLabel)

Try it!

Data-driven semantic clustering[edit]

#defaultView:Graph
SELECT ?item1 ?item1Label ?item2 ?item2Label WHERE {
VALUES ?item1Label {"Congressional Black Caucus"@en
"Barack Obama"@en
"Michelle Obama"@en
"University of Chicago"@en
"Time Person of the Year"@en
"Democratic Party"@en
"White House"@en
"Hillary Clinton"@en
"Aragorn"@en
"C. S. Lewis"@en
"J. R. R. Tolkien"@en
"University of Oxford"@en
"World War I"@en
"Battle of the Somme"@en
"British Army"@en
"The Lord of the Rings"@en}
VALUES ?item2Label {"Congressional Black Caucus"@en
"Barack Obama"@en
"Michelle Obama"@en
"University of Chicago"@en
"Time Person of the Year"@en
"Democratic Party"@en
"White House"@en
"Hillary Clinton"@en
"Aragorn"@en
"C. S. Lewis"@en
"J. R. R. Tolkien"@en
"University of Oxford"@en
"World War I"@en
"Battle of the Somme"@en
"British Army"@en
"The Lord of the Rings"@en}
  ?item1 rdfs:label ?item1Label.
  ?item2 rdfs:label ?item2Label.
  ?item1 ?prop ?item2
}

Try it!