Page MenuHomePhabricator

SPARQL or: How I Learned to Stop Worrying and Love the Triples
Closed, ResolvedPublic

Description

Wednesday, 22. June, at 13:00 in Room 50

Sparql and http://query.wikidata.org/ have been around for some time now, but could be used more. We should do a SPARQL beginners workshop during the Wikimania Hackathon 2016 to get more people started with SPARQL. It would be nice if non-hackathon participants would be allowed in too.

https://etherpad.wikimedia.org/p/SPARQLatWikimania2016

Related Objects

Event Timeline

Restricted Application added projects: Wikidata, Discovery. · View Herald TranscriptJun 13 2016, 8:13 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald Transcript
Base awarded a token.Jun 13 2016, 8:33 PM
Base added a subscriber: Base.
Kghbln added a subscriber: Kghbln.Jun 13 2016, 8:38 PM

I won't be on Wikimania but if any help is needed I would be glad to assist.

Yay! Let me know if you need any held and/or presentations on the topic and/or basic explanation of how this whole SPARQL thing works! :)

Lucie updated the task description. (Show Details)Jun 17 2016, 12:06 PM

Yes please!

Resources:

About the format: We probably need a couple of slides, but more important, we need people to bring their laptops and have a couple of people walk around.

We need to start with the basics (like https://query.wikidata.org/#%23Can%20I%20have%2010%20triples%20please%3F%0ASELECT%20%3Fa%20%3Fb%20%3Fc%0AWHERE%20%7B%20%3Fa%20%3Fb%20%3Fc%20%7D%0ALIMIT%2010 ) and add the pieces for people who to build queries. Components we probably want to explain:

  • basic SELECT .. WHERE .. LIMIT
  • Label service
  • OPTIONAL
  • DISTINCT
  • ORDER BY
  • GROUP BY
  • MINUS
  • FILTER
  • UNION
  • BIND
  • Visualizations! Maps, external, on Wikidata
Spinster added a comment.EditedJun 19 2016, 6:26 PM

I’m not going to the hackathon but will be there on Wednesday and would love to attend this.

I'm not a programmer. I’m able to take existing queries and modify them a bit. I'm also able to build WDQ queries and then use the converter. Would like to learn to build SPARQL queries from scratch.

Haven’t been able to figure out the scenarios and questions below, though, and would like to learn this (if it is doable via Wikidata’s SPARQL engine):

  • Give me all the paintings that are depicted in https://www.wikidata.org/wiki/Q17337965 and put them on a map - this should be retrieved via the coordinates of their collections
  • Give me all the artworks in one art collection + all their inventory numbers + the reference URLs in the references for the inventory numbers (that last part is something I can’t do yet)
  • I'd like to get lists of items that have specific statements *with specific qualifiers* (so I'd like to learn to integrate qualifiers in a query)
  • Give me all the artists who are creators of artworks of one art collection, show each artist only once, and put them on a map based on their birth date
  • Give me all the public artworks (genre: public art) in an area 3 km around a given point
  • I’d like to see an interesting and working use case for the Graph and the Dimensions display mode
  • Is it possible to generate a graph visualization of 8 different art collections and their connected artists (so that you see which artists are represented in multiple collections)?
  • I'd like to work with pagepiles and/or with sets of handpicked Wikidata items, but have a hunch that this is not possible, is this correct? If it is possible, how to do it?

Here is a video showing how to use the query explanation box and different result views:
https://commons.wikimedia.org/wiki/File:Wikidata_Query_Service_Introduction.webm

This comment was removed by Jonas.

I think we also need to mention how the completion works, both when writing and reading, not everybody is aware of it. And give some insight in the data model - i.e. how wdt: works, how statements work, etc.

Esh77 added a subscriber: Esh77.Jun 21 2016, 4:59 AM
Ata added a subscriber: Ata.Jun 21 2016, 9:04 PM
Addshore moved this task from incoming to monitoring on the Wikidata board.Jun 22 2016, 1:00 PM

You can also point out talk page. There are also many examples, which probably could be ported to queries page itself some day, but that is another story.

Ata added a comment.Jun 26 2016, 5:06 PM

I am completely a newbie and my first query thanks to this session is this. Now I have 43 entries of people born in Ukraine before year 1890 with no death date which I will need to check :) Thanks a lot for the session.

Multichill closed this task as Resolved.Jun 28 2016, 2:19 PM
Multichill triaged this task as Normal priority.
Multichill claimed this task.

Backing up the etherpad:

llllllllllllllPhab task: https://phabricator.wikimedia.org/T137743

Slides: https://commons.wikimedia.org/wiki/File:Wikimania_2016_Hackathon_SPARQL.pdf

Examples: https://www.mediawiki.org/wiki/Wikibase/Indexing/SPARQL_Query_Examples

http://query.wikidata.org

RDF is a triple language: Subject Predicate Object

Can render output of query as a map; this scales to ~100,000 points.

Components include

basic SELECT .. WHERE .. LIMIT

Label service

OPTIONAL

DISTINCT

ORDER BY

GROUP BY

MINUS

FILTER

UNION

BIND

Query for artists that are a member of collection rights society (CRO):

https://query.wikidata.org/#%23Artist%20that%20are%20member%20of%20CBO%20per%20country%20%0ASELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20%3FCBO%20%3FCBOLabel%20%3Fcountry%20%3FcountryLabel%0AWHERE%20%7B%0A%20%20%20%20%3Fperson%20wdt%3AP106%20wd%3AQ483501%20.%20%0A%20%20%20%20%3Fperson%20wdt%3AP463%20%3FCBO%20.%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20...%20with%20an%20awarded%28P166%29%20statement%0A%20%20%20%20%3FCBO%20wdt%3AP31%20wd%3AQ1047437%20.%0A%20%20%09%3FCBO%20wdt%3AP17%20%3Fcountry%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%23%20...%20include%20the%20labels%0A%20%20%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22nl%2Cen%22%20.%0A%20%20%20%20%7D%0A%20%20%0A%7D%20ORDER%20BY%20ASC%28%3FpersonLabel%29%20%0ALIMIT%20100%0A

https://www.wikidata.org/wiki/Q5301050
(space at start of English label)

@Lucie gave a nice presentation to a classroom full of people. Most people were fairly new to sparql, but managed to get some queries working and continued to improve and expand them on the hackathon.