rdf & sparql introduction dongfang xu ph.d student, school of information, university of arizona...
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
RDF & SPARQLIntroduction
Dongfang XuPh .D student, School of Information, University of Arizona
Sept 10, 2015
Catalog
Semantic Web
RDF
RDF Schema
SPARQL
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.
Semantic Web What can be done?
Semantic Web
The Semantic Web Technologies(standard technologies ):
1.Format the web content.
2.Relate the data
Machine-processable web information
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>
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
Catalog
Semantic Web
RDF
RDF Schema
SPARQL
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
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"
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>
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;
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
RDF property & valueProperty value must be a Literal or a Resource
<uni:courseName>Discrete Mathematics</uni:courseName>
propertyValue
<rdf:type rdf:resource =“&uni;lecturer“/>
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
Catalog
Semantic Web
RDF
RDF Schema
SPARQL
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.
RDF Schema
Catalog
Semantic Web
RDF
RDF Schema
SPARQL
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.
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.}
SPARQL
Select ?X ?YWhere { ?x uni: phone ?y}
SPARQL
Select ?name ?YWhere { ?X rdf:type uni:Lecturer; uni: name ?name. ?X uni: phone ?Y.}
SPARQL
Select ?name ?YWhere { ?X rdf:type uni:Lecturer; uni: name ?name. ?X uni: phone ?Y. OPTIONAL{?X uni:phone ?Y}}
SPARQL
Select ?YWhere { ?X rdf:type uni:Lecturer; uni: name :David Bill. ?C uni: phone ?Y. Filter(?X=?C)}
SPARQL
SPARQL
SPARQL
SPARQL
SPARQL1. SPARQL has several query
forms. 2. The CONSTRUCT query
form returns an RDF graph.
SPARQL
More resources:
http://www.w3.org/TR/rdf-sparql-query/#docResultDesc
http://rdf.myexperiment.org/howtosparql
https://jena.apache.org/tutorials/sparql.html
Thank you!
Q&A