86
The Semantic Web “Turns Ten” 11.11.2011, Milano Emanuele Della Valle http://emanueledellavalle.org

The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Embed Size (px)

Citation preview

Page 1: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

The Semantic Web “Turns Ten”11.11.2011, Milano

Emanuele Della Valle

http://emanueledellavalle.org

Page 2: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Share, Remix, Reuse — Legally

This work is licensed under the Creative Commons Attribution 3.0 Unported License.

Your are free:

• to Share — to copy, distribute and transmit the work

• to Remix — to adapt the work

Under the following conditions

• Attribution — You must attribute the work by inserting– “© applied-semantic-web.org” at the end of each slide– a credits slide stating

- These slides are partially based on “The Semantic Web “Turns Ten” by Emanuele Della Valle http://applied-semantic-web.org/slides/2011/11/SemanticWebTurns10.ppt

To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/

2

Page 3: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Agenda

Introduction and Motivation

Data Interchange on the Web: RDF

Querying the Semantic Web: SPARQL

Modelling data and knowledge for the Semantic Web: RDF-S and OWL

Conclusions

3

Page 4: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

The Web Today

Large number of integrations - ad hoc - pair-wise

Too much information to browse, need for searching and mashing up automatically

Each site is “understandable” for us

Computers don’t “understand” much

?

Search & Mash-up Engine

010 0 1 1 0

01101

10100 10 0010 01 101 101 01 110 1 10 110 0 1 1 01 0 1 0 0 1 1 0 1 1 1 10 01 101 0 1

Millions of Applications

Page 5: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

The Problem: “Semantic Gap”

Sensor Data

Semantic Gap

Symbolic DescriptionMissing building

No existing streets

Page 6: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

“Understanding” Means Bridging the Gap 6

understanding

Sensor Data

Symbolic Description

Page 7: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

Do We Really Know What “Understanding” Means? 7

[ source http://www.thefarside.com/ ]

Page 8: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

Two ways for computer to “understand”

Smart Machine

Smart Data

8

Page 9: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

Smart Machines

Working examples found on the Web• Image Processing

– retrievr: find by sketching

http://labs.systemone.at/retrievr/

• Audio Processing– midomi: find by singing

http://www.midomi.com/

• […]

• Natural Language Processing– semantic proxy:

http://semanticproxy.opencalais.com/about.html

Sensor Data

Symbolic Description

Ima

ge

Pro

ces

sin

g

Au

dio

Pro

ces

sin

g

Na

tura

l La

ng

ua

ge

Pro

ces

sin

g

[…]

Page 10: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

Smart Machines alone cannot bridge the gap …

Natural Language Processing (NLP) meets Image Processing (IP)

NLP : What does your eye see?IP : I see a seaNLP : You see a “c”?IP : Yes, what else could it be?

[Source NLP Related Entertainment http://www.cl.cam.ac.uk/Research/NL/amusement.html]

Sensor Data

Symbolic Description

Ima

ge

Pro

ces

sin

g

Na

tura

l L

ang

uag

e

Pro

ces

sin

g

sea “c”

Semantic Gap

Page 11: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

… smart data are need

11

Sensor Data

Symbolic Description

Ima

ge

Pro

ces

sin

g

Na

tura

l L

ang

uag

e

Pro

ces

sin

g

sea “c”

smart data

Natural Language Processing (NLP) meets Image Processing (IP)

NLP: What does your eye see?IP : I see a wordnet:word-sea NLP: mmm, I see a wordnet:word-c IP : I believe we have different understanding of the world …NLP: So do I

The Semantic Web offers a

set of standards that

lowers the barriers to

employ smart data at large scale

Page 12: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

What a machine “understands” of the Web

What we say to Web agents

" For more information visit <a href=“http://www.ex.org”> my company </a> Web site. . .”

What they “hear” " blah blah blah blah blah <a

href=“http://www.ex.org”> blah blah blah </a> blah blah. . .”

Jet this is enought to train them to achive tasks for us

[ source http://www.thefarside.com/ ]

Page 13: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction

What does Google “understand”?

Understanding that• [page1] links [page2] page2 is interesting

Google is able to rank results!• “The heart of our software is PageRank™, a system for

ranking web pages […] (that) relies on the uniquely democratic nature of the web by using its vast link structure as an indicator of an individual page's value.”

http://www.google.com/technology/

13

Page 14: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction The Semantic Web 1/4

“The Semantic Web is not a separate Web, but an extension of the current one, in which information is given well-defined meaning, better enabling computers and people to work in cooperation.”

“The Semantic Web”, Scientific American Magazine, Maggio 2001 http://www.sciam.com/article.cfm?articleID=00048144-10D2-1C70-84A9809EC588EF21

Key concepts• an extension of the current Web• in which information is given well-defined meaning • better enabling computers and people to work in

cooperation.– Both for computers and people

Page 15: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction The Semantic Web 2/4

“The Semantic Web is not a separate Web, but an extension of the current one […] ”

15

Web 1.0 The Web Today

Page 16: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction The Semantic Web 3/4

“The Semantic Web […] , in which information is given well-defined meaning […]”

16

Human understandable but “only” machine-

readable

Human and machine

“understandable”

?

Web 1.0 Semantic Web

Page 17: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction The Semantic Web 4/4 17

Semantic Web

Fewer Integration - standard - multi-lateral

[…] better enabling computers and

people to work in cooperation.

Even More Applications

Easier to understand for people

More “understandable” for computers

Semantic Mash-ups &Search

Page 18: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Linked Data Standards 18

WebMGS 2010, 27.8.2010

View the full talk at http://www.ted.com/talks/view/id/484 !

Page 19: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Linking Open Data Project

Goal: extend the Web with data commons by publishing open data sets using Semantic Web techs

19

Visit http://esw.w3.org/topic/SweoIG/TaskForces/CommunityProjects/LinkingOpenData !

Page 20: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Example: BIO2RDF 20

Peter Ansell, Model and prototype for querying multiple linked scientific datasets, Future Generation Computer Systems, Volume 27, Issue 3, March 2011, Pages 329-333

Page 21: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction data.gov and data.gov.uk 21

[source: J. Hendler WIMS’11 Key Note – http://wims.vestforsk.no/slides/jimhendler.pdf ]

Page 22: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction http://www.data.gov/opendatasites/ 22

And a growing number of

apps is appearing :-)

•http://explore.data.gov/cata

log/apps/

•http://data.gov.uk/apps

Page 23: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: BBC’s Artist as Linked Data

<?xml version="1.0" encoding="utf-8"?> <rdf:RDF xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs = "http://www.w3.org/2000/01/rdf-schema#" xmlns:owl = "http://www.w3.org/2002/07/owl#" xmlns:dc = "http://purl.org/dc/elements/1.1/" xmlns:foaf = "http://xmlns.com/foaf/0.1/" xmlns:rel = "http://www.perceive.net/schemas/relationship/" xmlns:mo = "http://purl.org/ontology/mo/" xmlns:rev = "http://purl.org/stuff/rev#" > <rdf:Description rdf:about="/music/artists/a3cb23fc-acd3-4ce0-

8f36-1e5aa6a18432.rdf"> <rdfs:label>Description of the artist U2</rdfs:label> <foaf:primaryTopic rdf:resource="/music/artists/a3cb23fc-acd3-

4ce0-8f36-1e5aa6a18432#artist"/> </rdf:Description> <mo:MusicGroup rdf:about="/music/artists/a3cb23fc-acd3-4ce0-

8f36-1e5aa6a18432#artist"> <foaf:name>U2</foaf:name> <owl:sameAs rdf:resource="http://dbpedia.org/resource/U2" /> <foaf:page rdf:resource="/music/artists/a3cb23fc-acd3-4ce0-8f36-

1e5aa6a18432.html" /> <mo:musicbrainz

rdf:resource="http://musicbrainz.org/artist/a3cb23fc-acd3-4ce0-8f36-1e5aa6a18432.html" />

<mo:homepage rdf:resource="http://www.u2.com/" /> <mo:fanpage rdf:resource="http://www.atu2.com/" /> <mo:wikipedia rdf:resource="http://en.wikipedia.org/wiki/U2" /> <mo:imdb

rdf:resource="http://www.imdb.com/name/nm1277752/" /> <mo:myspace rdf:resource="http://www.myspace.com/u2" /> <mo:member rdf:resource="/music/artists/7f347782-eb14-40c3-

98e2-17b6e1bfe56c#artist" /> <mo:member rdf:resource="/music/artists/1f52af22-0207-40ac-

9a15-e5052bb670c2#artist" />

23

HTML: http://www.bbc.co.uk/music/artists/a3cb23fc-acd3-4ce0-8f36-1e5aa6a18432

RDF : http://www.bbc.co.uk/music/artists/a3cb23fc-acd3-4ce0-8f36-1e5aa6a18432.rdf

Page 24: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: Best Buy

Since Fall 2009

450.00 products

Using RDFa (= embedded in HTML)

Pages with RDFa higher in Google ranking

BestBuy claims 30% more traffic!

Yahoo reports 15% higher click-through rat

24

Page 25: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: Best Buy - example 25

<div rel="v:hasReview">

<span property="v:rating" datatype="xsd:string"> 4.8</span> of <span property="v:best">5</span>

<div rel="v:hasReview">

<span property="v:rating" datatype="xsd:string"> 4.8</span> of <span property="v:best">5</span>

RDFa

Page 26: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: Best Buy – SEO on Google

https://www.google.com/search?q=Nikon+12.3-Megapixel+Digital+SLR+Camera

26

Sponsored Links

Page 27: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: Facebook Open Graph 1/2

Use RDFA with some FB specific vocabulary• og:title - The title of your object, e.g., "The Rock".• og:type - The type of your object, e.g., "movie". • og:image - An image URL • og:url - The permanent ID of your object • og:description - A one to two sentence description of

your object.• og:site_name - If your object is part of a larger web site,

the name which should be displayed for the overall site. e.g., "IMDb".

27

Page 28: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Industrial Uptake: Open Graph Usage Statistics

100.000 sites are using Open Graph!

28

[Source: http://trends.builtwith.com/docinfo/Open-Graph-Protocol]

Page 29: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Introduction Semantic Web “layer cake” 29

Standardized

UnderInvestigation

Already Possible

[ source http://www.w3.org/2007/03/layerCake.png ]

Page 30: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Data Interchange: RDF 30

Page 31: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Looking for a flexible data model

Why• Application are always changing

(competitive environment) • People are always adding more features• Graceful evolution is important

Optimal: relational model• Relational model is remarkably flexible• Supports graceful evolution

– Change => Add another table– Existing queries are unaffected

• Easily accommodates new data – Without affecting existing queries

• Allows data to be easily combined ("joined") in new ways• 25+ years of relational database experience

- 31 -

© 2001-2005 E. Della Valle - CEFRIEL

Page 32: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Resource Description Framework

The adaptation of the relational model to the Web give rise to RDF

From T-tuples to Triples

Any relational data can be represented as triples• Row Key --> Subject• Column --> Property• Value --> Value

32

Page 33: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Representing relational data in RDF (almost)

E.g., geographical data

Represented in RDF (almost)

33

City Country Population

IT.2 Italy 1.298.972

City Name

IT.2 Milano

IT.2 Milan

IT.2 Mailand

IT.2

Italy 1.298.972 Milano Milan Mailand

CountryPopulation

Is a City

Legend

resource

literal

Name

Page 34: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Representing relational data in RDF (almost)

Two important problems• Once out of the database internal ID (e.g., IT.2) becomes

useless• Once out of the database internal names of schema

element (e.g., City) becomes useless as well

RDF solves it by using URI• Internal ID should be replaced by URI• Internal schema names should be replaced by URI• Values do (always) not need to be URI-fied

34

http://sws.geonames.org/3173435/

http://www.geonames.org/countries/#IT

1.298.972

Milano Milan Mailand

http://www.geonames.org/ontology#inCountry

http://www.geonames.org/ontology#population

http://www.w3.org/2000/01/rdf-schema#label

http://www.geonames.org/ontology#P

http://www.w3.org/1999/02/22-rdf-syntax-ns#type

Legend

resource

literal

Page 35: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Which URI should we use?• Popular ones! Data merge will take place automatically!

RDF in a nutshell

Representing data in RDF Q/A 1/4 35

http://sws.geonames.org/3173435/

http://www.geonames.org/countries/#IT

http://www.geonames.org/ontology#inCountry

+http://sws.geonames.org/3173435/

20100

http://dbpedia.org/resource/Postalcode

http://sws.geonames.org/3173435/

http://www.geonames.org/countries/#IT

http://www.geonames.org/ontology#inCountry

=

20100

http://dbpedia.org/resource/Postalcode

Page 36: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Where do I find popular URIs?• A difficult question with no clear answer• The best place to keep an eye on is

– the Linking Open Data Project http://esw.w3.org/topic/SweoIG/TaskForces/CommunityProjects/LinkingOpenData

– and in particular the following pages of the Wiki- Data Sets

http://esw.w3.org/topic/TaskForces/CommunityProjects/LinkingOpenData/DataSets

- Semantic Web Search Engines http://esw.w3.org/topic/TaskForces/CommunityProjects/LinkingOpenData/SemanticWebSearchEngines

- Common Vocabularies http://esw.w3.org/topic/TaskForces/CommunityProjects/LinkingOpenData/CommonVocabularies

RDF in a nutshell

Representing data in RDF Q/A 2/4 36

Page 37: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

What is a value? When shall we URI-fy a value? • Literals cannot be used to merge different data set• E.g., having chosen to represent postal codes as a

string, merging different data sets using postal codes is impossible

– 20100 may refer to lots of different thing on the Webe.g., try http://images.google.com/images?q=20100

• URI-fy any value that can be eventually used to merge different dataset and leave the other values as literals

RDF in a nutshell

Representing data in RDF Q/A 3/4 37

20100

http://dbpedia.org/resource/Postalcode

20100

http://dbpedia.org/resource/Postalcode

+ = ?

Page 38: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

What if I cannot thing about a good URI?• When no go URI exists, you can use blank nodes ( ) • The following relational data …

• … can be translated in RDF, in the BIO vocabulary [1], as follows

[1] http://vocab.org/bio/0.1.html

RDF in a nutshell

Representing data in RDF Q/A 4/4 38

Person Bio Event Date

Sofia Birth 1974-02-28

Sofia Marriage 1995-08-04

1974-02-28

http://www.sofia.org/#me

http://purl.org/vocab/bio/0.1/Birth

http://purl.org/vocab/bio/0.1/Marriage

1995-08-04

http://purl.org/vocab/bio/0.1/event

http://purl.org/vocab/bio/0.1/event

http://www.w3.org/1999/02/22-rdf-syntax-ns#type

http://purl.org/vocab/bio/0.1/date

http://purl.org/vocab/bio/0.1/event

http://purl.org/vocab/bio/0.1/date

Page 39: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Other data structure in RDF

Trees can be represented in RDF

Anything can be represented in RDF

39

Page 40: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Serializing RDF

Three alternatives to write triples, in1. RDF/XML: Standard serialization in XML

<Description about=”subject”>

<property>value</property>

</Description>– e.g., http://www.geonames.org/3173435/about.rdf – Check-out the triples using

http://www.w3.org/RDF/Validator/

2. NTriples: Simple (verbose) reference serialization (for specifications only)

<http://...subject> <http://...predicate> “value” .

• N3 and Turtle: Developer-friendly serializations :subject :property “value” .

40

Page 41: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Serializing RDF in Turtle - namespaces

URI terms can be abbreviated using namespaces@prefix geo: <http://www.geonames.org/ontology#> .@prefix rdf: <http://www.w3.org/1999/ 02/22-rdf-syntax-ns#> .

http://www.geonames.org/3173435/ rdf:type geo:P .

<http://www.w3.org/1999/ 02/22-rdf-syntax-ns#type> = 'a'

http://www.geonames.org/3173435/ a geo:P .

41

Page 42: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Serializing RDF in Turtle - Literals

Literals: "Milano"• Typed literals: "3.14"^^xsd:float• Literals with language tags: "日本語 "@ja

@prefix geo: <http://www.geonames.org/ontology#> .

http://www.geonames.org/3173435/ geo:population "1306661"^^xsd:integer .http://www.geonames.org/3173435/ geo:name "Milan" .http://www.geonames.org/3173435/ geo:alternateName "Milano"@IT .http://www.geonames.org/3173435/ geo:alternateName "Milan"@EN .http://www.geonames.org/3173435/ geo:alternateName "Mailand"@DE .

42

Page 43: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Serializing RDF in Turtle - Convience Syntax

Abbreviating repeated subjects:http://www.geonames.org/3173435/ geo:population "1306661"^^xsd:integer .http://www.geonames.org/3173435/ geo:name "Milan" .

... is the same as ...http://www.geonames.org/3173435/ geo:population "1306661"^^xsd:integer ; geo:name "Milan" .

Abbreviating repeated subject/predicate pairs:http://www.geonames.org/3173435/ geo:alternateName "Milano"@IT .http://www.geonames.org/3173435/ geo:alternateName "Milan"@EN .http://www.geonames.org/3173435/ geo:alternateName "Mailand"@DE .

... is the same as ...http://www.geonames.org/3173435/ geo:alternateName "Milano"@IT, "Milan"@EN, "Mailand"@DE .

43

Page 44: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

Serializing RDF in Turtle – black nodes

The following RDF model (see slide 25), including two blank nodes, can be serialized as shown hereafter

@prefix bio: <http://purl.org/vocab/bio/0.1/> .

http://www.sofia.org/#me bio:event [ a bio:Birth; bio:date "1974-02-28"^^xsd:date ] , [ a bio:Mariage; bio:date "1995-08-04"^^xsd:date ].

44

1974-02-28

http://www.sofia.org/#me

http://purl.org/vocab/bio/0.1/Birth

http://purl.org/vocab/bio/0.1/Marriage

1995-08-04

http://purl.org/vocab/bio/0.1/event

http://purl.org/vocab/bio/0.1/event

http://www.w3.org/1999/02/22-rdf-syntax-ns#type

http://purl.org/vocab/bio/0.1/date

http://purl.org/vocab/bio/0.1/event

http://purl.org/vocab/bio/0.1/date

Page 45: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

XML vs. RDF w.r.t. Evolving Data 1/2

V1 has several features

V1.1 adds two features

V2 changes the root tag

45

XML RDF

XML RDF

XML RDF

What effect on existing client software?–Regenerate stubs?–Recompile?

What effect on existing client software?

:#

Just few more triples

:-)

Just few more triples

:-)

Page 46: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

XML vs. RDF w.r.t. Evolving Data 2/2

Flexibility is important• Products are always changing

(competitive environment)• People are always adding more features• Graceful evolution is important• Relational data is remarkably flexible

XML syntax is important• Lots of application, which use XML, are already available• Lots of tools for XML are already available• Trees alows for simple parsing without loading the entire

model (i.e., XML parsing using SAX)

46

Page 47: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF in a nutshell

RDF Resources

RDF at the W3C - primer and specifications• http://www.w3.org/RDF/

Semantic Web tools - community maintained list; includes triple store, programming environments, tool sets, and more• http://esw.w3.org/topic/SemanticWebTools

302 Semantic Web Videos and Podcasts - includes a section specifically on RDF videos• http://www.semanticfocus.com/blog/entry/title/302-sema

ntic-web-videos-and-podcasts/

47

Page 48: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Query: SPARQL 48

Page 49: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

What is SPARQL?

SPARQL • is the query language of the Semantic Web• stays for SPARQL Protocol and RDF Query Language

A Query Language ...:Find names and websites of contributors to PlanetRDF: PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX dbp-ont: <http://dbpedia.org/ontology/>PREFIX dbp-prop: <http://dbpedia.org/property/>PREFIX geo-ont: <http://www.geonames.org/ontology#>

SELECT * WHERE { ?Company dbp-prop:location ?Place ; dbp-ont:industry dbpedia:Mass_media . ?Place geo-ont:parentFeature dbpedia:Italy . }

... and a Protocol.http://factforge.net/sparql?query=PREFIX+dbpedia%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%0D%0APREFIX+dbp-ont%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology …

49

Page 50: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

Why SPARQL?

SPARQL let us • Pull values from structured and semi-structured data

represented in RDF• Explore RDF data by querying unknown relationships• Perform complex joins of disparate RDF repositories in a

single query• Transform RDF data from one vocabulary to another• Develop higher-level cross-platform application

50

Page 51: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

Anatomy of a SPARQL query

Source: Pérez, Arenas and Gutierrez, Chapter 1: On the Semantics of SPARQL, Semantic Web Information Management: A Model Based Perspective, Springer 2010

Page 52: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

Anatomy of a SPARQL SELECT query

52

PREFIX foo: <…>PREFIX bar: <…>…SELECT …FROM <…>FROM NAMED <…>WHERE {

…}ORDER BY …LIMIT …OFFSET …

Declare prefixshortcuts (optional) Query result

clause

Triple patterns

Query modifiers(optional)

Define the dataset

(optional)

Page 53: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

The Modigliani Test 53

Page 54: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

SPARQL, FactForge and the Modigliani Test 1/2

SELECT DISTINCT ?painting_l ?owner_l ?city_fb_con ?city_db_loc ?city_db_cit

WHERE {?p fb:visual_art.artwork.artist dbpedia:Amedeo_Modigliani ; fb:visual_art.artwork.owners [ fb:visual_art.artwork_owner_relationship.owner ?ow ] ; ff:preferredLabel ?painting_l .?ow ff:preferredLabel ?owner_l .OPTIONAL { ?ow fb:location.location.containedby [ rdf:type umbel-sc:City ; ff:preferredLabel ?city_fb_con ] } . OPTIONAL { ?ow dbp-prop:location ?loc. ?loc rdf:type umbel-sc:City ; ff:preferredLabel ?city_db_loc }

OPTIONAL { ?ow dbp-ont:city [ ff:preferredLabel ?city_db_cit ] }FILTER ( bound(?city_fb_con) || bound(?city_db_loc) || bound(?city_db_cit) )}

54

Page 55: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

SPARQL, FactForge and the Modigliani Test 2/2 55

Page 56: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

SPARQL in a nutshell

SPARQL Resources

SPARQL Frequently Asked Questions• http://thefigtrees.net/lee/sw/sparql-faq

SPARQL implementations - community maintained list of open-source and commercial SPARQL engines• http://esw.w3.org/topic/SparqlImplementations

Public SPARQL endpoints - community maintained list• http://esw.w3.org/topic/SparqlEndpoints

SPARQL extensions - collection of SPARQL extensions implemented in various SPARQL engines• http://esw.w3.org/topic/SPARQL/Extensions

Page 57: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Ontology: RDF-S and OWL 57

Page 58: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Ontology definition

Philosophy (400BC): • Systematic explanation of Existence

Neches (91): • Ontology defines basic terms and relations comprising

the vocabulary of a topic area as well as the rules for combining terms and relations to define extensions to the vocabulary

Gruber (93): • Explicit specification of a conceptualization

Borst (97): • Formal specification of a shared conceptualization

Studer(98)• Formal, explicit specification of a shared

conceptualization

58

Page 59: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

What does it mean? 59

Formal, explicit specification of a shared conceptualization

Machinereadable

Several peopleagrees that suchconceptual model

is adequate to describe such aspects of the

reality

A conceptual model of someaspects of the

realityIt makesdomain

assumptionexplicit

Page 60: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Did I Get it? 60

Page 61: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

What is an Ontology?

A model of (some aspect of) the world• Introduces vocabulary

relevant to domain– e.g., anatomy

• Specifies meaning (semantics) of terms– Heart is a muscular

organ that is part ofthe circulatory system

• Formalised using suitable logic– ∀x.[ Heart(x)→

MuscolarOrgan(x)∧ ∃y.[isPartOf(x,y )∧ CirculatorySystem(y)]]

• Shared among multiple people organizations

Page 62: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

How much explicit shall the specification be? 62

“A little semantics, goes a long way”

[James Hendler, 2001]

“A little semantics, goes a long way”

[James Hendler, 2001]

Page 63: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

A simple ontology 63

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Page 64: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Specifying classes, sub-classes and instances

Creating a class • RDFS: Artist rdf:type rdfs:Class . • FOL: x Artist(x)

Creating a subclass • RDFS: Painter rdfs:subClassOf Artist .• RDFS: Sculptor rdfs:subClassOf Artist .• FOL: x [Painter(x) Sculptor(x) Artist(x)]

Creating an instance• RDFS: Rodin rdf:type Sculptor .• FOL: Sculptor(Rodin)

64

ArtistPainter

SculptorRodin

Page 65: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Creating a property• RDFS: creates rdf:type rdf:Property .• FOL: x y Creates(x,y)

Using a property• RDFS: Rodin creates TheKiss .• FOL: Creates(Rodin, TheKiss)

Creating subproperties • RDFS: paints rdfs:subPropertyOf creates .• FOL: x y [Paints(x,y) Creates(x,y)]• RDFS: sculpts rdfs:subPropertyOf creates . • FOL: x y [Sculpts(x,y) Creates(x,y)]

RDF-S/OWL in a nutshell

Specifying properties and sub-properties 65

creates

paints

Page 66: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Specifying domain/range constrains

Checking which classes and properties can be use together

RDFS:creates rdfs:domain Artist .creates rdfs:range Piece .paints rdfs:domain Painter .paints rdfs:range Paint .sculpts rdfs:domain Sculptor .sculpts rdfs:range Sculpt .

FOL:x y [Creates(x,y) Artist(x) Piece(y)]x y [Paints(x,y) Painter(x) Paint(y)]x y [Sculpts(x,y) Sculptor(x) Sculpt(y)]

66

Page 67: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

The ontology we specified 67

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Page 68: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

RDF semantics (a part of it) if then

x rdfs:subClassOf y . a rdf:type y .

a rdf:type x .

x rdfs:subClassOf y . x rdfs:subClassOf z .

y rdfs:subClassOf z .

x a y . x b y .

a rdfs:subPropertyOf b .

a rdfs:subPropertyOf b . a rdfs:subPropertyOf c .

b rdfs:subPropertyOf c .

x a y . x rdf:type z .

a rdfs:domain z .

x a u . u rdf:type z .

a rdfs:range z .

68

Read out more in RDF Semantics http://www.w3.org/TR/rdf-mt/

Page 69: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

RDF semantics at work

Shared the ontology ...@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@prefix ex: <http://www.ex.org/schema#> .

ex:Sculptor rdfs:subClassOf ex:Artist .ex:Painter rdfs:subClassOf ex:Artist .ex:Sculpt rdfs:subClassOf ex:Piece.ex:Painting rdfs:subClassOf ex:Piece .ex:creates rdfs:domain ex:Artist .ex:creates rdfs:range ex:Piece.ex:sculpts rdfs:subPropertyOf ex:creates .ex:sculpts rdfs:domain ex:Sculptor .ex:sculpts rdfs:range ex:Sculpt .

... when transmitting the following triple …ex:Rodin ex:sculpts ex:TheKiss .

69

Page 70: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Without Inference

A recipient, that only understands XML syntax

receiving<RDF> <Description about="Rodin"> <sculpts resource="TheKiss"/> </Description></RDF>

can answer the following queries• What does Rodin sculpt?RDF/Description[@about='Rodin']/sculpts/@resource• Who does sculpt TheKiss?RDF/Description[sculpts/@resource='TheKiss']/@about• Try out your self at http://www.mizar.dk/XPath/

but it cannot answer• Who is Rodin?• What is TheKiss?• Is there any Sculptor/Scupts?• Is there any Artist/Piece?

70

Page 71: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Knowing the ontology and RDF semantics …

A recipient, that knows the ontology and “understands” RDF semantics

Receiving Rodin sculpts TheKiss .

71

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Rodin TheKiss

Page 72: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

… a reasoner can answer 1/2

the previous queries• What does Rodin sculpt?

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

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

SELECT ?x

WHERE { ex:Rodin ex:sculpts ?x }

?x = ex:TheKiss• Who does sculpt TheKiss?

WHERE { ex:Rodin ex:sculpts ?x }

?x = ex:Rodin

and it can also answer• Who is Rodin?

WHERE { ex:Rodin a ?x }

?x = ex:Artist, ex:Sculptor, rdfs:Resource• What is TheKiss?

WHERE { ex:TheKiss a ?x }

?x = ex:Sclupt, ex:Piece, rdfs:Resource

72

Page 73: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

… a reasoner can answer 2/2

• Is there any Sculptor?WHERE { ?x a ex:Sculptor}

?x = ex:Rodin• Is the any Artist?

WHERE { ?x a ex:Artist }

?x = ex:Rodin• Is there any Sculpt?

WHERE { ?x a ex:Sculpt }

?x = ex:TheKiss• Is there any Piece?

WHERE { ?x a ex:Piece }

?x = ex:TheKiss• Is there any Paint?

WHERE { ?x a ex:Paint }

0 results• Is there any Painter?

WHERE { ?x a ex:Painter }

0 results

73

Page 74: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Reasoning and Query Answering

SPARQL alone cannot answer queries that require reasoning

but a reasoner can be exposed as a SPARQL service.

Or a query can be rewritten in order to incorporate the ontology

74

dataSPARQLservice

ReasonerdataSPARQLservice

Inferred data

ontology

dataSPARQLservice

ontology

Rewritten query

Page 75: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

More expressive power 1/3

RDFS is a light ontological language that allows for defining simple vocabularies.

One may want also express• Cardinality constrains (max, min, exactly) for properties

usage– Es. a Polygon has 3 or more edges– x [Polygon(x) ≥3y Edge(y) Forms(y,x) ]

• Property types– transitive

- e.g. hasAncestor is a transitive property: if A hasAncestor B and B hasAncestor C, then A hasAncestor C.

- x y z [HasAncestor(x,y) HasAncestor(y,z) HasAncestor(x,z) ]

– inverse- e.g. sclupts has isSculptedBy as inverse property:

if A sclupts B then B isSculptedBy A- x y [Sculpts(x,y) IsSculptedBy(y,x) ]

75

Page 76: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

More expressive power 2/3

– simmetric- e.g. isCloseTo is a simmetric property:

if A isCloseTo B then B isCloseTo A- x y [IsCloseTo(x,y) IsCloseTo(y,x) ]

• Restrictions of usage for a specific property– All values of property must be of a certain kind

- e.g. a D.O.C. Wine can be only produced by a Certified Wienery

- x y [DOCWine(x) Produces(x,y) CertifiedWienery(y)]

– Some values of property must be of a certain kind- e.g. a Famous Painter must have painted some Famous

Painting- x [FamousPainter(x) y FamousPaint(y)

IsPaintedBy(y,x)]• A class is defined combining other classes (union,

intersection, negation, ...) – A white wine is a Wine and its color is “white”– x [Wine(x) White(x)]

76

Page 77: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

More expressive power 3/3

• Two instances refers to the same real object– “The Boss” and “Bruce Springsteen” are two names for the

same person– TheBoss = BruceSpringsteen

• Two classes refers to the same set– “Painters” in english and “Pittori” in italian– x [Painter(x) Pittore(x)]

• Two properties refers to the same binary relationship– “Paints” in english and “Dipinge” in italian– x y [Paints(x,y) Dipinge(x,y)]

77

Page 78: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

Expressivity vs. Tractability

The more an ontological language is expressive the less is tractable

the Web Ontology Language (OWL) comes with several profiles that offers different trade-offs between expressivity and tractability.

78

Page 79: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

OWL profiles

OWL 1 defines only one fragment (OWL Lite)• And it isn’t very tractable!

OWL 2 defines several different fragments with• Useful computational properties

– E.g., reasoning complexity in range LOGSPACE to PTIME• Useful implementation possibilities

– E.g., Smaller fragments implementable using RDBs

OWL 2 profiles• OWL 2 EL, OWL 2 QL, OWL 2 RL

79

Page 80: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

OWL 2 EL

Useful for applications employing ontologies that contain very

large number of properties and/or classes• Captures expressive power used by many large-

scaleontologies E.g.; SNOMED CT, NCI thesaurus

Features• Included: existential restrictions, intersection,

subClass,equivalentClass, disjointness, range and domain, object property inclusion possibly involving property chains, and data property inclusion, transitive properties, keys …

• Missing: include value restrictions, Cardinality restrictions (min, max and exact), disjunction and negation

Maximal language for which reasoning (including query answering) known to be worst-case polynomial

80

Page 81: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

OWL 2 QL

Useful for applications that use very large volumes of data, and where query answering is the most important task

Captures expressive power of simple ontologies like thesauri, classifications, and (most of) expressive power of ER/UML schemas

E.g., CIM10, Thesaurus of Nephrology, ...

Features• Included: limited form of existential restrictions, subClass,

equivalentClass, disjointness, range & domain, symmetric properties, …

• Missing: existential quantification to a class, self restriction, nominals, universal quantification to a class, disjunction etc.

Can be implemented on top of standard relational DBMS

Maximal language for which reasoning (including query answering) is known to be worst case logspace (same as DB)

81

Page 82: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

OWL 2 RL

Useful for applications that require scalable reasoning without sacrifying too much expressive power, and where query answering is the most important task

Support most OWL features but• with restrictions placed on the syntax of OWL 2• standard semantics only apply when they are used in a

restricted way

Can be implemented on top of rule extended DBMS• E.g., Oracle’s OWL Prime implemented using forward

chaining rules in Oracle 11g• Related to DLP and pD*

Allows for scalable (polynomial) reasoning using rule-based technologies

82

Page 83: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

RDF-S/OWL in a nutshell

RDF-S/OWL Resources

OWL Frequently Asked Questions• http://www.w3.org/2003/08/owlfaq.html

RDF-S/OWL implementations - community maintained list of open-source and commercial SPARQL engines• http://esw.w3.org/topic/SemanticWebTools#head-

d07454b4f0d51f5e9d878822d911d0bfea9dcdfd

RDF-S Specification• http://www.w3.org/TR/rdf-schema/

OWL Working Group Wiki• http://www.w3.org/2007/OWL/wiki

Page 84: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Conclusions 84

Page 85: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Credits

Introduction and RDF slides are partially based on “Fundamentals of the Semantic Web” by David Boothhttp://www.w3.org/2002/Talks/0813-semweb-dbooth/

OWL 2 slides are partially based on • OWL 2 Update by Christine Golbreich

http://esw.w3.org/topic/HCLSIG/F2F/2008-10_F2F?action=AttachFile&do=get&target=HCLSF2F2008-OWL2-CG.pdf

• “Scalable Ontology-Based Information Systems” by Ian Horrocks presented at EDBT/ICDT 2010 Joint Conference, Lausanne, Switzerland, March 26th, 2010.http://www.comlab.ox.ac.uk/people/ian.horrocks/Seminars/download/EDBT-2010.pdf

85

Page 86: The Semantic Web Turns Ten 11.11.2011, Milano Emanuele Della Valle

Search Computing

Advertisement 86