Querying Wikidata

01cb91d068090b9e18fce6bdf83295fd?s=47 Emw
January 16, 2016

Querying Wikidata

Basic introduction to querying Wikidata with SPARQL. Presented at a plenary session of Wikipedia Day 15 at Tisch School of the Arts in New York University. Released into the public domain under CC0 1.0.

01cb91d068090b9e18fce6bdf83295fd?s=128

Emw

January 16, 2016
Tweet

Transcript

  1. Querying Wikidata Emw Wikipedia Day Tisch School of the Arts,

    New York University New York, NY 2016-01-16 Bufoceratias wedli by Masaki Miya et al.
  2. Wikidata is a free knowledge base and we can query

    it with a language called SPARQL
  3. What you'll learn from this talk What SPARQL is What

    RDF is How to query Wikidata with SPARQL How this relates to Wikipedia
  4. SPARQL l Pronounced “sparkle” l l Semantic query language for

    RDF l l W3C standard, like HTML l l “Trying to use the Semantic Web without SPARQL l is like trying to use a relational database without SQL.” l – Tim Berners-Lee
  5. Elements of a Wikidata statement

  6. Wikidata statement in RDF London population 8,173,900 l Wikidata: item

    property value l RDF: subject predicate object l RDF “triplet”
  7. RDF to English l RDF triplet: subject-predicate-object l English statement:

    subject-verb-object (SVO) l l RDF: l London : population : 8,173,900 l l English: l London has a population of 8,173,900 people.
  8. l Wikidata has over 80,906,047 statements http://tools.wmflabs.org/wikidata-todo/stats.php

  9. How SPARQL works l Queries database of RDF triplets (e.g.,

    Wikidata) l Returns all triplets that satisfy query l l l Wikidata Query Service: https://query.wikidata.org/ l
  10. How many people live there? © User:Colin / Wikimedia Commons

    / CC BY-SA-4.0
  11. SPARQL example l What is the population of London? PREFIX

    wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?object WHERE { wd:Q84 wdt:P1082 ?object }
  12. SPARQL example l What is the population of London? PREFIX

    wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?object WHERE { wd:Q84 wdt:P1082 ?object } The wd: and wdt: represent different namespaces
  13. SPARQL example l What is the population of London? PREFIX

    wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?object WHERE { wd:Q84 wdt:P1082 ?object } London population
  14. SPARQL example l What is the population of London? PREFIX

    wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?object WHERE { wd:Q84 wdt:P1082 ?object } subject predicate object
  15. SPARQL example l What is the population of London? PREFIX

    wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> SELECT ?object WHERE { wd:Q84 wdt:P1082 ?object } “Return the value of London's population”
  16. Explore this query in Wikidata Query Service: http://tinyurl.com/zvhc2ar

  17. SPARQL example 2 l What are all populations of London

    over time? PREFIX wd: <http://www.wikidata.org/entity/> PREFIX p: <http://www.wikidata.org/prop/> PREFIX v: <http://www.wikidata.org/prop/statement/> SELECT ?population WHERE { wd:Q84 p:P1082/v:P1082 ?population . } On Wikidata Query Service: http://tinyurl.com/hcaglpg
  18. Wikipedia templates that involve multiple Wikidata items like this one

    can get data from from Wikidata queries. How does this relate to Wikipedia?
  19. More interesting Wikidata queries Most common causes of death among

    U.S. Presidents Diseases associated with particular symptoms All human genes on chromosome X Causes of the American Civil War
  20. Thank you! l l l https://www.wikidata.org/wiki/User:Emw l