Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Querying Wikidata

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.

Emw

January 16, 2016
Tweet

More Decks by Emw

Other Decks in Technology

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. Wikidata statement in RDF London population 8,173,900 l Wikidata: item

    property value l RDF: subject predicate object l RDF “triplet”
  6. 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.
  7. 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
  8. 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 }
  9. 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
  10. 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
  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 } subject predicate 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 } “Return the value of London's population”
  13. 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
  14. Wikipedia templates that involve multiple Wikidata items like this one

    can get data from from Wikidata queries. How does this relate to Wikipedia?
  15. 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