introduction to semantic web for gis practitioners

102
Applied Semantic Web Timely. Practical. Reliable. http://applied-semantic-web.org Introduction to Semantic Web for GIS Practitioners 3.5.2011, Como Emanuele Della Valle [email protected] http://emanueledellavalle.org

Upload: emanuele-della-valle

Post on 20-Aug-2015

4.709 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Introduction to Semantic Web for GIS Practitioners

Applied Semantic WebTimely. Practical. Reliable.http://applied-semantic-web.org

Introduction to Semantic Web for GIS Practitioners3.5.2011, ComoEmanuele Della [email protected]://emanueledellavalle.org

Page 2: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 reused slide– a credits slide stating “These slides are partially based on

“An Introduction to the Semantic Web for GIS Practitioners” by Emanuele Della Valle http://applied-semantic-web.org/slides/2011/05/SemanticWeb4GIS.ppt

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

2

Page 3: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 4

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 5

Introduction

The Problem: “Semantic Gap”

Sensor Data

Semantic Gap

Symbolic Description

Page 6: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 6

Introduction

“Understanding” Means Bridging the Gap 6

understanding

Sensor Data

Symbolic Description

Page 7: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 7

Introduction

Do We Really Know What “Understanding” means? 7

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

Page 8: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Introduction

Two ways for computer to “understand”

Smart Machine

Smart Data

8

Page 9: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 9

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 10

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

eP

roc

ess

ing

sea “c”

Semantic Gap

Page 11: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 11

Introduction

… smart data are need

11

Sensor Data

Symbolic Description

Ima

ge

Pro

ces

sin

g

Na

tura

l L

ang

uag

eP

roc

ess

ing

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 12

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 17

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Introduction Linked Data Standards

18WebMGS 2010, 27.8.2010

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

Page 19: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 20

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: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 21

Introduction data.gov and data.gov.uk 21

Page 22: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 22

Introduction Example: 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" />

22

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 23: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Introduction Example: LinkedGeoData

LinkedGeoData • is an effort to add a spatial dimension

to the Semantic Web. • uses the information collected by the

OpenStreetMap project • makes it available as an RDF knowledge base according

to the Linked Data principles. • interlinks this data with other knowledge bases in the Linking

Open Data initiative.

23

Page 24: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 24

Introduction Semantic Web “layer cake”

Standardized

UnderInvestigation

Already Possible

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

Page 25: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 25

Data Interchange: RDF

Page 26: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

- 26 -© 2001-2005 E. Della Valle - CEFRIEL

Page 27: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

27

Page 28: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Representing relational data in RDF (almost)

E.g., geographical data

Represented in RDF (almost)

28

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 29: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

29

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 30: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

30

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 31: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

31

Page 32: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

32

20100

http://dbpedia.org/resource/Postalcode

20100

http://dbpedia.org/resource/Postalcode

+ = ?

Page 33: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

33

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

Adv

ance

d

Page 34: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Other data structure in RDF

Trees can be represented in RDF

Anything can be represented in RDF

34

Page 35: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

Scenario: Describe printer capabilities

V1 has several features

35

XML RDF

Page 36: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

V1.1 adds two features

• What effect on existing client software? – Regenerate stubs?– Recompile?– Did any queries break?– (Depends how they're written.  Best programmers?)

36

XML RDF

Page 37: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

V1.2 adds three more features

• What effect on existing client software? 

37

XML RDF

Page 38: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

V2 adds colors

• What effect on existing client software? 

38

XML RDF

Page 39: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

Version n combines printer, scanner, fax:

Problem:  How to combine trees?• Printer and fax both have output paper settings (red)• Scanner and fax both have input image settings (blue)

39

Page 40: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

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

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)

40

Page 41: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Serializing RDF in XML

W3C standardized an RDF/XML syntax [1]

The basic idea is to insert an XML element for each node (sobject and value) and arc (predicate)

Es.

<rdf:RDF xmlns:rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:ex=”http://www.example.org/” xmlns:sid=“URN:org:example:staffid:” xmlns:dc=”http://purl.org/dc/elements/1.1/”> <rdf:Description rdf:about="http://www.example.org/index.html ">

  <dc:creator>    <rdf:Description rdf:about="URN:org:example:staffid:85740"/>

  </dc:creator ></rdf:Description>

</rdf:RDF>

41

[1] RDF/XML Syntax Specification available at http://www.w3.org/TR/rdf-syntax-grammar/

ex:index.html sid:85740

dc:creator

propertyelement

Root tag

Page 42: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Serializing RDF in XML

A compact XML serialization of

is

<ex:pagina_web rdf:about="http://www.example.org/index.html"> <dc:creator> <ex:impiegato rdf:about="sid:55740" foaf:email="mailto:[email protected]"/> <dc:creator> </ex:pagina_web>

42

ex:index.html sid:85740

dc:creator

mailto:[email protected]:email

ex:pagina_web ex:impiegato

rdf:type rdf:type

Adv

ance

d

Page 43: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Merging XML files 1/2

Suppose you have to merge the two following XML

Merging the XML trees is difficult, but being RDF …

<Park rdf:about="Yosemite">

<conteins>

<Camp rdf:about="North-Pines"/>

</conteins>

<crossedBy>

<Path rdf:about="S11"/>

</crossedBy>

</Park>

<Camp rdf:about="North-Pines"

locatedIn="Yosemite">

<accessibleBy>

<Path rdf:about="S11"/>

</accessibleBy>

</Camp>

Yosemite

North-Pines

Park

rdf:type

rdf:type

conteins

Camp

S11

rdf:typePath

crossedBy

Yosemite

North-Pines

rdf:typeCamp

S11

rdf:typePath

accessibleBy

locatedIn

Adv

ance

d

Page 44: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Merging XML files 2/2

It’s (just) a matter to merge the two RDF graphs

NOTE: It works out nicely because both RDF/XML documents refer to the same resources and use the same vocabularies.

U

Yosemite

North-Pines

Park

rdf: type

rdf: type

conteins

Camp

S11

Path

accessibleBy

crossedBy

locatedIn

rdf: type

Yosemite

North-Pines

Park

rdf: type

rdf: type

conteins

Camp

S11

rdf: type

Path

crossedBy

Yosemite

North-Pines

rdf:type

Camp

S11

rdf:type

Path

accessibleBy

locatedIn

Adv

ance

d

Page 45: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Serializing RDF in Turtle - namespaces

RDF allows for serializations alternative to XML

Turtle serialization is often used for teaching Semantic Web Technologies because triples are more evident

Example

@prefix sr: <http://www.streamreasoning.org/sr4ld2011/onto#> .@prefix skos: <http://www.w3.org/2004/02/skos/core#> .@prefix dbp: <http://dbpedia.org/resource/Category:> .

sr:LaScala a sr:NamedPlace ;skos:subject dbp:Opera_houses_in_Italy .

sr:GalleriaVittorioEmanueleII a sr:NamedPlace ;skos:subject dbp:Pedestrian_streets_in_Italy,

dbp:Buildings_and_structures_in_Milan . sr:Duomo a sr:NamedPlace ;

skos:subject dbp:ChurchesInMilan.

45

Page 46: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Serializing RDF in Turtle - namespaces

RDF allows for serializations alternative to XML

Turtle serialization is often used for teaching Semantic Web Technologies because triples are more evident

URI terms can be abbreviated using namespaces

@prefix sr: <http://www.streamreasoning.org/sr4ld2011/onto#> .

sr:LaScala rdf:type sr:NamedPlace .

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

sr:LaScala a sr:NamedPlace .

46

Page 47: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF in a nutshell

Serializing RDF in Turtle - Convience Syntax

Abbreviating repeated subjects:sr:LaScala a sr:NamedPlace .sr:LaScala skos:subject dbp:Opera_houses_in_Italy .

... is the same as ...sr:LaScala a sr:NamedPlace ;

skos:subject dbp:Opera_houses_in_Italy .

Abbreviating repeated subject/predicate pairs:sr:GalleriaVittorioEmanueleII skos:subject dbp:Pedestrian_streets_in_Italy .sr:GalleriaVittorioEmanueleII skos:subject dbp:Buildings_and_structures_in_Milan.

... is the same as ...sr:GalleriaVittorioEmanueleII skos:subject dbp:Pedestrian_streets_in_Italy,

dbp:Buildings_and_structures_in_Milan .

47

Page 48: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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-semantic-

web-videos-and-podcasts/

48

Page 49: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 49

Query: SPARQL

Page 50: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 named place:

PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#>SELECT ?poi WHERE { ?poi a sr:NamedPlace . }

... and a Protocol.http://lod.openlinksw.com/sparql?&query=PREFIX+sr%3A+%3Chttp%3A%2F%2Fwww.streamreasoning.org%2Fsr4ld2011%2Fonto%2F%3E%0D%0ASELECT+%3Fpoi+WHERE+{+%3Fpoi+a+sr%3ANamedPlace+.+}

50

Page 51: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

51

Page 52: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 52

SPARQL in a nutshell

Anatomy of a SPARQL query

52

Page 53: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 53

SPARQL in a nutshell

Anatomy of a SPARQL SELECT query

53

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 54: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Triple Pattern Syntax

Turtle-like: URIs, QNames, literals, convenience syntax.

Adds variables to get basic graph patterns • ?var• Variable names are a subset of NCNames (no "-" or ".")

E.g., • simple

– ?poi a sr:NamedPlace .• a bit more complex

– ?poi a geo:NamedPlace .?poi skos:subject ?category .

Adds • OPTIONAL to cope with semi-structured nature of RDF• FILTER to select solution according to some criteria• UNION operator to get complex patterns

54

Page 55: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Writing a Simple Query

Data

@prefix sr:<http://www.streamreasoning.org/sr4ld2011/onto#>.

sr:LaScala a sr:NamedPlace .sr:GalleriaVittorioEmanueleII a sr:NamedPlace . sr:Duomo a sr:NamedPlace .

Query

PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#>

SELECT ?poi WHERE { ?poi a sr:NamedPlace . }

Results

?poi

http://www.streamreasoning.org/sr4ld2011/data#GalleriaVittorioEmanueleII

http://www.streamreasoning.org/sr4ld2011/data#LaScala

http://www.streamreasoning.org/sr4ld2011/data#Duomo

55

a = rdf:type

Page 56: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Matching

Matches the graph means find a set of bindings such that the substitution of variables for values creates a triple that is in the set of triples making up the graph.

Solution 1: • variable poi has value sr:GalleriaVittorioEmanueleII • Triple sr:GalleriaVittorioEmanueleII a sr:NamedPlace .

is in the graph.

Solution 2: • variable poi has value sr:LaScala • Triple sr:LaScala a sr:NamedPlace . is in the graph.

Solution 3: • variable poi has value sr:Duomo • Triple sr:Duomo a sr:NamedPlace . is in the graph.

No order of solutions in this query.

56

Page 57: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Writing a bit more complex query Query

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#>

SELECT ?poi ?category WHERE { ?poi a geo:NamedPlace ; skos:subject ?category . }

Results

57

?poi ?category

http://www.streamreasoning.org/sr4ld2011/data#GalleriaVittorioEmanueleII

http://dbpedia.org/resource/Category:Pedestrian_streets_in_Italy

http://www.streamreasoning.org/sr4ld2011/data#GalleriaVittorioEmanueleII

http://dbpedia.org/resource/Category:Buildings_and_structures_in_Milan

http://www.streamreasoning.org/sr4ld2011/data#LaScala

http://dbpedia.org/resource/Category:Opera_houses_in_Italy

http://www.streamreasoning.org/sr4ld2011/data#Duomo

http://dbpedia.org/class/yago/ChurchesInMilan

… …

Page 58: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Basic Graph Patterns

A Basic Graph Patter is a set of triple patterns, all of which must be matched.

In this case matches the graph means find a set of bindings such that the substitution of variables for values creates a subgraph that is in the set of triples making up the graph.

58

Page 59: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Matching RDF literals – text

QueryPREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#>

SELECT ?poi WHERE { ?poi sr:name "Duomo". }

Results

Alert!• It may return 0 results if the literal have a language tag

– E.g., if data contains only the triple sr:Duomo sr:name "Duomo"@it . • To obtain results also add the language tag to the triple

pattern– E.g, ?poi sr:name "Duomo"@it.

59

?poi

http://www.streamreasoning.org/sr4ld2011/data#Duomo

Page 60: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Matching RDF literals – numerical values

As in the case of language tags, if the literals are typed (i.e., "3.14"^^xsd:float), they do not match if they are not given explicitly.

Query

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#>

SELECT ?poi WHERE { ?poi a sr:NamedPlace ; geo:lat "45.46416854858398"^^xsd:float ; geo:long "9.191389083862305"^^xsd:float .}

Results

60

?poi

http://www.streamreasoning.org/sr4ld2011/data#Duomo

Page 61: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

RDF Term Constraints SPARQL allows restricting solutions by applying the FILTER

clause. An RDF term bound to a variable appears in the results if the

FILTER expression, applied to the term, evaluates to TRUE. Query

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?poi ?lat ?log WHERE {

?poi geo:lat ?lat ; geo:long ?long .FILTER(

?lat>"45.46"^^xsd:float && ?lat<"45.47"^^xsd:float && ?long>"9.18"^^xsd:float && ?long<"9.20"^^xsd:float )

}

Results

61

?poi

http://www.streamreasoning.org/sr4ld2011/data#GalleriaVittorioEmanueleII

http://www.streamreasoning.org/sr4ld2011/data#LaScala

http://www.streamreasoning.org/sr4ld2011/data#Duomo

Page 62: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

RDF Term Constraints – regex

SPARQL FILTERs allows also restricting values of strings using the regex()

Query

PREFIX sr: <http://www.streamreasoning.org/sr4ld2011/onto#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?poi ?c WHERE { ?poi rdfs:comment ?c . FILTER(regex(?c, "glass-vaulted arcades", "i" ))}

Results

62

?poi ?c

http://www.streamreasoning.org/sr4ld2011/data#GalleriaVittorioEmanueleII

The Galleria Vittorio Emanuele II is a covered double arcade formed of two glass-vaulted arcades at right angles intersecting in an octagon, prominently sited on the northern side of the Piazza del Duomo in Milan, and connects to the Piazza della Scala.

Page 63: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Value Tests

Notation for value comparison: <, >, =, <=, >= and !=

Test functions• Check if a variable is bound: BOUND• Check the type of resource bound: isIRI, isBLANK, isLITERAL

Accessing accessories: LANG, DATATYPE

Logic operators: || and &&

Comparing strings: REGEX, langMatches

Constructor functions: bool, dbl, flt, dec, int, dT, str, IRI

Extensible Value Testing• E.g., FILTER ( aGeo:distance(?axLoc, ?ayLoc, ?bxLoc, ?byLoc) < 10 ) . • (see http://www.w3.org/TR/rdf-sparql-query/#extensionFunctions )

63

Page 64: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Value Tests - Extensible Value Testing 1/2

Find all schools within a 5km radius around a specific location, and for each school find coffeeshops that are closer than 1km.

PREFIX lgdo: <http://linkedgeodata.org/ontology/>SELECT ?schoolname ?schoolgeo ?coffeeshopname ?coffeeshopgeoWHERE { ?school     a            lgdo:School . ?school     geo:geometry ?schoolgeo . ?school     rdfs:label   ?schoolname . ?coffeeshop a            lgdo:CoffeeShop . ?coffeeshop geo:geometry ?coffeeshopgeo . ?coffeeshop rdfs:label   ?coffeeshopname . FILTER( bif:st_intersects( ?schoolgeo,bif:st_point(4.892222,52.373056), 5) &&  bif:st_intersects(?coffeeshopgeo, ?schoolgeo, 1) ) .}

Click here for query results on a Virtuoso endpoint used by LinkedGeoData project.

64

Page 65: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Value Tests - Extensible Value Testing 2/2

Signature• st_intersects(g1, g2, prec)

Parameters• g1 – The first geometry. • g2 – The second geometry. • prec – A tolerance for the matching in units of linear distance

appropriate to the srid. Default is 0.

Description• Returns intersects between two geometries. If prec is

supplied, this is a tolerance for the matching in units of linear distance appropriate to the srid. Both geometries should have the same srid. st_intersects is true if there is at least one point in common.

65

Page 66: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

More Sophisticated Graph Patterns

RDF is "semi structured" and has no integrity constrains

SPARQL addresses this issue with• Group patterns match if all subpatterns match and all

constraints are satisfied– In SPARQL syntax, groups are { … }

• OPTIONAL graph patterns accommodate the need to add information to a result but without the query failing just because some information is missing.– In SPARQL syntax, OPTIONAL { … }

• UNION graph patterns allows to match alternatives – In SPARQL syntax, { … } UNION { … }

66

Page 67: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

SPARQL in a nutshell

Result Forms

Besides selecting tables of values, SPARQL allows three other types of queries:• ASK - returns a boolean answering, does the query have any

results?• CONSTRUCT - uses variable bindings to return new RDF

triples• DESCRIBE - returns server-determined RDF about the queried

resources

SELECT and ASK results can be returned as XML or JSON.

CONSTRUCT and DESCRIBE results can be returned via any RDF serialization (e.g. RDF/XML or Turtle).

67

Page 68: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 69: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 69

Ontology: RDF-S and OWL

Page 70: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

70

Page 71: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 71

RDF-S/OWL in a nutshell

What does it mean?

71

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 72: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF-S/OWL in a nutshell

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 73: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 73

RDF-S/OWL in a nutshell

How much explicit shall the specification be?

“A little semantics, goes a long way”[James Hendler, 2001]

“A little semantics, goes a long way”[James Hendler, 2001]

Adv

ance

d

Page 74: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 74

RDF-S/OWL in a nutshell

A simple ontology

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Page 75: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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)

75

ArtistPainter

SculptorRodin

Page 76: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

76

creates

paints

Page 77: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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)]

77

Page 78: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 78

RDF-S/OWL in a nutshell

The ontology we specified

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Page 79: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 .

79

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

Page 80: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 .

80

Page 81: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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?

81

Page 82: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 .

82

Artist Piece

Painter Paint

paints

Sculptor Sculpt

sculpts

creates

Rodin TheKiss

Page 83: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

83

Page 84: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

84

Page 85: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

85

dataSPARQLservice

ReasonerdataSPARQLservice

Inferred data

ontology

dataSPARQLservice

ontology

Rewritten query

Adv

ance

d

Page 86: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Given ontology O and query Q, use O to rewrite Q as Q’ so that, for any set of ground facts A contained in multiple databases:• answer(Q,O,A) = answer(Q’,,A)

– The answer of the query Q using the ontology O for any set of ground facts A is equal to answer of a query Q’ without considering the ontology O

Use (Global As View) mapping M to map Q’ to multiple SQL queries to the various databases

RDF-S/OWL in a nutshell

Reasoning and Information Integration

86

Rewrite

O

QQ’

MapSQL

M

answer

Adv

ance

d

Page 87: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF-S/OWL in a nutshell

Query Rewriting Technique (basics)

Example:• Ontology

– Doctors treats patients– Consultants are doctors

• Query– Give me those that treats some patient

• For OWL2 QL, the rewriting results in a union of conjunctive queries

87

Adv

ance

d

Page 88: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF-S/OWL in a nutshell

Query Rewriting Technique (basics)

Relationship between ontology and databases defined by mappings, e.g.:

• Note: the mapping can be partial, i.e., Consultant is non mapped

Using the mapping the query resulting from the mapping can be translated in SQL

88

Adv

ance

d

Page 89: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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) ]

89

Adv

ance

d

Page 90: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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)]

90

Adv

ance

d

Page 91: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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)]

91

Adv

ance

d

Page 92: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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.

92

Adv

ance

d

Page 93: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

RDF-S/OWL in a nutshell

OWL 1 and OWL 2 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

93

Page 94: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

94

Page 95: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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)

95

Page 96: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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

96

Page 97: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

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 98: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 98

Conclusions 1/2

Achievements• Extending the Web with a

data commons– 27 billion triples– 395 million links

• Vibrant, global RTD community

• Industrial uptake begins – e.g., BBC, NYT, Eli Lilly

• Government sponsorship – mainly in USA and UK, but

something moves in EU as well

Page 99: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Conclusions 2/2

Challenges• Coherence

– relatively few and expansive to maintain links• Quality

– Partly low quality data and inconsistencies• Performance

– Still substantial penalties compared to relational• Data consumption

– Large-scale processing, schema mapping and data fusions still in its infancy

• Usability– Missing direct end-user tools and network effect

99

Page 100: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org

Credits

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

SPARQL slides are partially based on WWW 2005 SPARQL Tutorial http://www.w3.org/2004/Talks/17Dec-sparql/

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

Conclusions are based on “Towards the Linked Data Web” by Sören Auer http://www.slideshare.net/lod2project/towards-the-linked-data-web-sren-auer-2612011-brussels-belgium

100

Page 101: Introduction to Semantic Web for GIS Practitioners

Emanuele Della Valle - http://applied-semantic-web.org 101

Advertisement ;-)

Page 102: Introduction to Semantic Web for GIS Practitioners

Applied Semantic WebTimely. Practical. Reliable.http://applied-semantic-web.org

Introduction to Semantic Web for GIS Practitioners3.5.2011, ComoEmanuele Della [email protected]://emanueledellavalle.org