Introduction to the Semantic Web Alberto Fernández University Rey Juan Carlos alberto.fernandez@urjc.es 1 2 1
University Rey Juan Carlos Alcorcón Medicine & Health Sciences Vicálvaro Law & Social Sciences Móstoles Fuenlabrada Polytechnic Information and Communication Sciences 3 Profile: Public University Founded in 1997 >29000 students 4 campus in greater Madrid URJC: Computer Science Studies Degrees Degree in Informatics Engineering Degree in Hardware Engineering Degree in Software Engineering Double Degree in Informatics Engineering + Software Engineering Double Degree in Informatics + Business Administration Double Degree in Informatics Engineering + Mathematics Double Degree in Software Engineering + Mathematics Master/Doctorate Advanced Hardware and Software Systems Graphics, Games and Virtual Reality Interactive Informatics and Multimedia Information Systems Engineering Telematics and Informatics Systems Computer Vision 4 2
Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 3. Querying the Semantic Web 4. Linked Data 5 The Semantic Web What is the Web? HTTP (how to transfer data) GET /index.htm URI (how to address data) http://www.ia.urjc.es/ HTML (how to present data to humans) <html> <head> <title>artificial Intelligence Group</title> The problem with the Web Millions of different documents online. Problems: How to find the right documents? How to extract relevant information (from those documents)? How to combine information from different sources? 6 3
How to find the right documents? What is the publications page of Tim Berners-Lee? 7 How to extract relevant information? What is a book about the Web? What is the price? 8 4
How to combine information? I want the cheapest offer of A Semantic Web Primer 9 How to combine information? I want the cheapest offer of A Semantic Web Primer including shipping costs Several clicks to get the shipping costs Alberto Fernandez Universidad Rey Juan Carlos Tulipan s/n Mostoles 28933. Spain 10 5
The Semantic Web Solution Instead of natural language publish machine-understandable information Make queries in terms machine-understandable How? Representing knowledge using standardised Ontologíes Semantic Web: the idea of having data on the Web defined and linked in a way that it can be used by machines not just for display purposes, but for automation, integration and reuse of data across various applications [W3C Semantic Web Activity (http://www.w3.org/2001/sw/)] 11 Ingeniería del Conocimiento 4º Ingeniería Informática Semantic Web Layered Architecture 12 6
Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 1. RDF 2. RDF Schema 3. OWL 3. Querying the Semantic Web 4. Linked Data 13 RDF Resource Description Framework W3C Recommentation http://www.w3.org/rdf/ http://www.w3.org/tr/rdf-primer/ Data model: semantic net Sentence = triple (Subject, Predicate, Object) Subject: resource (URI) or blank node Predicate/Property: binary relation (URI) Object: URI, literal or blank node 14 7
RDF: Example Notation: Turtle <http://www.example.org/index.html> <http://purl.org/dc/elements/1.1/creator> <http://www.example.org/staffid/85740>. <http://www.example.org/index.html> <http://www.example.org/terms/creation-date> "August 16, 1999". <http://www.example.org/index.html> <http://purl.org/dc/elements/1.1/language> "en". more compact (@prefix ex: <http://www.example.org/>.): ex:index.html dc:creator exstaff:85740. ex:index.html exterms:creation-date "August 16, 1999". ex:index.html dc:language "en". 15 RDF: XML syntax. Example <?xml version="1.0"?> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:exterms="http://www.example.org/terms/"> <rdf:description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>august 16, 1999</exterms:creation-date> </rdf:description> <rdf:description rdf:about="http://www.example.org/index.html"> <dc:language>en</dc:language> </rdf:description> <rdf:description rdf:about="http://www.example.org/index.html"> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:description> </rdf:rdf> <rdf:description rdf:about="http://www.example.org/index.html"> <exterms:creation-date>august 16, 1999</exterms:creation-date> <dc:language>en</dc:language> <dc:creator rdf:resource="http://www.example.org/staffid/85740"/> </rdf:description> 16 8
RDF: Blank Nodes Nodes without URI (no needed) Anonymous resources Independent among each other exstaff:85740 exterms:address _:johnaddress. _:johnaddress exterms:street "1501 Grant Avenue". _:johnaddress exterms:city "Bedford". _:johnaddress exterms:state "Massachusetts". _:johnaddress exterms:postalcode "01730". 17 RDF: Literals Data Types The only predefined data types is rdf:xmlliteral Recommendation: XML Schema datatypes (xsd=http://www.w3.org/2001/xmlschema#): xsd:string, xsd:integer, xsd:date, Example ex:index.html exterms:creation-date "1999-08-16"^^xsd:date. <creation-date rdf:datatype="http://www.w3.org/2001/xmlschema#date"> 1999-08-16 </creation-date> <title rdf:datatype="http://www.w3.org/2001/xmlschema#string"> RDF primer </title> 18 9
RDF: Containers and Collections Containers rdf:bag: unordered. May contain duplicates. rdf:seq: ordered. May contain duplicates. rdf:alt: set of alternatives Note: containers are open Collections Closed collections rdf:list, rdf:first,rdf:rest, rdf:nil 19 RDF: Reification Mechanism to turn a statement into a resource So we can make statements about other statements Vocabulary Sentence: rdf:statement rdf:subject, rdf:predicate, rdf:object Example: (ex:index.html dc:creator exstaff:85740.) ex:triple1 rdf:type rdf:statement. ex:triple1 rdf:subject ex:index.html. ex:triple1 rdf:predicate dc:creator. ex:triple1 rdf:object exstaff:85740. 20 10
Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 1. RDF 2. RDF Schema 3. OWL 3. Querying the Semantic Web 4. Linked Data 21 RDF Schema (RDFS) In RDF we talk about individual objects (resources) We would like to reason about classes that define typos of objects For instance, to avoid sentences like (allowed in RDF): SSIM is taught by SSIM (range restriction) Porto F.C. is taught by John (domain restriction) Solution Classes, relations, domain and range restrictions, Example: Courses must be taught by academic staff members only 22 11
RDF Schema (RDFS) W3C Recommendation http://www.w3.org/tr/rdf-schema/ RDFS extends RDF con new primitives Defines a basic language for describing ontologies Fixing the semantics of subclass of Classes and Properties hierarchies Inheritance Domain and Range restrictions 23 RDF Schema (RDFS) Clases (rdfs:class) e Instancias (rdf:type) Class definition <rdf:description rdf:id= Course"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#class"/> </rdf:description> Or <rdfs:class rdf:id="course"/> Instances <Asignatura rdf:id="ssim "/> Class hierarchies (rdfs:subclassof) <rdfs:class rdf:id= Professor"> <rdfs:subclassof rdf:resource="#academisstaff"/> </rdfs:class> 24 12
RDF Schema (RDFS) Properties (rdf:property) <rdf:property rdf:id= taught_by /> Property restrictions (rdfs:domain, rdfs:range) <rdf:property rdf:id="taught_by"> <rdfs:domain rdf:resource="#course"/> <rdfs:range rdf:resource="#academicstaff"/> </rdf:property> Property hierachies (rdfs:subpropertyof) <rdf:property rdf:id= taught_by"> <rdfs:domain rdf:resource="#course"/> <rdfs:range rdf:resource="#academicstaff"/> <rdfs:subpropertyof rdf:resource="#involves"/> </rdf:property> 25 RDF Schema (RDFS) Class domain property domain Course type involves range subpropertyof range taught_by subclassof Professor Staff Academic subclassof Staff subclassof Assistant Professor RDF Schema type type RDF SSIM taught_by Eugenio Oliveira 26 13
RDF Schema (RDFS) Primitives Classes rdfs:resource, rdfs:literal, rdf:xmlliteral, rdfs:class, rdf:property, rdfs:datatype Properties rdf:type, rdfs:subclassof, rdf:subpropertyof, rdfs:domain, rdfs:range, rdfs:label, rdfs:comment Containers rdfs:container, rdf:bag, rdf:seq, rdf:alt, rdfs:containermembershipproperty, rdfs:member Collections rdf:list, rdf:first, rdf:rest, rdf:nil Reification rdf:statement, rdf:predicate, rdf:subject, rdf:object Others rdfs:seealso, rdfs:isdefinedby, rdf:value 27 RDF Schema (RDFS) owns Person domain range Fish Wendy type owns type Wanda type Restriction violation: the range of owns is Fish. OR There is not inconsistency: Wanda is a fish! Marmaid? 28 14
RDFS RDFS limitations It basically allows organise vocabularies in hierarchies Local scope of properties Range restrictions cannot be applied to some classes only It cannot be expressed: Disjoint classes Example: male y female Boolean combinations of classes Example: Person = Man Woman Cardinality restrictions Special characteristics of properties Transitive, symmetric, inverse of, 29 Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 1. RDF 2. RDF Schema 3. OWL 3. Querying the Semantic Web 4. Linked Data 30 15
OWL Web Ontology Language W3C Recommendation http://www.w3.org/2004/owl/ http://www.w3.org/tr/owl-guide/ Language for describing ontologies Extends RDFS, adding primitives to augment expressivity 31 OWL Heading owl:ontology owl:imports: URI ontología owl:versioninfo owl:priorversion: URI ontología owl:backwardcompatiblewith owl:incompatiblewith: it is not backward compatible owl:deprecatedclass owl:deprecatedproperty <owl:ontology rdf:about=""> <owl:versioninfo>v 1.1</owl:versionInfo> <rdfs:comment>an example ontology</rdfs:comment> <owl:imports rdf:resource="http://www.example.org/foo"/> <owl:backwardcompatiblewith rdf:resource="http://www.example.org/vehicle-1.0"/> <owl:priorversion rdf:resource="http://www.example.org/veh-1.0"/> </owl:ontology> 32 16
OWL Classes owl:class owl:class is subclass of rdfs:class <owl:class rdf:id= Course"/> rdfs:subclassof (v) owl:thing: > (superclass of all classes) owl:nothing:? (subclass of all classes) 33 OWL Properties owl:objectproperty owl:datatypeproperty rdfs:subpropertyof (r 1 v r 2 in H) rdfs:domain (9r.> v C or > v 8r.C) rdfs:range (> v 8r.C) 34 17
OWL Property characteristics owl:transitiveproperty: (r + ) p(x,y) p(y,z) p(x,z) (ej: ancestor of ) owl:symmetricproperty: (r r ) p(x,y) p(y,x) (ej: relative of ) owl:functionalproperty: (> v 1 r) p(x,y) p(x,z) y = z (ej: birth year ) owl:inverseof: (r ) p 1 (x,y) p 2 (y,x) owl:inversefunctionalproperty: (> v 1 r - ) p(y,x) p(z,x) y = z (ej: mobile number ) (ej: p 1 = teacher of, p 2 = student of ) 35 OWL Property restrictions owl:restriction owl:onproperty owl:allvaluesfrom: (8r.C) <owl:class rdf:id= Cow"> <rdfs:subclassof rdf:resource="#animal"/> <rdfs:subclassof> <owl:restriction> <owl:onproperty rdf:resource="#eats" /> <owl:allvaluesfrom rdf:resource="#plant" /> </owl:restriction> </rdfs:subclassof> </owl:class> owl:somevaluesfrom: (9r.C) owl:cardinality owl:maxcardinality ( n r) owl:mincardinality ( n r) owl:hasvalue (9r.{a}) 36 18
OWL Complex classes owl:intersectionof: (C u D) owl:unionof: (C t D) owl:complementof: ( C) owl:disjointwith: (C v D) disjoint classes owl:oneof: ({a,b,c} en O) enumerates individuals that belong to a class. Example: {Red, Amber, Green}. <owl:class rdf:id= TrafficLightColor"> <owl:oneof rdf:parsetype="collection"> <Color rdf:about="#red"/> <Color rdf:about="#amber"/> <Color rdf:about="#green"/> </owl:oneof> </owl:class> 37 OWL Ontology mapping owl:equivalentclass ( ) owl:equivalentproperty ( in H) owl:sameas: ({x} {x}) two URIs represent the same individual owl:differentfrom: ({x} {x}) two URIs do not represent the same individual owl:alldifferent owl:distinctmembers <owl:alldifferent> <owl:distinctmembers rdf:parsetype="collection"> <Color rdf:about="#red"/> <Color rdf:about="#ambar"/> <Color rdf:about="#green"/> </owl:distinctmembers> </owl:alldifferent> 38 19
OWL Annotations rdfs:label rdfs:comment rdfs:seealso rdfs:isdefinedby owl:annotationproperty owl:ontologyproperty 39 OWL: inference examples disjointwith example Professor owl:subclassof AcademicStaff. Book owl:subclassof Publication. AcademicStaff owl:disjointwith Publication. Inferred: Professor and Book are disjoints owl:equivalentclass example Man owl:subclassof Person Person owl:equivalentclass Human Inferred: Man is a subclass of Human Instances example A Semantic Web Primer rdf:type Book Book owl:subclassof Publication Inferred: A Semantic Web Primer is a Publication 40 20
Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 3. Querying the Semantic Web 4. Linked Data 41 SPARQL Query Language for RDF W3C Recommendation http://www.w3.org/tr/rdf-sparql-query/ Query language of RDF contents SQL-like sintax 42 21
SPARQL Basic patterns PREFIX rdf: <http://www.w3.org/1999/02/22-rdfsyntax-ns#> SELECT?name?sur WHERE {?x :name?nom.?x :surname?ape.?x rdf:type :Employee. } Group Patterns SELECT?name?sur WHERE { {?x :name?nom.?x :surname?ape. } {?x rdf:type :Employee.} } 43 SPARQL Optional patterns (OPTIONAL) SELECT?name?sur?y WHERE {?x :name?name.?x :surname?sur.?x rdf:type :Employee. OPTIONAL {?x :birth_year?y} } Alternative patterns(union) SELECT?name?y WHERE { {?x :name?name} UNION {?x :surname?sur}.?x rdf:type :Employee.?x :birth_year?a. } 44 22
SPARQL Restrictions (FILTER) SELECT?name?sur WHERE {?x :name?name.?x :surname?sur.?x rdf:type :Employee.?x :birth_year?y. FILTER (?y >= 1980").} Result formats SELECT CONSTRUCT: generates an RDF graph ASK: indicates whether a query pattern matches or not DESCRIBE: returns RDF graph that describes the resources found 45 SPARQL Result modifiers ORDER BY SELECT?name?sur WHERE {?x :name?name.?x :surname?sur. } ORDER BY?sur DISTINCT: avoid duplicates SELECT DISTINCT?name?sur OFFSET / LIMIT SELECT?name?sur WHERE {?x :name?name.?x :surname?sur.} ORDER BY?sur LIMIT 5 OFFSET 3 46 23
Introduction to the Semantic Web 1. Introduction to the Semantic Web 2. Ontology languages 3. Querying the Semantic Web 4. Linked Data 47 Web of Data (Linked Data) We want to query information like: All soccer players, who played as goalkeeper for a club that has a stadium with more than 40.000 seats and who are born in a country with more than 10 million inhabitants From the Web of Documents to the Web of Data Linked Data http://linkeddata.org/ http://www.w3.org/designissues/linkeddata.html http://www.ted.com/talks/tim_berners_lee_on_the_next_web.html (vídeo 16 min) 48 24
Web of Data (Linked Data) Principles of Linked Data (Tim Berners-Lee) 1. Use URIs as names for things 2. Use HTTP URIs so that people can look up those names. 3. When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL) 4. Include links to other URIs so that they can discover more things. 49 The Linking Open Data cloud diagram May 2007 12 datasets Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/ 50 25
The Linking Open Data cloud diagram Sept 2008 45 datasets Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/ 51 The Linking Open Data cloud diagram July 2009 95 datasets Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/ 52 26
The Linking Open Data cloud diagram Sept. 2009 295 datasets 53 Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch. http://lod-cloud.net/ Linked Data Data Generation From existing repositories, e.g. Relational DB, XML, CSV and spreadsheets, etc. to Linked Data Transforming information R2O and ODEMapster OBDI NOR2O Jena geometry2rdf Dynamic generation D2RQ Platform Triplify Ultrawrap 54 27
Linked Data Data Publication Virtuoso Open Source Edition D2R Server AllegroGraph RDFStore Joseki Sesame 55 Linked Data Data visualisation Pubby SNORQL Disco Hyperdata Browser 56 28
Linked Data: data integration [http://www.w3.org/people/ivan/corepresentations/introthroughexample/] [http://www.w3.org/people/ivan/corepresentations/introthroughexample/] 57 Linked Data Some existing Linked Data data sources Dbpedia: http://dbpedia.org/sparql UK Government: http://data.gov.uk/sparql USA Government: http://semantic.data.gov/sparql Musicbrainz: http://dbtune.org/musicbrainz/sparql... 58 29
Example: DBPedia http://dbpedia.org Makes available information from Wikipedia Data generation from structured information extracted from Wikipedia Data publication OpenLink Virtuoso Public SPARQL endpoint: http://dbpedia.org/sparql 59 Example: DBPedia Data visualisation Leipzig query builder http://querybuilder.dbpedia.org OpenLink Interactive SPARQL Query Builder (isparql) http://dbpedia.org/isparql; SNORQL query explorer http://dbpedia.org/snorql any other SPARQL-aware client(s) Other tools DBpedia Faceted Search http://wiki.dbpedia.org/facetedsearch Browser: http://dbpedia.neofonie.de/browse/ Resource example: http://wikipedia.org/wiki/berlin à http://dbpedia.org/resource/berlin 60 30