Bas Ernst

This is an image of the blog post Playing with Wikidata

Playing with Wikidata

Sept. 21, 2024

I am learning to understand the semantic web, because I am thinking about using this technology for my final BSc project. Last year, as part of the Data Analysis module, my university provided some extra material about the semantic web the that caught my attention, because linked open data are widely used in the cultural sector connecting collections and various data sets, but also in collaborative projects like Wikipedia.
The Wikidata project enables the use of the Resource Description Framework (RDF) to connect items in the database and add meaning to their relationships.
Wikidata has an online terminal where you can practice Sparql queries and retrieve all possible data from their database. Today I tried to create a timeline and a map of one of Italy's finest painters, Piero della Francesca.
You can copy past the code below and try it yourself.

# Piero della Francesca - Q5822
# Works timeline 
# Location of works

SELECT DISTINCT ?item_label ?image ?name ?location_label ?location_coordinates ?date ?article


WHERE {
    ?item wdt:P31 wd:Q3305213 ;
          wdt:P170 wd:Q5822 ;
          rdfs:label ?item_label # title of the work
          filter ( lang(?item_label) = "en" ) .

    OPTIONAL {?item wdt:P18 ?image } # image
    OPTIONAL {?item wdt:P1476 ?name }  # title
    OPTIONAL {?item wdt:P195 ?location . # this is the collection, look for English 
              ?location wdt:P625 ?location_coordinates ;
                        rdfs:label ?location_label .
                    filter ( lang(?location_label) = "en" ) .
             }
    OPTIONAL {?item wdt:P571 ?date } # date of inception
    OPTIONAL {
              ?item ^schema:about ?article . # only articles from English wikipedia
              ?article schema:isPartOf <https://en.wikipedia.org/>;
              schema:name ?articlename .
             }     
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}