User:Fuzheado/queries

Example queriesEdit

Some Wikidata queries I've crafted that may be interesting to people.

Sports arenasEdit

Knowledge graphEdit

This is a neat query that creates a connected graph of Wikidata items first posed by Martin Poulter (link) and optimized by Lucas Werkmeister (link). Given a list of Wikidata items provided in a VALUES array, use a SPARQL query to find all the relationships among them and then graph them.

 
Knowledge graph of Death of Socrates from The Met

The following query uses these:

Features: Graph (Q24515287)     

#defaultView:Graph
SELECT ?item1 ?image1 ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel 
WITH {
  SELECT ?item1 WHERE {
    VALUES ?item1 { wd:Q913 wd:Q186953 wd:Q3110066 wd:Q1752990 wd:Q5597 wd:Q83155 wd:Q51955019 wd:Q20539433 }
  }
} AS %item1

WITH {
  SELECT (?item1 AS ?item2) WHERE {
    INCLUDE %item1.
  }
} AS %item2

WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
  ?item1 ?wdt ?item2.
  ?edge wikibase:directClaim ?wdt;
        a wikibase:Property.
  OPTIONAL { ?item1 wdt:P18 ?image1. }
  OPTIONAL { ?item2 wdt:P18 ?image2. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Knowledge graph for Portrait of Madame XEdit

This knowledge graph shows how one portrait painting from The Met's collection has had a lasting influence in art, fashion, cinema and literature. The Portrait of Madame X (Q2664039) by John Singer Sargent was such a scandal at the time that only a knowledge graph can capture all the breadth of its impact. It inspired dress that Rita Hayworth wore in the film Gilda, was also the subject of two different books. After the painting was made, it inspired other artists to paint their own portraits of the Madame Virginie Amélie Avegno Gautreau.

 
Knowledge graph for Portrait of Madame X


The following query uses these:

Features: Graph (Q24515287)     

#defaultView:Graph
SELECT ?item1 ?image1 ?item1Label ?item2 ?image2 ?item2Label ?edgeLabel 
WITH {
  SELECT ?item1 WHERE {
    VALUES ?item1 { wd:Q28537550 wd:Q430682 wd:Q69562155 wd:Q69561988 wd:Q571 wd:Q155626 wd:Q2664039 wd:Q3560705 wd:Q160236 wd:Q4010432 wd:Q382307 wd:Q42745 wd:Q65966004 wd:Q15221656 wd:Q17494007 wd:Q23402 wd:Q65966300 wd:Q49135 }
  }
} AS %item1

WITH {
  SELECT (?item1 AS ?item2) WHERE {
    INCLUDE %item1.
  }
} AS %item2

WHERE {
  INCLUDE %item1.
  INCLUDE %item2.
  ?item1 ?wdt ?item2.
  ?edge wikibase:directClaim ?wdt;
        a wikibase:Property.
  OPTIONAL { ?item1 wdt:P18 ?image1. }
  OPTIONAL { ?item2 wdt:P18 ?image2. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Knowledge graph of Met objects and depictionsEdit

Building on the above query, this variation takes a list of Met Museum object IDs (artworks), looks up their Wikidata items, then finds out what those artworks depict. It then draws a connected graph showing relationships among the artworks and the depicted items. This can be customized for any properties or set of starting items as needed. It restricts depicted items to those used at least twice, in order to reduce clutter and to emphasize artworks that have commonalities.

This example draws on The Met Museum's Americana collection, to show themes of nature, North America and politics of the early United States.

Some of the interesting insights from the depiction graph include the tree stump that is common among a number of landscape paintings and sculptures. That leads to some interesting papers around its meaning:

You can edit the Wikidata properties of the objects using this TABernacle session.

NB: This SPARQL query does not shorten correctly using the w.wiki shortener.

 
Example knowledge graph of Met artworks and what they depict

Knowledge graph of Met objects, depictions and creatorsEdit

Variation of the above query, but with creators added in.

Knowledge graph of Hudson River School artists and worksEdit

This shows The Met's Hudson River School aritsts and works in the collection of the museum.

 
Wikidata Knowledge graph of Met Hudson River School artists and artworks

Knowledge graph of Hudson River School works and depictionsEdit

Illustration of all depictions in Hudson River School works and themes

 
Wikidata Knowledge Graph showing Hudson River School depiction subjects

Knowledge graph of women related to folklore and their professionsEdit

 
Wikidata Knowledge Graph related to women in folklore - 2020-02-06

Met Afrofuturism roomEdit

Show graph of Afrofuturism room