From 1086b9818a9364f17213c84c9043c821e86043a4 Mon Sep 17 00:00:00 2001 From: "Carlos A. Iglesias" Date: Thu, 21 Feb 2019 11:11:57 +0100 Subject: [PATCH] Updated intro --- lod/01_SPARQL_Introduction.ipynb | 96 +++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 15 deletions(-) mode change 100644 => 100755 lod/01_SPARQL_Introduction.ipynb diff --git a/lod/01_SPARQL_Introduction.ipynb b/lod/01_SPARQL_Introduction.ipynb old mode 100644 new mode 100755 index 404ac3a..1be3a2c --- a/lod/01_SPARQL_Introduction.ipynb +++ b/lod/01_SPARQL_Introduction.ipynb @@ -43,14 +43,12 @@ "## Introduction to Linked Open Data\n", "\n", "This lecture provides a quick introduction to semantic queries in Python using SPARQL.\n", - "SPARQL is aa semantic query language inspired by SQL.\n", + "SPARQL is a semantic query language inspired by SQL.\n", "\n", "This is the first in a series of notebooks about SPARQL, which consists of:\n", "\n", "* This notebook, which introduces basic concepts using a small public dataset.\n", "* [A notebook with queries to a custom dataset](02_SPARQL_Custom_Endpoint.ipynb), which links to the RDF exercises.\n", - "* [A notebook with queries to DBpedia](03_SPARQL_Writers.ipynb). DBpedia is the semantic version of Wikipedia. It is very useful, as it contains much more data. However, finding the right properties to query can be challenging.\n", - "* [A notebook with more advanced SPARQL concepts](04_SPARQL_Advanced.ipynb), which extends the previous notebook with more advanced concepts, such as regular expressions and dealing with dates." ] }, { @@ -163,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "deletable": false, "editable": false, @@ -176,7 +174,17 @@ "solution": false } }, - "outputs": [], + "outputs": [ + { + "data": { + "application/javascript": [ + "IPython.CodeCell.options_default.highlight_modes['magic_sparql'] = {'reg':[/^%%sparql/]};" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "from helpers import sparql, solution, show_photos" ] @@ -332,7 +340,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "deletable": false, "editable": false, @@ -345,7 +353,21 @@ "solution": false } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
entitytype
http://learningsparql.com/ns/musician/RaymondBrownhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/PaulMcCartneyhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/PeteBesthttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/GeorgeHarrisonhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/JohnLennonhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/RingoStarrhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/KeithMoonhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/TonySheridanhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/GeorgeMartinhttp://learningsparql.com/ns/schema/Musician
http://learningsparql.com/ns/musician/DennisMcConnellhttp://learningsparql.com/ns/schema/Musician
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%sparql http://fuseki.cluster.gsi.dit.upm.es/sitc/\n", "\n", @@ -376,7 +398,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -388,12 +410,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now, use the same concepts to write a query that gets the **list of entities and their properties**." + "Now, use the same concepts to write a query that gets the **list of entities and their properties**. You can remove DISTICT and observe what happens. \n", + "\n", + "**Hint**: review the previous query and see how to use the variable ?prop." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "deletable": false, "nbgrader": { @@ -405,7 +429,21 @@ "solution": true } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
entityprop
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%sparql http://fuseki.cluster.gsi.dit.upm.es/sitc/\n", "\n", @@ -587,9 +625,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
prop
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.w3.org/2000/01/rdf-schema#label
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%sparql http://fuseki.cluster.gsi.dit.upm.es/sitc/\n", "\n", @@ -885,7 +937,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": { "deletable": false, "nbgrader": { @@ -897,7 +949,21 @@ "solution": true } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
musician
Alan Branscombe
Alan Civil
Alan Dalziel
Alan Holmes
Alan Loveday
Alex Nifosi
Alf Bicknell
Alf Reece
Alfred Waters
Allan Grant
Allen Ford
Amrit Gajjar
Andrew McGee
Andy White
Anil Bhagwat
Anna Joshi
Art Ellefson
Ashish Khan
Barrie Cameron
Basil Tschaikov
Bernard Davis
Bernard George
Bernard Miller
Bert Courtley
Bill Jackman
Bill Monro
Bill Povey
Billy Preston
Bram Martin
Brian Jones
Buddhadev Kansara
Chris Thomas
Christopher Taylor
Clifford Seville
Colin Hanton
Cyril MacArthur
D Bradley
D Griffiths
Danny Moss
David Glyde
David Mason
David Mason and three others
David McCallum
David Sanderman
David Smith
David Wolfsthal
Dennis McConnell
Dennis Vigay
Dennis Walton
Derek Collins
Derek Jacobs
Derek Simpson
Derek Watkins
Dick Morgan
Don Honeywill
Don Lang
Donald Weekes
Duncan Campbell
Eddie Kramer
Eddie Thornton
Eldon Fox
Elgar Howarth
Eric Bowie
Eric Clapton
Eric Morecambe
Erich Gruenberg
Ernest Scott
Ernie Wise
Evan Watkins
F Dachtler
Francie Schwartz
Francisco Gabarro
Frank Clarke
Frank Reidy
Fred Lucas
Freddy Clayton
Frederick Alexander
G Mallen
Gary Leeds and more
Gayleen Pease
Geoff Emerick
George Harrison
George Martin
Gordon Lewin
Gordon Pearce
Graham Nash
Granville Jones
Greg Bowen
Gwynne Edwards
Hans Geiger
Hariprasad Chaurasia/SR Kenkare
Harold Jackson
Harry Klein
Harry Spain
Henry Datyner
Henry MacKenzie
Henry Myerscough
Hunter Davies
Ian Hamer
Ingrid Thomas
Irene King
J Fraser
J Power
J Smith
Jack Brymer
Jack Ellory
Jack Emblow
Jack Fallon
Jack Greene
Jack Holmes
Jack Richards
Jack Rothstein
Jackie Lomax
James W Buck
Jane Asher
Jeff Lynne
Jill Utting
Jim Chester
John Burden
John 'Duff' Lowe
John Hall
John Jezzard
John Lee
John Lennon
John Marston
John McCartney
John Meek
John O'Neill
John Ronayne
John Sharpe
John Underwood
John Wilbraham
Johnnie Scott
José Luis Garcia
Julien Gaillard
June Day
Jurgen Hess
Keith Cummings
Keith Moon
Keith Richards
Ken Barrie
Kenneth Essex
Kenny Powell
Leo Birnbaum
Leon Calvert
Les Condon
Les Maddox
Linda McCartney
Lionel Bentley
Lionel Ross
Lizzie Bravo
Lou Sofier
Louis Stevens
Mahapurush Misra
Mal Evans
Manny Winters
Marianne Faithfull
Marijke Koger
Michael Barnes
Mick Jagger
Mike McCartney
Mike Redway
Mike Vickers
Mike Winfield
Monty Montgomery
Morris Miller
N Fawcett
Natwar Soni
Neil Aspinall
Neil Sanders
Nicky Hopkins
Norman Jones
Norman Lederman
Norman Smith
Other musicians
P Goody
Pat Whitmore
Patrick Halling
Pattie Harrison
Paul Harvey
Paul McCartney
Paul Scherman
Peggie Allen
Personnel unknown; instruments include
Pete Best
Peter Beavan
Peter Coe
Peter Willison
Ralph Elman
Ray Swinfield
Raymond Brown
Raymond Newman
Raymond Premru
Reginald Kilbey
Rex Morris
Richard Taylor
Rij Ram Desad
Ringo Starr
Robert Burns
Roger Lord
Ronald Chamberlain
Ronald Thomas
Ronnie Hughes
Ronnie Ross
Ronnie Scott
Ross Gilmour
Roy Copestake
Sharad Ghosh/Hanuman Jadev
Sheila Bromberg
Sidney Sax
Stanley Reynolds
Stanley Roderick
Stanley Woods
Stephen Shingles
Stuart Sutcliffe
Sylvia King
T Moore
Ted Barker
Terry Doran
Terry Weil
Tom (surname unknown)
Tony Fisher
Tony Gilbert
Tony Randall
Tony Sheridan
Tony Tunstall
Trevor Williams
Tristan Fry
Uncredited
Unknown
Unknown musician
Val Stockwell
Various others
Victor Spinetti
Wendy Horan
Yoko Ono
including Maureen Starkey
unknown
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "%%sparql http://fuseki.cluster.gsi.dit.upm.es/sitc/\n", "\n",