rdf & sparql introduction dongfang xu ph.d student, school of information, university of arizona...

32
RDF & SPARQL Introduction Dongfang Xu Ph .D student, School of Information, University of Arizona Sept 10, 2015

Upload: abigayle-johnston

Post on 06-Jan-2018

216 views

Category:

Documents


1 download

DESCRIPTION

Semantic Web The Limits of today’s Web (2.0): 1.High recall and low precision; 2. Low recall and even on recall; 3. Results are highly sensitive to vocabulary. 4. Single Web pages. Reference: Antoniou, G., & Van Harmelen, F. (2008). A semantic web primer (2 nd ed.). Cambridge, Mass: MIT press.

TRANSCRIPT

Page 1: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF & SPARQLIntroduction

Dongfang XuPh .D student, School of Information, University of Arizona

Sept 10, 2015

Page 2: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Catalog

Semantic Web

RDF

RDF Schema

SPARQL

Page 3: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Semantic Web

The Limits of today’s Web (2.0):

1.High recall and low precision;

2. Low recall and even on recall;

3. Results are highly sensitive to vocabulary.

4. Single Web pages.

Reference: Antoniou, G., & Van Harmelen, F. (2008). A semantic web primer (2nd ed.). Cambridge, Mass: MIT

press.

Page 4: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Semantic Web What can be done?

Page 5: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Semantic Web

The Semantic Web Technologies(standard technologies ):

1.Format the web content.

2.Relate the data

Machine-processable web information

Page 6: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Semantic Web

<company> <treatmentOffered>Physiotherapy</treatment Offered> <companyName>Agilitas Physiotherapy Centre</companyName> <staff> <therapist>Lisa Davenport</therapist> <therapist>Steve Matthews</therapist> <secretary>Kelly Townsend</secretary> <staff></company>

Page 7: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

XML & RDF<course name=“Discrete Mathematics”> <lecturer>David Billing</lecturer></course>

<lecturer name=“lecturer>David Billing”> <teaches> Discrete Mathematics</teaches></lecturer>

<teachingOffering> <lecturer>David Billing</lecturer> <courses> Discrete Mathematics</courses></teachingOffering>

XML does not provide any means of talking about the semantics (meaning) of data

Page 8: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Catalog

Semantic Web

RDF

RDF Schema

SPARQL

Page 9: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

What is RDF?• A data model for objects (“resources”) and relations

between them; • Provides a simple semantics for the data model;• The model can be represented in an xml syntax.

Basic building block is an object-attribute-value triple, called statement.

RDF

Page 10: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF

<?xml version="1.0"?><River id="Yangtze" xmlns="http://www.geodesy.org/river"> <length>6300 kilometers</length> <startingLocation>western China's Qinghai-Tibet Plateau</startingLocation> <endingLocation>East China Sea</endingLocation></River>

XML

Modify the following XML document so that it is also a valid RDF document:

<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.geodesy.org/river#"> <rdf:Description rdf:ID="Yangtze" <uni:length>6300 kilometers</uni:length> <uni:startingLocation>western China's Qinghai-Tibet Plateau</uni:startingLocation> <uni:endingLocation>East China Sea</uni:endingLocation> </rdf: Description></rdf: RDF>

RDF

Yangtze.xml

Yangtze.rdf

"convert to"

Page 11: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF Data Model• As you read the RDF literature you may see

the following terminology:• Subject: this term refers to the item that is playing

the role of the resource.• predicate: this term refers to the item that is playing

the role of the property. • Object: this term refers to the item that is playing

the role of the value.

Subject Objectpredicate

Resource ValuepropertyEquivalent!

<rdf:Description rdf:ID="Yangtze" <uni:length>6300 kilometers</uni:length></rdf: Description>

Page 12: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF resource A Resource is any object identifiable by a URI.1.Resources can use any URI, e.g.: http://www.example.org/file.xml#element(home) http://www.example.org/file.html#home http://www.example.org/file2.xml#xpath1(//q[@a=b])

2. URI-s can also use different forms: CIT11111 =(http://www.example.org/file.xml# CIT11111) 3525346

3. The resource is defined like below, with <rdf: Description>

Usually <rdf: Description rdf: about=“” >means referencing an existing resource;<rdf: Description rdf: ID=“” >means creating a new resource;

Page 13: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF resource

<rdf:Description rdf:about=“CIT1111”> <uni:courseName>Discrete Mathematics</uni:courseName> <uni:isTaughtBy rdf:resourse=“#949318”/></ rdf:Description >

<rdf:Description rdf:ID=“949318”> <uni:name>David Bill</uni:name> <uni:title> Associate Professor</uni:title></ rdf:Description >

Resource reference

Page 14: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF property & valueProperty value must be a Literal or a Resource

<uni:courseName>Discrete Mathematics</uni:courseName>

propertyValue

<rdf:type rdf:resource =“&uni;lecturer“/>

Page 15: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF element

1. Root element <rdf: RDF namespace><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:cd="http://www.recshop.fake/cd#">

2. Description element define resource

3. Property eelement define attribute

4. Bag/Seq/Alt element define a few attributes within the property.

See more: http://www.w3schools.com/webservices/ws_rdf_main.asp

Page 16: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Catalog

Semantic Web

RDF

RDF Schema

SPARQL

Page 17: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF Schema

RDF schema is a vocabulary description language for describing properties and classes of RDF resources, with a semantics for generalization hierarchies of such properties and classes.

RDF Schema is a primitive ontology language.

RDFS will use RDF itself to define the semantics of particular domain.

Page 18: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

RDF Schema

Page 19: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Catalog

Semantic Web

RDF

RDF Schema

SPARQL

Page 20: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

SPARQL is the query language to search resource & value;

It is based on matching graph patterns ( like RDF triple pattern, but the resource and value can be variable) ?res uni:phone ?pho

use “?” to define variable, for both string and numeric type

Like in SQL, it has a Select-From-Where structure.

Page 21: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

PREFIX rdf: < http://www.w3.org/1999/02/22-rdf-syntax-ns# >PREFIX uni:<http://www.mydomain.org/uni-ns#>(namespace make quries shorter and easier to read)

Select ?XWhere { ?x uni: phone : 520-543-2340.}

Page 22: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Select ?X ?YWhere { ?x uni: phone ?y}

Page 23: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Select ?name ?YWhere { ?X rdf:type uni:Lecturer; uni: name ?name. ?X uni: phone ?Y.}

Page 24: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Select ?name ?YWhere { ?X rdf:type uni:Lecturer; uni: name ?name. ?X uni: phone ?Y. OPTIONAL{?X uni:phone ?Y}}

Page 25: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Select ?YWhere { ?X rdf:type uni:Lecturer; uni: name :David Bill. ?C uni: phone ?Y. Filter(?X=?C)}

Page 26: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Page 27: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Page 28: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Page 29: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

Page 30: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL1. SPARQL has several query

forms. 2. The CONSTRUCT query

form returns an RDF graph.

Page 31: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

SPARQL

More resources:

http://www.w3.org/TR/rdf-sparql-query/#docResultDesc

http://rdf.myexperiment.org/howtosparql

https://jena.apache.org/tutorials/sparql.html

Page 32: RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015

Thank you!

Q&A