ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

157
Semantic Web Languages and Standards (Primer) Aidan Hogan DERI Galway Session 1; Day 1; 10:30

description

 

Transcript of ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

Page 1: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

Semantic Web Languages

and Standards (Primer) Aidan Hogan — DERI Galway

Session 1; Day 1; 10:30

Page 2: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

2 24.05.2012

Page 3: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

3

WHAT IS THE SEMANTIC WEB?

24.05.2012

Page 4: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

4

The Semantic Web is Tim (et al.)’s Vision ?

24.05.2012

Page 5: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

5

The Semantic Web is intelligent machines

helping us make sense of the Web ?

24.05.2012

Page 6: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

6

The Semantic Web is naming everything ?

24.05.2012

Page 7: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

7

The Semantic Web is linking Web data ?

24.05.2012

Image by Cyganiak & Jentzsch ; http://lod-cloud.net

Page 8: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

8 24.05.2012

Image from http://www.digitaltimes.ie

The Semantic Web is breaking down the

data silos / walls ?

Page 9: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

9

The Semantic Web is Web 3.0 ?

24.05.2012

Image by Radar Networks; Nova Spivak; http://memebox.com/futureblogger/show/824

Page 10: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

10 24.05.2012

The Semantic Web is a stack of

technologies for interoperability?

Images by Hendler, Brickley Novack; http://www.bnode.org/blog/tag/layer%20cake

Page 11: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

11 24.05.2012

The Semantic Web is a bunch of standards

for interoperability?

Page 12: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

12 24.05.2012

The Semantic Web is something very very

bad and it must die (apparently) ?

Page 13: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

13 24.05.2012

The Semantic Web is a buzzword ?

Page 14: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

14 24.05.2012

The Semantic Web is…

… …cf. “What is the Web?”

Page 15: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

15

…WHAT IS THE SEMANTIC

WEB FOR?

24.05.2012

Page 16: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

16 24.05.2012

Web = Flood of information

= 5.9 TB of data

(Jan. 2010 Dump)

Page 17: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

17 24.05.2012

Web = Flood of information

= 235 TB of data indexed

= 40 Wikipedias

(incl. Web archive)

Page 18: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

18 24.05.2012

Web = Flood of information

= 12 TB/day added

= 2 Wikipedias / day

(as of Mar. 2010)

Page 19: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

19 24.05.2012

Web = Flood of information

= 20 PB/day processed

= 3,389 Wikipedias/day

(Jan. 2010)

Page 20: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

20 24.05.2012

Web = Flood of information

= 160 TB/s transferred

= 27 Wikipedias/second

(2008; Cisco)

Page 21: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

21 24.05.2012

From signals …

Page 22: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

22 24.05.2012

To binary …

…10010110…

Page 23: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

23 24.05.2012

To characters (ASCII/Unicode) …

…Hello World…

Page 24: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

24 24.05.2012

To document markup (HTML) …

<title>

Hello World

</title>

She’ll know what

to do with <title>

Ah yes, I

display this

at the top.

Page 25: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

25 24.05.2012

To data markup …

<time=“10:36”/>

She’ll know what <time> means

This is what my

user asked for.

Thanks!

Page 26: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

26 24.05.2012

To arbitrary information exchange ???

<aidan presents=

“session1” />

This is the data

I have. What’s an “aidan”?

Page 27: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

27 24.05.2012

Arbitrary data/information exchange …

We need …

Common data model for encoding data (triples)

Common ways of serialising data (syntaxes)

Well-defined languages for saying what terms mean (semantics)

Common ways to query data (query languages)

Web standards!

Make data machine-readable!

<aidan presents=

“session1” />

Page 28: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

28 24.05.2012

Syntax to semantics / terms to entities

<aidan presents=“session1”/>

Page 29: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

29

…WHEN DID THE SEMANTIC

WEB BEGIN?

24.05.2012

Page 30: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

30 24.05.2012

Started with the Web?

1990

Page 31: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

31

Pre-dating Web …

Tim Berners Lee ENQUIRE (1980)

Pre-dates Web by 10 years / Closer to Semantic Web than Web

Link cards (each card reflected an “entity”)

Different types of relations

Never made it out of CERN … Disk containing software “re-used”

Other works in Artificial Intelligence:

FOL / Logic Programming / Description Logics / Expert Systems

… Knowledge Representation

Frame languages / Semantic networks / Ontology

… Databases

Entity-Attribute-Value (EAV) model / Deductive databases / Conceptual +

Logical Schema

… Information Retrieval, Natural Language Processing, …

24.05.2012

Page 32: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

32

Modern Semantic Web …

24.05.2012

Image by Titti Cimmino; http://www.titticimmino.com/2009/12/31/the-future-internet-semantics-and-service-web-3-0-survey/

Page 33: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

33

…SO WHERE IS THIS

SEMANTIC WEB NOW?

24.05.2012

Image by Titti Cimmino; http://www.titticimmino.com/2009/12/31/the-future-internet-semantics-and-service-web-3-0-survey/

Page 34: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

34

Hidden within the Web?

24.05.2012

Page 35: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

35

Linked Open Data cloud

24.05.2012

Page 36: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

36

Open Government Data (US)

24.05.2012

http://data.gov/

Page 37: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

37

Open Government Data (UK)

24.05.2012

http://data.gov.uk/

Page 38: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

38

Semantics in HCLS/Biomedical Domain

24.05.2012

Page 39: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

39

Drupal 7 Core

24.05.2012

Page 40: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

40

Image from http://www.heppnetz.de/projects/goodrelations/primer/;; Hepp

GoodRelations for Products

Page 41: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

41

FaceBook’s Open Graph Protocol

24.05.2012

http://developers.facebook.com/tools/debug/

Page 42: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

42

schema.org

24.05.2012

http://schema.org

Page 43: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

43

BBC World Cup 2010 site

24.05.2012

Page 44: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

44

qwiki.com

24.05.2012

http://qwiki.com/

Page 45: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

45

Metaweb / Freebase

24.05.2012

http://freebase.com/

Page 46: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

46

Google’s Knowledge Graph

24.05.2012

http://google.com/ncr/

Page 47: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

47

Not there yet (but getting there…)

24.05.2012

Page 48: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

48

IT ALL BEGINS WITH RDF …

24.05.2012

Page 49: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

49

A brief history of RDF

Meta Content Framework (MCF) by Ramanathan V. Guha [1995]

Data-model consisting of Objects, Categories, and Properties

Directed, labelled graph

type / domain / range / superType / superPropertyType

XML syntax (based on XML names)

Resource Description Framework (RDF) by W3C [1999]

Spec. edited by Ora Lassila and Ralph R. Swick

Data-model consisting of Resources, Class, and Properties

Directed, labelled graph

Later extended to RDFS, including type / domain / range /

subClassOf / subPropertyOf

XML syntax (based on URIs)

RDF Revised by W3C [2004]

24.05.2012

Page 50: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

50

What is RDF (not)?

24.05.2012

Page 51: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

51

What is RDF?

24.05.2012

Page 52: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

52

What are triples?

24.05.2012

aidan presents session1

Page 53: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

53

RDF Triples: statements in slots of three

24.05.2012

SUBJECT PREDICATE OBJECT

aidan presents session1

aidan deri worksAt

aidan attending eswc2012

eswc2012

deri galway

crete

location

location

Page 54: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

54

Triples form a directed, labelled graph

24.05.2012

session1 aidan

eswc2012

deri

Galway

Crete

worksAt

attending

presents

location

location

livesIn

Page 55: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

55

Why triples? Simplest fixed-arity model …

24.05.2012

FROM TO

eswc2012

deri location

location

location galway

location crete

deri galway

(PAIRS)

Page 56: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

56

Naming in triples … avoid ambiguity

24.05.2012

aidan … …

Page 57: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

57

Avoid ambiguities: use URIs (/IRIs)!

24.05.2012

http://ex.org/#aidan … …

Page 58: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

58

Abbreviating URIs

Use “CURIEs” / namespaces

PREFIX ex: <http://ex.org/#>

ex:aidan = <http://ex.org/#aidan>

24.05.2012

Page 59: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

59

RDF Triples: literals in object position

24.05.2012

SUBJECT PREDICATE OBJECT

ex:session1 ex:title

“Semantic Web

Languages and

Standards”@en

ex:session1 ex:startTime “10:30:00+02:00”

^^xsd:time

ex:aidan ex:presents ex:session1

ex:aidan ex:gender “male”

URI | Literal | BNode URI URI | BNode

Page 60: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

60

Simple Literals

Simple strings:

“male”, “Hello World”, “aju901odksad”

24.05.2012

Page 61: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

61

Language-tagged Literals

Simple strings with specified language:

“Hello World”@en

“Bonjour tout le monde.”@fr

“Whilst I dreamt colourful dreams.”@en-GB

(Defined by RFC 3066, ISO 639-2)

24.05.2012

Page 62: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

62

Datatype Literals

Typed literals with mappings from strings to values

String (lexical value) / URI (type) pair

Many from XML Schema (namespace often given xsd: or xs: prefix) “true”^^xsd:boolean • “false”^^xsd:boolean

“1.0”^^xsd:decimal • “1”^^xsd:int • “1”^^xsd:byte

“2012-05-21”^^xsd:date • “2012-05-21T10:30:00Z”^^xsd:dateTime

“---15”^^xsd:gDay “--05-15”^^xsd:gMonthDay “2010”^^xsd:gYear

“Hello World”^^xsd:string (…and more besides)

Other datatypes defined elsewhere (rdf:XMLLiteral, owl:real)

Can define custom datatypes (e.g., dbt:usDollars)

“literal”^^xsd:string ≡ “literal”

Can’t mix datatypes and language tags (“Hello World”^^xsd:string@en)

24.05.2012

Page 63: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

63

RDF Literals: summary

24.05.2012

Simple Literals “string”

Lang-tag Literals “string”@en

Datatype Literals “string”^^xsd:string

Plain Literals

Page 64: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

64

RDF Triples: blank-nodes

24.05.2012

SUBJECT PREDICATE OBJECT

ex:session1 ex:venue _:somewhere

ex:kalamaki

ex:aidan ex:presents ex:session1

ex:aidan ex:gender “male”

URI | Literal | BNode URI URI | BNode

_:somewhere ex:location

Page 65: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

65

Blank Nodes

Often denoted with the prefix “_:”, and a label suffix

_:bnode4 • _:genid2 • _:venue

Can only be referenced in a local document!

Values of labels are inconsequential

Can consistently re-label blank nodes; makes no difference

Used:

to avoid creating a URI for something

for syntax shortcuts

if a value is unknown or not concretely identifiable

once-off resource (e.g., for time-of-access)

only allow local reference

etc.

24.05.2012

Page 66: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

66

Blank Nodes are existential (in theory)

Denote the existence of something ex:JohnFKennedy ex:assassin _:unknown .

Blank nodes can introduce redundancy (non-lean RDF)

24.05.2012

_:bnode1 ex:aidan

_:bnode2

ex:coauthoredPaper

“On Blank

Nodes”@en

ex:coauthoredPaper

ex:title

Page 67: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

67

Summary of RDF Triples

Slots of three: Subject, Predicate, Object

Used to make statements about the world

Subject: URIs or Blank Nodes

Predicate: URIs only

Object: URIs, Blank Nodes, Literals (plain [w/lang] or typed)

An RDF graph is a set of triples

24.05.2012

_:bnode1 ex:aidan

_:bnode2

ex:coauthoredPaper

“On Blank

Nodes”@en

ex:coauthoredPaper ex:title

(1) ex:aidan ex:coauthoredPaper _:bnode1

(2) _:bnode1 ex:title “On Blank Nodes”@en

(3) ex:aidan ex:coauthoredPaper _:bnode2

Page 68: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

68

Triples are everywhere!

24.05.2012

SUBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT

OBJECT …

Page 69: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

69

Triples are everywhere!

24.05.2012

SUBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT

Page 70: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

70

Triples are everywhere!

24.05.2012

SUBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT

SUBJECT

PREDICATE

OBJECT

PREDICATE

OBJECT … …

Page 71: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

71

What is RDF?

24.05.2012

Page 72: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

72

Features of RDF: typing / classes

24.05.2012

ex:aidan

ex:barry

ex:elena

ex:matthew

ex:dan

ex:denny

ex:Tutor

rdf:type

rdf:type rdf:type rdf:type

rdf:type rdf:type

Page 73: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

73

Features of RDF: containers (aka. lists)

ex:summerSchool ex:1stDaySchedule _:dayOne

_:dayOne rdf:first “Enrico’s Keynote”

_:dayOne rdf:rest _:dayOneB

_:dayOneB rdf:first “Session 1”

_:dayOneB rdf:rest _:dayOneC

_:dayOneC rdf:first “Session 2”

_:dayOneC rdf:rest _:dayOneD

_:dayOneD rdf:first “Hands On 1”

_:dayOneD rdf:rest rdf:nil

24.05.2012

listNode-1

listEl-1

rdf:first

listNode-2 rdf:rest

listEl-1

rdf:first

rdf:nil rdf:rest …

Page 74: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

74

Other features of RDF (not covered)

RDF containers

RDF reification

RDF n-ary predicates

Hint: if you’re using these features, you’re probably

doing it wrong

(unless you specifically know what you’re doing)

24.05.2012

Page 75: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

75

Writing RDF triples down?

24.05.2012

Page 76: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

76

RDF syntaxes / serialisation

24.05.2012

<http://ex.org/#aidan> … …

The bit between angle

brackets is a URI

Page 77: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

77

RDF syntaxes

N-Triples

Simple syntax for line-delimited triples

Turtle

Superset of N-Triples, with lots of nice shortcuts

Notation3 (N3)

Superset of Turtle and RDF (goes beyond RDF!)

RDF/XML

RDF syntax based on XML

RDFa

Syntax for embedding RDF directly into XHTML documents

24.05.2012

Page 78: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

78

N-Triples

24.05.2012

<http:/ex.org/#aidan> <http:/ns.com/worksAt> <http:/ex.org/#DERI> .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode1 .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode2 .

_:bnode2 <http://ns.com/title> “On Blank Nodes”@en .

_:bnode2 <http://ns.com/pages> “16”^^<http://w3.org/…#integer> .

Full URIs in ‘<>’angle

brackets

Blank nodes with ‘_:’

prefix

Terms delimited

by space or tab

Triples ended by ‘.’,

delimited by new line

Literals

enclosed

with quotes

Literals

enclosed

with quotes

Optional

lang-tag with ‘@’

Optional

datatype with ‘^^’

Page 79: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

79

Turtle (Terse RDF Triple Language)

24.05.2012

@base <http://ex.org/#> .

@prefix ns: <http://ns.com/> .

<aidan> ns:worksAt <DERI> ; ns:author _:bnode1 , _:bnode2 .

_:bnode2 ns:title “On Blank Nodes”@en ; ns:pages 16 .

<http:/ex.org/#aidan> <http:/ns.com/worksAt> <http:/ex.org/#DERI> .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode1 .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode2 .

_:bnode2 <http://ns.com/title> “On Blank Nodes”@en .

_:bnode2 <http://ns.com/pages> “16”^^<http://w3.org/…#integer> .

Re-usable

URI prefixes ‘;’ for

common

subject

‘,’ for common

subject & predicate

Expands to “16”^^xsd:integer

(Similar shortcuts for decimals, floating

points and booleans)

Rel. URIs

resolved

against base

Page 80: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

80

Turtle (Blank node abbreviation)

24.05.2012

@base <http://ex.org/#> .

@prefix ns: <http://ns.com/> .

<aidan> ns:worksAt <DERI> ; ns:author [] ,

[ ns:title “On Blank Nodes”@en ; ns:pages 16 ] .

<http:/ex.org/#aidan> <http:/ns.com/worksAt> <http:/ex.org/#DERI> .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode1 .

<http:/ex.org/#aidan> <http:/ns.com/author> _:bnode2 .

_:bnode2 <http://ns.com/title> “On Blank Nodes”@en .

_:bnode2 <http://ns.com/pages> “16”^^<http://w3.org/…#integer> .

Don’t have to label blank nodes.

(Labels are arbitrary anyways)

Can assign predicate–object information

to implicit blank node

Page 81: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

81

Turtle (RDF collection / list abbreviation)

24.05.2012

@base <http://ex.org/#> .

<summerSchool> <1stDaySchedule>

( “Enrico’s Keynote” “Session 1” “Session 2” “Hands-on 1” ) .

<http://ex.org/#summerSchool> <http://ex.org/#1stDaySchedule> _:dayOne .

_:dayOne <http://w3.org/…/22-rdf-syntax#first> “Enrico’s Keynote” .

_:dayOne <http://w3.org/…/22-rdf-syntax#rest> _:dayOneB .

_:dayOneB <http://w3.org/…/22-rdf-syntax#first> “Session 1” .

_:dayOneB <http://w3.org/…/22-rdf-syntax#rest> _:dayOneC .

_:dayOneC <http://w3.org/…/22-rdf-syntax#first> “Session 2” .

_:dayOneC <http://w3.org/…/22-rdf-syntax#rest> _:dayOneD .

_:dayOneD <http://w3.org/…/22-rdf-syntax#first> “Hands-on 1”

_:dayOneD <http://w3.org/…/22-rdf-syntax#first> <http://…/22-rdf-syntax#nil> .

Enclose list elements in

parentheses, and you’re done!

Page 82: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

82

Turtle (my favourite abbreviation)

24.05.2012

@base <http://ex.org/#> .

<aidan> a <Tutor> .

<http://ex.org/#aidan> <http://w3.org/…#type> <http://ex.org/#Tutor> .

‘a’ instead of rdf:type

(No need to declare rdf: prefix)

Page 83: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

83

Notation3 (N3) … a quick note

A superset of RDF

Contains non-RDF features like rules, scoping graphs, etc.

Intersection of N3 and RDF ≈ Turtle

24.05.2012

N3

Turtle

N-Triples

Page 84: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

84

RDF/XML overview

RDF syntax based on XML

RDF/XML and RDF often conflated:

RDF is a data-model based on triples

RDF/XML is a syntax to serialise triples

A very prominent syntax (dates back to 1999); used widely

Unfortunately, not a very nice syntax:

Difficult to see triple structure

Shortcuts are confusing

Relative name schemes are confusing

Not all RDF can be written as RDF/XML (due to limitations of XML names

for writing down predicates)

Not canonical: XML tools are useless

Just plain difficult to read/write/parse/learn, etc.

24.05.2012

Page 85: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

85

RDF/XML (…will not go into detail)

<rdf:Description rdf:about="http://…/TR/rdf-syntax-grammar">

<ex:editor>

<rdf:Description>

<ex:homePage rdf:resource="http://purl.org/net/dajobe/“ />

<ex:fullName>Dave Beckett</ex:fullName>

</rdf:Description>

</ex:editor>

<dc:title>RDF/XML Syntax Specification (Revised)</dc:title>

</rdf:Description>

24.05.2012

Image from http://www.w3.org/TR/REC-rdf-syntax/;; Beckett

Page 86: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

86

RDFa overview

RDFa allows for embedding RDF into XHTML

Mix human readable and machine readable

No need for separate docs!

Less server costs simpler hosting

Becoming more and more prominent (rec. since 2008)

24.05.2012

Page 87: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

87

RDFa (…will not go into detail)

<div typeof="foaf:Person" xmlns:foaf="http://xmlns.com/foaf/0.1/">

<p property="foaf:name">Alice Birpemswick</p>

<p> Email: <a rel="foaf:mbox"

href="mailto:[email protected]">[email protected]</a> </p>

<p> Phone: <a rel="foaf:phone" href="tel:+1-617-555-7332">+1

617.555.7332</a> </p>

</div>

24.05.2012

Image from http://www.w3.org/TR/xhtml-rdfa-primer/;; Adida & Birbeck

Page 88: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

88

THAT’S RDF …

… NEXT UP…

24.05.2012

Page 89: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

89

RDFS and OWL! RDF Schema

Web Ontology Language

W3C Recommendations, 2004

OWL 2 since 2009

Standardised schema/ontology languages

Can be serialised in RDF

OWL (partly) extends RDFS

Page 90: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

90

Features walkthrough…

…modelling family relationships in RDFS and OWL…

Page 91: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

91

A Family-Relations OWL Ontology

ex:Carmela ex:Vito

ex:Sonny ex:Connie ex:Fredo ex:Michael

ex:Vincent ex:Mary

Page 92: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

92

RDFS 1. rdfs:subPropertyOf

2. rdfs:subClassOf

3. rdfs:domain

4. rdfs:range

Page 93: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

93

rdfs:subPropertyOf

ex:Carmela ex:Vito

:husbandOf

:wifeOf

:spouse

:spouse

ex:Vito :husbandOf ex:Carmela .

:husbandOf rdfs:subPropertyOf :spouse .

⇒ ex:Vito :spouse ex:Carmela .

ex:Carmela :wifeOf ex:Vito .

:wifeOf rdfs:subPropertyOf :spouse .

⇒ ex:Carmela :spouse ex:Vito .

Page 94: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

94

rdfs:subClassOf

ex:Mary

rdf:type

rdf:type

ex:Mary rdf:type :Woman .

:Woman rdfs:subClassOf :Person .

⇒ ex:Mary rdf:type :Person .

:Woman

:Person

Page 95: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

95

rdfs:domain

ex:Carmela

:motherOf

ex:Carmela :motherOf ex:Fredo .

:motherOf rdfs:domain :Woman .

⇒ ex:Carmela rdf:type :Woman .

ex:Fredo

:Woman

rdf:type

Page 96: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

96

rdfs:range

ex:Carmela

:hasSon

ex:Carmela :hasSon ex:Fredo .

:hasSon rdfs:range :Man .

⇒ ex:Fredo rdf:type :Man .

ex:Fredo

:Man

rdf:type

Page 97: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

97

Recap RDFS

What would be the rdfs:domain of the property :fatherOf?

What would be the rdfs:range of the property :wifeOf?

Page 98: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

98

RDFS 1. rdfs:subPropertyOf

2. rdfs:subClassOf

3. rdfs:domain

4. rdfs:range

OWL 1. Property Axioms

a. owl:equivalentProperty

b. owl:inverseOf

c. owl:SymmetricProperty

d. owl:TransitiveProperty

e. owl:propertyChainAxiom

Page 99: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

99

owl:equivalentProperty

ex:Vito :parentOf ex:Michael .

ex:Michael :hasChild ex:Mary .

:parentOf owl:equivalentProperty :hasChild .

⇒ ex:Vito :hasChild ex:Vincent .

⇒ ex:Michael :parentOf ex:Mary .

ex:Vito ex:Mary ex:Michael

:parentOf :hasChild

:hasChild :parentOf

Page 100: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

100

owl:inverseOf

ex:Carmela :parentOf ex:Sonny .

ex:Vincent :childOf ex:Sonny .

:parentOf owl:inverseOf :childOf .

⇒ ex:Sonny :parentOf ex:Vincent .

⇒ ex:Sonny :childOf ex:Carmela .

ex:Vincent ex:Sonny

:parentOf :childOf

:parentOf

ex:Carmela

:childOf

Page 101: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

101

owl:SymmetricProperty

ex:Connie

:sibling

ex:Connie :sibling ex:Fredo .

:sibling rdf:type owl:SymmetricProperty .

⇒ ex:Fredo :sibling ex:Connie .

:sibling

ex:Fredo

Page 102: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

102

ex:Carmela

owl:TransitiveProperty

ex:Carmela :ancestorOf ex:Michael .

ex:Michael :ancestorOf ex:Mary .

:ancestorOf rdf:type owl:TransitiveProperty .

⇒ ex:Carmela :ancestorOf ex:Mary .

ex:Mary ex:Michael

:ancestorOf :ancestorOf

:ancestorOf

Page 103: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

103

ex:Sonny

owl:propertyChainAxiom

ex:Sonny :brotherOf ex:Michael .

ex:Michael :fatherOf ex:Mary .

:uncleOf owl:propertyChainAxiom (:brotherOf :fatherOf) .

⇒ ex:Sonny :uncleOf ex:Mary .

ex:Mary ex:Michael

:brotherOf :fatherOf

uncleOf

2

Page 104: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

104

Recap OWL property axioms

What would be the owl:inverseOf of the property :fatherOf?

Name an owl:SymmetricProperty to do with family relations?

Name an owl:TransitiveProperty to do with family relations?

Give a owl:propertyChainAxiom for hasNiece?

Page 105: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

105

RDFS 1. rdfs:subPropertyOf

2. rdfs:subClassOf

3. rdfs:domain

4. rdfs:range

OWL 1. Property Axioms

2. Equality

a. owl:sameAs

b. owl:FunctionalProperty

c. owl:InverseFunctionalProperty

Page 106: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

106

ex:Vito_young

owl:sameAs

ex:Vito_old

owl:sameAs

ex:Vito_old owl:sameAs ex:Vito_young .

owl:sameAs

Vito

ex:Mary ex:Vincent

:hasGrandson :granddaugtherOf :hasGrandson :granddaugtherOf

Page 107: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

107

ex:Vito_young ex:Vito

owl:FunctionalProperty

ex:Vito_old

ex:Fredo :hasFather ex:Vito_old .

ex:Fredo :hasFather ex:Vito_young .

:hasFather rdf:type owl:FunctionalProperty .

⇒ ex:Vito_old owl:sameAs ex:Vito_young .

ex:Fredo

:hasFather

Page 108: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

108

ex:Vito ex:Vito_young ex:Connie

owl:InverseFunctionalProperty

ex:Vito_old

ex:Vito_old :fatherOf ex:Connie .

ex:Vito_young :fatherOf ex:Connie .

:fatherOf rdf:type

owl:InverseFunctionalProperty .

⇒ ex:Vito_old owl:sameAs ex:Vito_young .

:fatherOf

Page 109: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

109

Recap OWL equality axioms

Name an owl:FunctionalProperty to do with family relations?

Name a similar owl:InverseFunctionalProperty?

Page 110: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

110

RDFS 1. rdfs:subPropertyOf

2. rdfs:subClassOf

3. rdfs:domain

4. rdfs:range

OWL 1. Property Axioms

2. Equality

3. Class Axioms a. owl:unionOf

b. owl:intersectionOf

c. owl:oneOf

d. owl:allValuesFrom

e. owl:someValuesFrom

Page 111: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

111

owl:unionOf

:Woman :Person :Man

ex:Vincent rdf:type :Man .

:Person owl:equivalentClass [ owl:unionOf (:Woman :Man) ]

⇒ ex:Vincent rdf:type :Person .

ex:Vincent

type type

Page 112: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

112

:Parent

⊓ :Mother

owl:intersectionOf (i)

:Woman

ex:Carmela

rdf:type rdf:type

ex:Carmela rdf:type :Mother .

:Mother rdfs:subClassOf [ owl:intersectionOf (:Woman :Parent) ]

⇒ ex:Carmela rdf:type :Woman , :Parent .

rdf:type

Page 113: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

113

ex:Parent

owl:intersectionOf (ii)

ex:Woman

ex:Carmela

rdf:type rdf:type rdf:type

ex:Carmela rdf:type :Woman , :Parent .

:Mother owl:equivalentClass [ owl:intersectionOf (:Woman :Parent) ]

⇒ ex:Carmela rdf:type :Mother .

ex:Mother

≡ ⊓

Page 114: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

114

,

owl:oneOf

{

:DonCorleone owl:equivalentClass

[ owl:oneOf (ex:Vito ex:Michael ex:Vincent) ]

⇒ ex:Vito rdf:type :DonCorleone .

⇒ ex:Michael rdf:type :DonCorleone .

⇒ ex:Vincent rdf:type :DonCorleone .

:DonCorleone

} ex:Vito ex:Michael ex:Vincent ,

rdf:type rdf:type rdf:type

Page 115: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

115

owl:disjointWith

ex:Michael rdf:type ex:DonCorleone .

ex:DonCorleone owl:disjointWith ex:LawAbiding .

ex:Michael rdf:type ex:LawAbiding .

ex:DonCorleone

ex:Vincent

rdf:type

≡ ⊓ ex:LawAbiding

┴ owl:Nothing

rdf:type

Page 116: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

116

owl:allValuesFrom

:Person

ex:Mary rdf:type :Person ; hasParent ex:Michael .

:Person rdfs:subClassOf

[ owl:allValuesFrom :Person ; owl:onProperty :hasParent ]

⇒ ex:Michael rdf:type :Person .

rdf:type

:Person

:hasParent .

ex:Michael ex:Mary

:hasParent

rdf:type

Page 117: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

117

owl:someValuesFrom (i)

ex:Mary :hasChild ex:Michael . ex:Michael rdf:type :Person .

:Parent owl:equivalentClass

[ owl:someValuesFrom :Person ; owl:onProperty :hasChild ]

⇒ ex:Mary rdf:type :Parent .

rdf:type

:Person

:hasChild .

ex:Michael

:hasChild

rdf:type

ex:Carmela

:Parent

Page 118: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

118

?

owl:someValuesFrom (ii)

ex:Mary rdf:type :Parent .

:Parent rdfs:subClassOf

[ owl:someValuesFrom :Person ; owl:onProperty :hasChild ]

⇒ ex:Mary :hasChild _:someone . _:someone rdf:type :Person .

:Person

:hasChild .

?

:hasChild

rdf:type

ex:Carmela

:Parent

⊑ rdf:type

Page 119: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

119

Recap OWL class axioms

A class :Parent might be the owl:unionOf what classes?

A class :OnlySon might be the owl:intersectionOf what

classes?

What OWL feature allows to define enumerations?

An example of owl:allValuesFrom for family relations?

An example of owl:someValuesFrom for the class :Uncle?

Page 120: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

120

RDFS 1. rdfs:subPropertyOf

2. rdfs:subClassOf

3. rdfs:domain

4. rdfs:range

OWL 1. Property Axioms

2. Equality

3. Class Axioms

Page 121: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

121

1. owl:hasKey

2. owl:hasValue

3. owl:cardinality(s)

4. owl:different

5. owl:AssymetricProperty

6. owl:IrreflexiveProperty

7. owl:propertyDisjointWith

8. …

…some OWL features not covered:

Page 122: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

122

But what does it all mean?

Page 123: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

123

RDFS History

Dan Brickley & R. V. Guha [2000]

Pat Hayes [2004]

Page 124: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

124

RDF(S) Semantics

Built directly on top of RDF (Semantics)

Given a mathematical model-theoretic semantics

http://ex.org/#aidan … …

Page 125: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

125

RDF(S) Semantics: existential blank nodes

Called “simple entailment”

24.05.2012

_:bnode1 ex:aidan

_:bnode2

ex:coauthoredPaper

“On Blank

Nodes”@en

ex:coauthoredPaper

ex:title

Page 126: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

126

?c1 rdfs:subClassOf ?c2 .

?x rdf:type ?c1 .

⇒ ?x rdf:type ?c2 .

ex:Tutor rdfs:subClassOf ex:Person .

ex:aidan rdf:type ex:Tutor .

⇒ ex:aidan rdf:type ex:Person .

24.05.2012

IF ⇒ THEN

Body/Antecedent/Condition Head/Consequent

RDFS Semantics: RDFS rules / reasoning

Page 127: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

127

OWL History

Description Logics [1980’s to now]

DAML (Hendler, McGuinness) [2000]

OIL (Fensel, van Harmelen, McGuinness, Patel-, Frank van

Harmelen) [2001]

DAML+OIL [2002]

OWL (W3C Rec.) [2004]

OWL 2 (W3C Rec.) [2008]

Page 128: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

128

OWL Semantics

Much more complex language = Much more complex semantics

24.05.2012

Parent ⊑

∃hasChild.Person

:Parent rdfs:subClassOf

[ owl:someValuesFrom :Person

; owl:onProperty :hasChild ]

Considers Axioms: Considers Triples:

Restricted so that triples

correspond to axioms Unrestricted

Decidable for OWL 2 DL

(but super-exponential) Undecidable

Page 129: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

129

OWL Profiles

24.05.2012

OWL 2 EL

OWL 2 QL

OWL 2 RL

RDFS*

pD*

P

Simple

RDF

RDFS

NP-complete ExpTime

OWL Lite

NExpTime

OWL DL

2NExpTime Undecidable

OWL 2 DL OWL Full

OWL 2 Full

Page 130: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

130

THAT’S RDFS/OWL …

… NEXT UP…

24.05.2012

Page 131: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

131

How can we query RDF?

…RDB has SQL…

…XML has XPath & XQuery…

…RDF has ?

Page 132: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

132

SPARQL! SPARQL Protocol and RDF Query Language

W3C Recommendation, 2008

SPARQL 1.1 upcoming, 201?

Standardised RDF query language (and supporting recommendations)

Looks a little like SQL

Syntax based on Turtle

Page 133: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

133

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

QUERY CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

; foaf:familyName ?surname .

Page 134: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

134

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

QUERY CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

Page 135: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

135

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

Prefix Declarations

foaf:Person ⇔ <http://xmlns.com/foaf/0.1/Person>

Use http://prefix.cc/ …

PREFIX DECLARATIONS

Page 136: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

136

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

QUERY CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

Page 137: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

137

SELECT ?name ?expertise

Result Clause

1. SELECT

2. CONSTRUCT (RDF)

3. ASK

4. DESCRIBE (RDF)

RESULT CLAUSE

Page 138: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

138

Return all tuples for the bindings of the variables

?name and ?expertise

-----------------------------------------------------------

| “Professor Robert Allen” | “Control engineering” |

| “Professor Robert Allen” | “Biomedical engineering” |

| “Prof Carl Leonetto Amos” | |

| “Professor Peter Ashburn” | “Silicon technology” |

| “Professor Robert Allen” | “Control engineering” |

-----------------------------------------------------------

Result Clause 1. SELECT…

SELECT ?name ?expertise RESULT CLAUSE

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

Page 139: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

139

Return all tuples for the bindings of the variables

?name and ?expertise

-----------------------------------------------------------

| “Professor Robert Allen” | “Control engineering” |

| “Professor Robert Allen” | “Biomedical engineering” |

| “Prof Carl Leonetto Amos” | |

| “Professor Peter Ashburn” | “Silicon technology” |

| “Professor Robert Allen” | “Control engineering” |

-----------------------------------------------------------

?name ?expertise

SELECT

Result Clause 1. SELECT DISTINCT…

DISTINCT

unique

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

Page 140: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

140

CONSTRUCT {

?person foaf:name ?name ; ex:expertise ?expertise .

}

Return RDF using bindings for the variables:

ex:RAllen foaf:name “Professor Robert Allen” ;

ex:expertise “Biomedical engineering” ,

“Control engineering” .

ex:PAshburn foaf:name “Peter Ashburn ” ;

ex:expertise “Silicon technology” .

Result Clause 2. CONSTRUCT…

RESULT CLAUSE

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

Page 141: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

141

ASK

… WHERE { … }

Is there any results?

Returns:

true or false

Result Clause 3. ASK…

RESULT CLAUSE

Page 142: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

142

DESCRIBE ?person

… WHERE { ?person … }

Returns some RDF which “describes” the given resource…

No standard for what to return!

Typically returns:

Result Clause 4. DESCRIBE…

RESULT CLAUSE

all triples where the given resource appears as subject and/or object

OR

Concise Bounded Descriptions…

Page 143: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

143

DESCRIBE ex:RAllen

(…can give URIs directly without need for a WHERE clause.)

Result Clause 4. DESCRIBE (DIRECT)…

RESULT CLAUSE

Page 144: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

144

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

QUERY CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

Page 145: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

145

FROM <http://data.southampton.ac.uk/>

Dataset clause (FROM/FROM NAMED)

DATASET CLAUSE

(Briefly)

Restrict the dataset against which you wish to query

SPARQL stores named graphs: sets of triples which are associated

with (URI) names

Can match across graphs!

Named graphs typically corrrespond with data provenance (i.e.,

documents)!

Default graph typically corresponds to the merge of all graphs

Many engines will typically dereference a graph if not available locally!

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

Page 146: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

146

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

} QUERY CLAUSE

Page 147: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

147

foaf:Person

foaf:name?person ?name

rdf:type

foaf:title

?titleoo:availableToCommentOn

?expertiseURI rdfs:label ?expertise

[FILTER “^Prof”]

foaf:familyName

?surname

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

Query clause (WHERE)

QUERY CLAUSE

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

“Professor Peter Ashburn”

“Silicon technology”

“Professor”

✓ ex:PAshburn

ex:Silicon

“Ashburn”

Page 148: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

148

WHERE {

… {?person oo:availableToCommentOn ?expertiseURI . }

UNION

{?person foaf:interest ?expertiseURI . }

… }

Quick mention for UNION

QUERY CLAUSE

Represent disjunction (OR)

Useful when there’s more than one property/class that represents the

same information you’re interested in (heterogenity)

Reasoning can also help, assuming terms are mapped (more later)

Page 149: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

149

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM NAMED <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

The anatomy of a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

QUERY CLAUSE

Page 150: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

150

ORDER BY ?surname

Solution Modifiers

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

SOLUTION MODIFIERS

Order output results by surname (as you probably guessed)

LIMIT

OFFSET

ORDER BY ?surname LIMIT 10

SOLUTION MODIFIERS

ORDER BY ?surname LIMIT 10 OFFSET 20

SOLUTION MODIFIERS

Only return 10 results

Return results 20‒30

…also…

Page 151: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

151

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, "^Prof")

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

PREFIX DECLARATIONS

RESULT CLAUSE

QUERY CLAUSE

SOLUTION MODIFIERS

DATASET CLAUSE

What are you looking for?

Which results do you want?

Where should we look?

How should results be ordered/split?

Shortcuts for URIs

The summary of a typical SPARQL query

Page 152: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

152

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

PREFIX oo: <http://purl.org/openorg/>

SELECT ?name ?expertise

FROM <http://data.southampton.ac.uk/>

WHERE {

?person foaf:name ?name ; foaf:familyName ?surname .

?person rdf:type foaf:Person .

?person foaf:title ?title . FILTER regex(?title, “^Prof”)

OPTIONAL {

?person oo:availableToCommentOn ?expertiseURI .

?expertiseURI rdfs:label ?expertise

}

}

ORDER BY ?surname

Trying out a typical SPARQL query

Give me a list of names of professors in Southampton

and their expertise (if available), in order of their surname

; foaf:familyName ?surname .

Page 153: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

153

SPARQL in the wild

See http://www.w3.org/wiki/SparqlEndpoints

66% of LD datasets have a SPARQL endpoint

35% offer an RDF dump

Page 155: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

155

SPARQL Extension Coming Soon!

SPARQL 1.1. W3C Working Draft (2012)

New query features:

Property-chains

?s ex:father+ ?o .

Arithemetic

BIND ( ?weight / (?height * ?height) AS ?bmi)

Aggregates

SELECT AVG(?age) as ?avgAge

Sub-queries, exists/not-exists, bindings, etc.

SPARQL 1.1 Federation

SPARQL 1.1 Update

SPARQL 1.1 Entailment

24.05.2012

Page 156: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

156

AND MORE BESIDES …

24.05.2012

Page 157: ESWC SS 2012 - Monday Tutorial 1 Aidan Hogan: Semantic Web Languages and Standards (Primer)

157

SO, WHAT IS THE SEMANTIC

WEB?

24.05.2012