ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ, ΑΠΘ ΜΕΤΑΠΤΥΧΙΑΚΟ ΠΡΟΓΡΑΜΜΑ ΣΠΟΥΔΩΝ Κατεύθυνση Πληροφοριακών Συστημάτων - 1ο Εξάμηνο Σημασιολογικός Ιστός lpis.csd.auth.gr/mtpx/sw/index.htm.

Slides:



Advertisements
Similar presentations
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
Advertisements

RDF Schemata (with apologies to the W3C, the plural is not ‘schemas’) CSCI 7818 – Web Technologies 14 November 2001 Van Lepthien.
CS570 Artificial Intelligence Semantic Web & Ontology 2
RDF Tutorial.
Of 27 lecture 7: owl - introduction. of 27 ece 627, winter ‘132 OWL a glimpse OWL – Web Ontology Language describes classes, properties and relations.
Chapter 3 Querying RDF stores with SPARQL. TL;DR We will want to query large RDF datasets, e.g. LOD SPARQL is the SQL of RDF SPARQL is a language to query.
Chapter 3 RDF Syntax 1. Topics Basic concepts of RDF resources, properties, values, statements, triples URIs and URIrefs RDF graphs Literals and Qnames.
Dr. Alexandra I. Cristea RDF.
Chapter 3A Semantic Web Primer 1 Chapter 3 Describing Web Resources in RDF Grigoris Antoniou Frank van Harmelen.
More RDF CS 431 – Carl Lagoze – Cornell University Acknowledgements: Eric Miller Dieter Fensel.
Chapter 7: Resource Description Framework (RDF) Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley,
RDF: Building Block for the Semantic Web Jim Ellenberger UCCS CS5260 Spring 2011.
The RDF meta model: a closer look Basic ideas of the RDF Resource instance descriptions in the RDF format Application-specific RDF schemas Limitations.
1 Introduction to Semantic Web with XML RDF Dickson K.W. Chiu PhD, SMIEEE Text: Antoniou & van Harmelen: A Semantic Web PrimerA Semantic Web Primer (Chapter.
Resource Description Framework (RDF) Lecture # 6 Faculty of Computer Science, IBA.
Chapter 3A Semantic Web Primer 1 Chapter 3 Describing Web Resources in RDF Grigoris Antoniou Frank van Harmelen.
Chapter 3A Semantic Web Primer 1 Chapter 3 Querying the Semantic Web Grigoris Antoniou Paul Groth Frank van Harmelen Rinke Hoekstra.
Visual Models for Knowledge Engineering Madalina Croitoru
RDF (Resource Description Framework) Why?. XML XML is a metalanguage that allows users to define markup XML separates content and structure from formatting.
Chapter 3 RDF Schema.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Okech Odhiambo Faculty of Information Technology Strathmore University
The Semantic Web Service Shuying Wang Outline Semantic Web vision Core technologies XML, RDF, Ontology, Agent… Web services DAML-S.
Chapter 3 RDF Syntax. RDF Overview RDF Syntax -- the XML encoding RDF Syntax – variations including N3 RDF Schema (RDFS) Semantics of RDF and RDFS – Axiomatic.
Logics for Data and Knowledge Representation
The Semantic Web Web Science Systems Development Spring 2015.
Chapter 3 Querying RDF stores with SPARQL. Why an RDF Query Language? Why not use an XML query language? XML at a lower level of abstraction than RDF.
RDF and OWL Developing Semantic Web Services by H. Peter Alesso and Craig F. Smith CMPT 455/826 - Week 6, Day Sept-Dec 2009 – w6d21.
© Copyright 2008 STI INNSBRUCK RDF and RDF Schema Semantic Web Lecture Lecture III – xx 2009 Dieter Fensel Slides.
Chapter 3A Semantic Web Primer 1 Chapter 3 Describing Web Resources in RDF Grigoris Antoniou Frank van Harmelen.
Chapter 3 RDF Schema. Introduction RDF has a very simple data model RDF Schema (RDFS) enriches the data model, adding vocabulary and associated semantics.
Of 41 lecture 4: rdf – basics and language. of 41 RDF basic ideas the fundamental concepts of RDF  resources  properties  statements ece 720, winter.
Part I: Set Constructs. RDF Schema (RDFS) RDF does not provide mechanisms to define domain classes and properties RDFS is a vocabulary that provides many.
RDF and XML 인공지능 연구실 한기덕. 2 개요  1. Basic of RDF  2. Example of RDF  3. How XML Namespaces Work  4. The Abbreviated RDF Syntax  5. RDF Resource Collections.
RQL: RDF Query language Jianguo Lu University of Windsor The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer”
Chapter 7: Resource Description Framework (RDF) Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley,
EEL 5937 Ontologies EEL 5937 Multi Agent Systems Lecture 5, Jan 23 th, 2003 Lotzi Bölöni.
Tutorial 13 Validating Documents with Schemas
Of 35 lecture 5: rdf schema. of 35 RDF and RDF Schema basic ideas ece 627, winter ‘132 RDF is about graphs – it creates a graph structure to represent.
RDF Schema (RDFS) RDF user communities need to define the vocabularies (terms) to indicate that they  are describing specific kinds or classes of resources.
Introduction The Resource Description Framework (RDF) is recommended by the World Wide Web Consortium (W3C) to model meta-data about the resources of the.
Introduction to the Semantic Web and Linked Data Module 1 - Unit 2 The Semantic Web and Linked Data Concepts 1-1 Library of Congress BIBFRAME Pilot Training.
Understanding RDF. 2/30 What is RDF? Resource Description Framework is an XML-based language to describe resources. A common understanding of a resource.
Chapter 7: Resource Description Framework (RDF) Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley,
Of 33 lecture 1: introduction. of 33 the semantic web vision today’s web (1) web content – for human consumption (no structural information) people search.
Important Concepts from the W3C RDF Vocabulary/Schema Sungtae Kim SNU OOPSLA Lab. August 19, 2004.
Description of Information Resources: RDF/RDFS (an Introduction)
RDF/RDFS Tutorial. Introduction The Resource Description Framework (RDF) is recommended by the World Wide Web Consortium (W3C) to model meta-data about.
Practical RDF Ch.4 Specialized RDF Relationships: Reification, Containers, and Collections Kim, Jong-Nam SNU OOPSLA Lab. August 12, 2004.
Chapter 3A Semantic Web Primer 1 Chapter 3 Describing Web Resources in RDF Grigoris Antoniou Frank van Harmelen.
Of 38 lecture 6: rdf – axiomatic semantics and query.
RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015.
Chapter 3 RDF Syntax. RDF Overview RDF Syntax -- the XML encoding RDF Syntax – variations including N3 RDF Schema (RDFS) Semantics of RDF and RDFS – Axiomatic.
Knowledge Technologies Manolis Koubarakis 1 Some Other Useful Features of RDF.
Other RDF Capabilities. Exercise: Write the following information into a set of statements (triples) and then draw them into and RDF graph The article.
Describing Web Resources in RDF Semantic Web. Knowledge Technologies Manolis Koubarakis 2 The Semantic Web “Layer Cake”
The Semantic Web SDBI 2010 Most of the slides are book slides of Semantic Web Primer, by Grigoris Antoniou and Frank van Harmelen.
Semantic Web In Depth Resource Description Framework Dr Nicholas Gibbins –
Linked Data & Semantic Web Technology The Semantic Web Part 7. RDF Semantics Dr. Myungjin Lee.
Linked Data & Semantic Web Technology The Semantic Web Part 4. Resource Description Framework (1) Dr. Myungjin Lee.
OWL (Ontology Web Language and Applications) Maw-Sheng Horng Department of Mathematics and Information Education National Taipei University of Education.
Service-Oriented Computing: Semantics, Processes, Agents
Charlie Abela Department of Intelligent Computer Systems
The Semantic Web By: Maulik Parikh.
Resource Description Framework - RDF
Service-Oriented Computing: Semantics, Processes, Agents
Resource Description Framework
Service-Oriented Computing: Semantics, Processes, Agents
ece 720 intelligent web: ontology and beyond
ece 720 intelligent web: ontology and beyond
Presentation transcript:

ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ, ΑΠΘ ΜΕΤΑΠΤΥΧΙΑΚΟ ΠΡΟΓΡΑΜΜΑ ΣΠΟΥΔΩΝ Κατεύθυνση Πληροφοριακών Συστημάτων - 1ο Εξάμηνο Σημασιολογικός Ιστός lpis.csd.auth.gr/mtpx/sw/index.htm Διδάσκων: Ν. Βασιλειάδης Αναπλ. Καθ. Τμ. Πληροφορικής ΑΠΘ Μαθήματα: 5-6

Chapter 3 Describing Web Resources in RDF Grigoris Antoniou Frank van Harmelen

Chapter 3A Semantic Web Primer, 2nd Edition 3-3 Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition 3-4 Drawbacks of XML XML is a universal metalanguage for defining markup It provides a uniform framework for interchange of data and metadata between applications However, XML does not provide any means of talking about the semantics (meaning) of data E.g., there is no intended meaning associated with the nesting of tags – It is up to each application to interpret the nesting.

Chapter 3A Semantic Web Primer, 2nd Edition 3-5 John Smith Algorithms aem153 aem202 … Nesting of tag A in B can be interpreted as: – Α is a part of Β – Α is a subset of Β – Α is a member of Β – Α is a property of Β Nesting of Tags in XML

Chapter 3A Semantic Web Primer, 2nd Edition 3-6 Nesting of Tags in XML David Billington is a lecturer of Discrete Maths David Billington Discrete Maths Opposite nesting, same information!

Chapter 3A Semantic Web Primer, 2nd Edition 3-7 Basic Ideas of RDF All information is represented as a set of Statements Basic building block (statement): object-attribute-value triple (or triplet) – Sentence about Billington is such a statement RDF has been given a syntax in XML – This syntax inherits the benefits of XML – Other syntactic representations of RDF possible

Chapter 3A Semantic Web Primer, 2nd Edition 3-8 Basic Ideas of RDF (2) The fundamental concepts of RDF are: – Resources (objects, sometimes values) – Properties (attributes) – Statements (triplets)

Chapter 3A Semantic Web Primer, 2nd Edition 3-9 Resources We can think of a resource as an object, a “thing” we want to talk about – E.g. authors, books, publishers, places, people, hotels Every resource has a URI, a Universal Resource Identifier A URI can be – a URL (Web address) or – some other kind of unique identifier

Chapter 3A Semantic Web Primer, 2nd Edition 3-10 URIs An identifier does not necessarily enable access to a resource. URI schemes have been defined not only for web- locations – E.g. telephone numbers, ISBN numbers (urn:isbn: Χ), geographic locations, etc. There has been a long discussion about the nature of URIs, even touching philosophical questions – E.g., what is an appropriate unique identifier for a person? – We assume that a URI is the identifier of a Web resource.

Chapter 3A Semantic Web Primer, 2nd Edition 3-11 Properties Properties describe relations between resources – E.g. “written by”, “age”, “title”, etc. Properties are a special kind of resources – Also identified by URIs Advantages of using URIs: – Α global, worldwide, unique naming scheme – Reduces the homonym problem of distributed data representation

Chapter 3A Semantic Web Primer, 2nd Edition 3-12 Statements Statements assert the properties of resources – Similar to a statement in natural language A statement is an object-attribute-value triple – It consists of a resource, a property, and a value – NL view: subject - predicate - object Values can be resources or literals – Literals are atomic values (strings)

Chapter 3A Semantic Web Primer, 2nd Edition 3-13 Three Views of a Statement A triple A piece of a graph A piece of XML code Thus an RDF document can be viewed as: A set of triples A graph (semantic net) An XML document

Chapter 3A Semantic Web Primer, 2nd Edition 3-14 Statements as Triples ( “David Billington” ) The triple (x,P,y) can be considered as a logical formula P(x,y) – Binary predicate P relates object x to object y – RDF offers only binary predicates (properties)

Turtle syntax Terse RDF Triple Language (Turtle) is a text based syntax for RDF. – The file extension used for Turtle text files is “.ttl” “David Billington” A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition 3-16 Statements as Graphs A directed graph with labeled nodes and arcs – from the resource (the subject of the statement) – to the value (the object of the statement) Known in AI as a semantic net The value of a statement may be a resource – Ιt may be linked to other resources

Chapter 3A Semantic Web Primer, 2nd Edition 3-17 A Set of Triples as a Semantic Net

Note on the example In this case, David Bilington should be a resource – NOT a literal Lectures 4 & 5: Knowledge Representation on the Web: Semantic Networks & RDF

Chapter 3A Semantic Web Primer, 2nd Edition 3-19 Statements in XML Syntax Graphs are a powerful tool for human understanding but The Semantic Web vision requires machine- accessible and machine-processable representations There is a 3rd representation based on XML – But XML is not a part of the RDF data model – E.g. serialisation of XML is irrelevant for RDF

Chapter 3A Semantic Web Primer, 2nd Edition 3-20 Statements in XML (2) <rdf:RDF xmlns:rdf=" xmlns:ex=" David Billington subject predicate object

Chapter 3A Semantic Web Primer, 2nd Edition 3-21 Statements in XML (3) An RDF document is represented by an XML element with the tag rdf:RDF The content of this element is a number of descriptions, which use rdf:Description tags. Every description makes a statement about a resource, identified in 3 ways: – an about attribute, referencing an existing resource – an ID attribute, creating a new resource – without a name, creating an anonymous resource

Chapter 3A Semantic Web Primer, 2nd Edition 3-22 Statements in XML (4) The rdf:Description element makes a statement about the resource Within the description – the property is used as a tag – the content is the value of the property

Chapter 3A Semantic Web Primer, 2nd Edition 3-23 Data Types Data types are used in programming languages to allow interpretation In RDF, typed literals are used, if necessary ( “David Billington”, “27”^^

Chapter 3A Semantic Web Primer, 2nd Edition 3-24 Data Types (2) ^^-notation indicates the type of a literal In practice, the most widely used data typing scheme will be the one by XML Schema – But the use of any externally defined data typing scheme is allowed in RDF documents XML Schema predefines a large range of data types – E.g. Booleans, integers, floating-point numbers, times, dates, etc.

Chapter 3A Semantic Web Primer, 2nd Edition 3-25 A Critical View of RDF: Binary Predicates RDF uses only binary properties – This is a restriction because often we use predicates with more than 2 arguments – But binary predicates can simulate these Example: referee(X,Y,Z) – X is the referee in a chess game between players Y and Z

Chapter 3A Semantic Web Primer, 2nd Edition 3-26 A Critical View of RDF: Binary Predicates (2) We introduce: – a new auxiliary resource chessGame – the binary predicates ref, player1, and player2 We can represent referee(X,Y,Z) as: ref(chessGame,X) player1(chessGame,Y) player2(chessGame,Z)

Chapter 3A Semantic Web Primer, 2nd Edition 3-27 A Critical View of RDF: Properties Properties are special kinds of resources – Properties can be used as the object in an object- attribute-value triple (statement) – They are defined independent of resources This possibility offers flexibility But it is unusual for modelling languages and OO programming languages – It can be confusing for modellers

Chapter 3A Semantic Web Primer, 2nd Edition 3-28 A Critical View of RDF: XML Syntax The XML-based syntax of RDF is well suited for machine processing It is not particularly human-friendly – The Semantic Web will not be programmed in RDF, but rather with user-friendly tools that will automatically translate higher representations (e.g. icons) into RDF.

Chapter 3A Semantic Web Primer, 2nd Edition 3-29 A Critical View of RDF: Summary RDF has its idiosyncrasies and is not an optimal modeling language but It is already a de facto standard It has sufficient expressive power – At least as for more layers to build on top Using RDF offers the benefit that information maps unambiguously to a model

Chapter 3A Semantic Web Primer, 2nd Edition 3-30 Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition 3-31 XML-Based Syntax of RDF An RDF document consists of an rdf:RDF element – The content of that element is a number of descriptions A namespace mechanism is used – Disambiguation – Namespaces are expected to be RDF documents defining resources that can be reused – Large, distributed collections of knowledge

Chapter 3A Semantic Web Primer, 2nd Edition 3-32 Example of University Courses <!DOCTYPE rdf:RDF [ ]> <rdf:RDF xmlns:rdf=" xmlns:uni=" David Billington Associate Professor 27

Chapter 3A Semantic Web Primer, 2nd Edition 3-33 Example of University Courses (2) Discrete Maths David Billington Programming III Michael Maher

Chapter 3A Semantic Web Primer, 2nd Edition 3-34 ENTITY definition Entities are like macros (e.g. #define) in programming languages If something is declared as an ENTITY, it can be used in the XML document with (&) in front and (;) at the back – E.g. &xsd;

Chapter 3A Semantic Web Primer, 2nd Edition 3-35 rdf:about versus rdf:ID An element rdf:Description has – An rdf:about attribute indicating that the resource has been “defined” elsewhere, or – An rdf:ID attribute indicating that the resource is defined here Formally, there is no such thing as “defining” an object in one place and referring to it elsewhere – Sometimes is useful (for human readability) to have a defining location, while other locations state “additional” properties

Chapter 3A Semantic Web Primer, 2nd Edition 3-36 Referencing with rdf:about For a correct RDF document, all occurrences of course and staff ID’s (e.g. CIT3112) should be represented by references to the external namespace

Referencing with rdf:about The use of “#” in front of a “local name” indicates that the resource is a part of the current document – The full URI of the resource is obtained by the URI of the current document, plus “#CIT3112” 3-37 A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition 3-38 Property Elements Content of rdf:Description elements Knowledge Representation Grigoris Antoniou uni:courseName and uni:isTaughtBy define two property-value pairs for CIT3116 (two RDF statements) – read conjunctively

Chapter 3A Semantic Web Primer, 2nd Edition 3-39 Data Types The attribute rdf:datatype="&xsd;integer" is used to indicate the data type of the value of the age property David Billington Associate Professor 27

Chapter 3A Semantic Web Primer, 2nd Edition 3-40 Data Types (2) The age property has been defined to have "&xsd;integer" as its range – It is still required to indicate the type of the value of this property each time it is used – This is to ensure that an RDF processor can assign the correct type of the property value even if it has not "seen" the corresponding RDF Schema definition before – This scenario is quite likely to occur in the unrestricted WWW

Chapter 3A Semantic Web Primer, 2nd Edition 3-41 The rdf:resource Attribute The relationships between courses and lecturers (in the example) were not formally defined but existed implicitly through the use of the same name The use of the same name may just be a coincidence for a machine We can denote that two entities are the same using the rdf:resource attribute

Chapter 3A Semantic Web Primer, 2nd Edition 3-42 The rdf:resource Attribute (2) Discrete Mathematics David Billington Associate Professor

Chapter 3A Semantic Web Primer, 2nd Edition 3-43 Referencing Externally Defined Resources E.g., to refer the externally defined resource CIT1111: as the value of rdf:about – is the URI where the definition of CIT1111 is found A description with an ID defines a fragment URI, which can be used to reference the defined description

The rdf:resource Attribute (3) Discrete Mathematics David Billington Associate Professor 3-44 A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition 3-45 Nested Descriptions: Example Discrete Maths David Billington Associate Professor

Chapter 3A Semantic Web Primer, 2nd Edition 3-46 Nested Descriptions Descriptions may be defined within other descriptions Other courses, such as CIT3112, can still refer to the new resource with ID T Although a description may be defined within another description, its scope is global

Chapter 3A Semantic Web Primer, 2nd Edition 3-47 Introducing some Structure to RDF Documents using the rdf:type Element In the examples, the descriptions fall into 2 categories: courses and lecturers. This is clear to human readers It has not been formally declared anywhere It is not accessible to machines In RDF it is possible to make such statements using the rdf:type element.

Chapter 3A Semantic Web Primer, 2nd Edition 3-48 Example of using the rdf:type Element Discrete Maths David Billington Associate Professor

Chapter 3A Semantic Web Primer, 2nd Edition 3-49 Abbreviated Syntax Simplification rules: 1. Childless property elements within description elements may be replaced by XML attributes 2. For description elements with a typing element we can use the name specified in the rdf:type element instead of rdf:Description These rules create syntactic variations of the same RDF statement – They are equivalent according to the RDF data model, although they have different XML syntax

Chapter 3A Semantic Web Primer, 2nd Edition 3-50 Abbreviated Syntax: Example <rdf:type rdf:resource=" uni-ns#course"/> Discrete Maths

Chapter 3A Semantic Web Primer, 2nd Edition 3-51 Application of First Simplification Rule <rdf:Description rdf:ID="CIT1111" uni:courseName="Discrete Maths"> <rdf:type rdf:resource=" uni-ns#course"/>

Chapter 3A Semantic Web Primer, 2nd Edition 3-52 Application of 2nd Simplification Rule <uni:course rdf:ID="CIT1111" uni:courseName="Discrete Maths">

Chapter 3A Semantic Web Primer, 2nd Edition 3-53 Container Elements Collect a number of resources or attributes about which we want to make statements as a whole E.g., we may wish to talk about the courses given by a particular lecturer The content of container elements are named rdf:_1, rdf:_2, etc. – Alternatively rdf:li

Chapter 3A Semantic Web Primer, 2nd Edition 3-54 Three Types of Container Elements rdf:Bag an unordered container, allowing multiple occurrences – E.g. members of the faculty board, documents in a folder rdf:Seq an ordered container, which may contain multiple occurrences – E.g. modules of a course, items on an agenda, an alphabetized list of staff members (order is imposed) rdf:Alt a set of alternatives – E.g. the document home and mirrors, translations of a document in various languages

Chapter 3A Semantic Web Primer, 2nd Edition 3-55 Example for a Bag <uni:lecturer rdf:ID="T949352" uni:name="Grigoris Antoniou" uni:title="Professor">

Chapter 3A Semantic Web Primer, 2nd Edition 3-56 Example for Alternative <uni:course rdf:ID="CIT1111" uni:courseName="Discrete Mathematics">

Chapter 3A Semantic Web Primer, 2nd Edition 3-57 rdf:ID Attribute for Container Elements <uni:lecturer rdf:ID="T949318" uni:name="David Billington">

RDF Collections A limitation of these containers is that there is no way to close them – “these are all the members of the container” – E.g. one may write the following and add one more course to David Billington 3-58 A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition 3-59 RDF Collections (2) RDF provides support for describing groups containing only the specified members, in the form of RDF collections – list structure in the RDF graph – constructed using a predefined collection vocabulary: rdf:List, rdf:first, rdf:rest and rdf:nil It is like Prolog/LISP lists or linked lists in data structures

Chapter 3A Semantic Web Primer, 2nd Edition 3-60 RDF Collections (3) A list with 3 elements …

Chapter 3A Semantic Web Primer, 2nd Edition 3-61 RDF Collections (4) A list with 3 elements Shorthand syntax: – "Collection" value for the rdf:parseType attribute:

Parsing RDF/XML There are many RDF parsers, i.e. tools that take as input and RDF/XML document and output a set of RDF triples – These are called “explicit triplets” The most prominent one is the W3C RDF parser/validator – A Semantic Web Primer, 2nd EditionChapter 3

W3C RDF Validation/Parsing 3-63 A Semantic Web Primer, 2nd EditionChapter 3

RDF Validation Results - Triples 3-64 A Semantic Web Primer, 2nd EditionChapter 3 "David Billington". "Associate Professor" "27"^^. "Discrete Maths".

RDF Validation Results - Graph 3-65 A Semantic Web Primer, 2nd EditionChapter 3

@prefix rdf:. uni:CIT1111 uni:courseName "Discrete Maths"; uni:isTaughtBy uni:T uni:T uni:age "27"^^ ; uni:name "David Billington"; uni:title "Associate Professor". Turtle syntax 3-66 A Semantic Web Primer, 2nd Edition The sign “;” indicates that the subsequent triples share the same subject with the first triple This is how namespaces are declared Chapter 3

Turtle syntax (or N3) You can use – – Other features of Turtle syntax: – Allows to abbreviate common data types uni:T uni:age 27. – Named graphs: a way to treat a set of triples as a single resource 3-67 A Semantic Web Primer, 2nd EditionChapter 3

Named dc:. { dc:creator } { uni:CIT1111 uni:courseName "Discrete Maths"; uni:isTaughtBy uni:T uni:T uni:age "27"^^ ; uni:name "David Billington"; uni:title "Associate Professor". } 3-68 A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition 3-69 Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition 3-70 Basic Ideas of RDF Schema RDF is a universal language that lets users describe resources in their own vocabularies – RDF does not assume, nor does it define semantics of any particular application domain The user can do so in RDF Schema using: – Classes and Properties – Class Hierarchies and Inheritance – Property Hierarchies

Chapter 3A Semantic Web Primer, 2nd Edition 3-71 Classes and their Instances We must distinguish between – Concrete “things” (individual objects) in the domain: Discrete Maths, David Billington etc. – Sets of individuals sharing properties called classes: lecturers, students, courses etc. Individual objects that belong to a class are referred to as instances of that class The relationship between instances and classes in RDF is through rdf:type

Chapter 3A Semantic Web Primer, 2nd Edition 3-72 Why Classes are Useful Impose restrictions on what can be stated in an RDF document using the schema – As in programming languages – E.g. A+1, where A is an array – Disallow nonsense from being stated

Chapter 3A Semantic Web Primer, 2nd Edition 3-73 Nonsensical Statements disallowed through the Use of Classes Discrete Maths is taught by Concrete Maths – We want courses to be taught by lecturers only – Restriction on values of the property “is taught by” (range restriction) Room MZH5760 is taught by David Billington – Only courses can be taught – This imposes a restriction on the objects to which the property can be applied (domain restriction)

Chapter 3A Semantic Web Primer, 2nd Edition 3-74 Class Hierarchies Classes can be organised in hierarchies – A is a subclass of B if every instance of A is also an instance of B – Then B is a superclass of A A subclass graph need not be a tree – A class may have multiple superclasses

Chapter 3A Semantic Web Primer, 2nd Edition 3-75 Class Hierarchy Example

Chapter 3A Semantic Web Primer, 2nd Edition 3-76 Inheritance in Class Hierarchies Range restriction: Courses must be taught by academic staff members only Michael Maher is a professor – He inherits the ability to teach from the class of academic staff members This is done in RDF Schema by fixing the semantics of “is a subclass of” – It is not up to an application (RDF processing software) to interpret “is a subclass of”

Chapter 3A Semantic Web Primer, 2nd Edition 3-77 Differences with Object-Oriented Programming In OO programming, an object class defines the properties that apply to it. – To add new properties we modify the class. In RDFS, properties are defined globally – Not encapsulated as attributes in class definitions – Define new properties for an existing class without changing the class Use classes defined by others and adapt them to our requirements through new properties. – Another idiosyncratic feature of RDF/RDFS.

Chapter 3A Semantic Web Primer, 2nd Edition 3-78 Property Hierarchies Hierarchical relationships for properties – E.g., “is taught by” is a subproperty of “involves” – If a course C is taught by an academic staff member A, then C also involves Α The converse is not necessarily true – E.g., A may be the teacher of the course C, or – a tutor who marks student homework but does not teach C P is a subproperty of Q, if Q(x,y) is true whenever P(x,y) is true – E.g. father is a subproperty of parent

Chapter 3A Semantic Web Primer, 2nd Edition 3-79 RDF Layer vs RDF Schema Layer Discrete Mathematics is taught by David Billington The schema is itself written in a formal language, RDF Schema, that can express its ingredients: – subClassOf, Class, Property, subPropertyOf, Resource, etc.

RDF Layer vs RDF Schema Layer (2) Chapter A Semantic Web Primer, 2nd Edition

Chapter 3A Semantic Web Primer, 2nd Edition 3-81 Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition 3-82 RDF Schema in RDF The modeling primitives of RDF Schema are defined using resources and properties (RDF itself is used!) To declare that “lecturer” is a subclass of “academic staff member” – Define resources lecturer, academicStaffMember – define property subClassOf – Write triple (lecturer, subClassOf, academicStaffMember) We use the XML-based syntax of RDF

Chapter 3A Semantic Web Primer, 2nd Edition 3-83 Core Classes rdfs:Resource, the class of all resources rdfs:Class, the class of all classes rdfs:Literal, the class of all literals (strings) rdf:Property, the class of all properties.

Chapter 3A Semantic Web Primer, 2nd Edition 3-84 Core Properties rdf:type, relates a resource to its class – The resource is declared to be an instance of that class rdfs:subClassOf, relates a class to one of its superclasses – All instances of a class are instances of its superclass rdfs:subPropertyOf, relates a property to one of its superproperties

Chapter 3A Semantic Web Primer, 2nd Edition 3-85 Core Properties (2) rdfs:domain, specifies the domain of a property P – The class of those resources that may appear as subjects in a triple with predicate P – If the domain is not specified, then any resource can be the subject rdfs:range, specifies the range of a property P – The class of those resources that may appear as values in a triple with predicate P

Chapter 3A Semantic Web Primer, 2nd Edition 3-86 Examples (abbreviated syntax) <rdfs:range rdf:resource=" 2000/01/rdf-schema#Literal"/>

Chapter 3A Semantic Web Primer, 2nd Edition 3-87 Examples (long syntax)

Chapter 3A Semantic Web Primer, 2nd Edition 3-88 Relationships Between Core Classes and Properties rdfs:subClassOf and rdfs:subPropertyOf are transitive, by definition rdfs:Class is a subclass of rdfs:Resource – Because every class is a resource rdfs:Resource is an instance of rdfs:Class – rdfs:Resource is the class of all resources, so it is a class Every class is an instance of rdfs:Class – For the same reason

Chapter 3A Semantic Web Primer, 2nd Edition 3-89 Subclass Hierarchy of some Modeling Primitives of RDF Schema

Chapter 3A Semantic Web Primer, 2nd Edition 3-90 Instance Relationships of some Modeling Primitives of RDFS

Chapter 3A Semantic Web Primer, 2nd Edition 3-91 Instance Relationships of Some Core Properties of RDF and RDF Schema

Chapter 3A Semantic Web Primer, 2nd Edition 3-92 Containers rdf:Bag, the class of bags rdf:Seq, the class of sequences rdf:Alt, the class of alternatives rdfs:Container, the superclass of all container classes, including the 3 above

Chapter 3A Semantic Web Primer, 2nd Edition 3-93 Utility Properties rdfs:seeAlso relates a resource to another resource that explains it rdfs:isDefinedBy is a subproperty of rdfs:seeAlso and relates a resource to the place where its definition, typically an RDF schema, is found rfds:comment. Comments, typically longer text, can be associated with a resource rdfs:label. A human-friendly label (name) is associated with a resource

Chapter 3A Semantic Web Primer, 2nd Edition 3-94 Example: A University The class of lecturers. All lecturers are academic staff members. <rdfs:subClassOf rdf:resource="#academicStaffMember"/>

Chapter 3A Semantic Web Primer, 2nd Edition 3-95 Example: A University (2) The class of academic staff members The class of staff members

Chapter 3A Semantic Web Primer, 2nd Edition 3-96 Example: A University (3) The class of courses It relates only courses to lecturers

Chapter 3A Semantic Web Primer, 2nd Edition 3-97 Example: A University (4) Inherits its domain ("course") and range ("lecturer") from its superproperty "involves"

Chapter 3A Semantic Web Primer, 2nd Edition 3-98 Example: A University (5) It is a property of staff members and takes literals as values.

Chapter 3A Semantic Web Primer, 2nd Edition 3-99 Class Hierarchy for the Motor Vehicles Example

Chapter 3A Semantic Web Primer, 2nd Edition Example: Motor Vehicles (1) <rdf:RDF xmlns:rdf=" xmlns:rdfs="

Chapter 3A Semantic Web Primer, 2nd Edition Example: Motor Vehicles (2)

Chapter 3A Semantic Web Primer, 2nd Edition Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition The Namespace of RDF <rdfs:Class rdf:ID="Property" rdfs:comment=" The class of properties "/> The class of unordered containers

Chapter 3A Semantic Web Primer, 2nd Edition The Namespace of RDF (2) The class of RDF Lists The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it

The Namespace of RDF (3) The subject is an instance of a class The first item in the subject RDF list The rest of the subject RDF list after the first item A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition The Namespace of RDF Schema <rdfs:Class rdf:ID="Resource" rdfs:comment="The most general class"/> <rdfs:Class rdf:ID="Class" rdfs:comment="The concept of classes. All classes are resources"/> <rdf:Property rdf:ID="comment" rdfs:comment="Use this for descriptions"/>

Chapter 3A Semantic Web Primer, 2nd Edition The Namespace of RDF Schema (2) <rdfs:domain rdf:resource=" 1999/02/22-rdf-syntax-ns#Property"/> <rdfs:range rdf:resource=" 1999/02/22-rdf-syntax-ns#Property"/>

Chapter 3A Semantic Web Primer, 2nd Edition Namespace versus Semantics Consider rdfs:subClassOf – The namespace specifies only that it applies to classes and has a class as a value – The meaning of being a subclass not expressed The meaning cannot be expressed in RDF – If it could, RDF Schema would be unnecessary External definition of semantics required – Respected by RDF/RDFS processing software

Chapter 3A Semantic Web Primer, 2nd Edition Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition Problem of Axiomatic Semantics The described axiomatic semantics can be used for automated reasoning with RDF and RDF Schema. It requires a first-order logic proof system. – This is a very heavy requirement It is unlikely to scale when millions of statements are involved – E.g. millions of statements of the form Type(?r, ?c)

Chapter 3A Semantic Web Primer, 2nd Edition Semantics based on Inference Rules Semantics in terms of RDF triples instead of restating RDF in terms of first-order logic – Plus sound and complete inference systems This inference system consists of inference rules of the form: IF E contains certain triples THEN add to E certain additional triples where E is an arbitrary set of RDF triples – Usually the set of explicit triples of an RDF document

Inference rules (or entailments) Inference rules add new triples to an existing set of triples so that a query can retrieve the correct set of triples according to RDF/S semantics Entailments are “materialized” conclusions of inference rules A Semantic Web Primer, 2nd EditionChapter 3

Inference / Query Process A Semantic Web Primer, 2nd Edition Original (explicit) set of triples RDF document translation RDF/S Inference rules input Inferred (implicit) set of triples output Set of all triples Query Chapter 3

A simple rule language The condition of a rule contains patterns of triples that are “searched” (or “matched”) against the current set of triples – Both explicit and implicit If the condition of the rule is true (i.e. there are triples that match the pattern), then the pattern of triples of the conclusion are added to the current set of triples (or triple DB) A Semantic Web Primer, 2nd EditionChapter 3

Constants and Variable Constants are RDF/S “reserved” names (classes/properties) – They could also be literals or resource names Variables begin with ? – They denote any value that could match the pattern in this place – Variables are logical ones: once they match with a value, they keep it throughout rule evaluation A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition Examples of Inference Rules (1) Any resource ?p that is used in the property position of a triple can be inferred to be a member of the class rdf:Property. IF ?x ?p ?y. THEN?p rdf:type rdf:Property. Example (explicit triple): uni:CIT1111 uni:courseName "Discrete Maths". Conclusion (implicit triple): uni:courseName rdf:type rdf:Property.

Chapter 3A Semantic Web Primer, 2nd Edition Examples of Inference Rules (2a) Definition of the meaning of rdfs:subClassOf IF ?x rdf:type ?u. and ?u rdfs:subClassOf ?v. THEN ?x rdf:type ?v. Example (explicit triple): uni:CIT1111 rdf:type uni:PostGraduateCourse. uni:PostGraduateCourse rdfs:subClassOf uni:Course. Conclusion (implicit triple): uni:CIT1111 rdf:type uni:Course.

Examples of Inference Rules (2b) Transitivity of the subclass relation IF ?u rdfs:subClassOf ?v. and ?v rdfs:subclassOf ?w. THEN ?u rdfs:subClassOf ?w. Example (explicit triple): uni:Lecturer rdfs:subClassOf uni:Faculty. uni:Faculty rdfs:subClassOf uni:Staff. Conclusion (implicit triple): uni:Lecturer rdfs:subClassOf uni:Staff A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition Examples of Inference Rules (3a) Any resource ?y which appears as the value of a property ?p can be inferred to be a member of the range of ?p – This shows that range definitions in RDF Schema are not used to restrict the range of a property, but rather to infer the membership of the range IF ?x ?p ?y. and ?p rdfs:range ?u. THEN ?y rdf:type ?u.

Examples of Inference Rules (3b) IF ?x ?p ?y. and ?p rdfs:range ?u. THEN ?y rdf:type ?u. Example (explicit triple): uni:T uni:teaches uni:CIT1111. uni:teaches rdfs:range uni:Course. Conclusion (implicit triple): uni:CIT1111 rdf:type uni:Course A Semantic Web Primer, 2nd EditionChapter 3

Other entailment rules (a) Domain IF ?x ?p ?y. and ?p rdfs:domain ?u. THEN ?x rdf:type ?u. Example (explicit triple): uni:T uni:teaches uni:CIT1111. uni:teaches rdfs:domain uni:Faculty. Conclusion (implicit triple): uni:T rdf:type uni:Faculty A Semantic Web Primer, 2nd EditionChapter 3

Other entailment rules (b) Every node of the semantic net is a Resource IF ?x ?p ?y. THEN ?x rdf:type rdfs:Resource. IF ?x ?p ?y. THEN ?y rdf:type rdfs:Resource. Example (explicit triple): uni:T uni:teaches uni:CIT1111. Conclusion (implicit triple): uni:T rdf:type rdfs:Resource. uni:CIT1111 rdf:type rdfs:Resource A Semantic Web Primer, 2nd EditionChapter 3

Sub-property entailment rules (a) What it means to be a subproperty IF ?a rdfs:subPropertyOf ?b. and ?x ?a ?y. THEN ?x ?b ?y. Example (explicit triple): uni:CIT1111 uni:isTaughtBy uni:T uni:isTaughtBy rdfs:subPropertyOf uni:involves. Conclusion (implicit triple): uni:CIT1111 uni:involves uni:T A Semantic Web Primer, 2nd EditionChapter 3

Sub-property entailment rules (b) Transitivity of subproperty relation IF ?u rdfs:subPropertyOf ?v. and ?v rdfs:subPropertyOf ?w. THEN ?u rdfs:subPropertyOf ?w. Example (explicit triple): ex:father rdfs:subPropertyOf ex:parent. ex:parent rdfs:subPropertyOf ex:ancestor. Conclusion (implicit triple): ex:father rdfs:subPropertyOf ex:ancestor Lectures 4 & 5: Knowledge Representation on the Web: Semantic Networks & RDF

Sub-property inheritance of domain/range (a) IF ?a rdfs:subPropertyOf ?b. and ?b rdfs:domain ?u. THEN ?a rdfs:domain ?u. IF ?a rdfs:subPropertyOf ?b. and ?b rdfs:range ?u. THEN ?a rdfs:range ?u A Semantic Web Primer, 2nd EditionChapter 3

Sub-property inheritance of domain/range (b) Example (explicit triple): uni:isTaughtBy rdfs:subPropertyOf uni:involves. uni:involves rdfs:domain uni:Course. uni:involves rdfs:range uni:Staff. Conclusion (implicit triple): uni:isTaughtBy rdfs:domain uni:Course. uni:isTaughtBy rdfs:range uni:Staff A Semantic Web Primer, 2nd EditionChapter 3

RDF/RDFS inference uni:lecturer rdf:type rdfs:Class. uni:course rdf:type rdfs:Class. uni:teaches rdf:type rdf:Property. uni:teaches rdfs:domain uni:lecturer. uni:teaches rdfs:range uni:course. uni:smith rdf:type uni:lecturer. uni:smith uni:teaches uni:math. Conclusion: uni:math rdf:type uni:course A Semantic Web Primer, 2nd Edition IF ?x ?p ?y. and ?p rdfs:range ?u. THEN ?y rdf:type ?u. Chapter 3

RDF/RDFS inference (2) uni:lecturer rdf:type rdfs:Class. uni:course rdf:type rdfs:Class. uni:teaches rdf:type rdfs:Property. uni:teaches rdfs:domain uni:lecturer. uni:teaches rdfs:range uni:course. uni:smith rdf:type uni:lecturer. uni:smith uni:teaches uni:jones. Conclusion: uni:jones rdf:type uni:course. !! A Semantic Web Primer, 2nd EditionChapter 3

RDF/RDFS inference (2’) uni:lecturer rdf:type rdfs:Class. uni:course rdf:type rdfs:Class. uni:teaches rdf:type rdfs:Property. uni:teaches rdfs:domain uni:lecturer. uni:teaches rdfs:range uni:course. uni:smith rdf:type uni:lecturer. uni:jones rdf:type uni:lecturer. uni:smith uni:teaches uni:jones. Conclusion: uni:jones rdf:type uni:course. !!!!!!!!! A Semantic Web Primer, 2nd EditionChapter 3

A Semantic Web Primer, 2nd Edition RDF/RDFS inference (2’) - explanation An instance can have multiple types simultaneously! – It can be an instance of multiple classes! – It can belong to different classes, because each resource can have multiple roles in general! – It belongs to the intersection of the classes. Big difference with OO programming!

… BUT (being instance of multiple classes) When a resource is an instance of two classes … but the two classes have a hierarchical (subClassOf) relationship then the most special class is the class of the resource A Semantic Web Primer, 2nd EditionChapter 3

Example of being an instance of multiple classes when one is subclass of the other Example (explicit triple): uni:Faculty rdfs:subClassOf uni:Staff. uni:isTaughtBy rdfs:subPropertyOf uni:involves. uni:isTaughtBy rdfs:domain uni:Course. uni:isTaughtBy rdfs:range uni:Faculty. uni:involves rdfs:domain uni:Course. uni:involves rdfs:range uni:Staff. uni:CIT1111 rdf:type uni:Course. uni:T rdf:type uni:Faculty. uni:CIT1111 uni:isTaughtBy uni:T Conclusion (implicit triple): uni:CIT1111 uni:involves uni:T uni:isTaughtBy rdfs:domain uni:Course. We already know that! uni:CIT1111 rdf:type uni:Course. We already know that! uni:isTaughtBy rdfs:range uni:Staff. Faculty  Staff  Faculty  Staff  Faculty uni:T rdf:type uni:Staff. We already know that! (from subclass entailment) Faculty  Staff  x  Faculty  x  Staff A Semantic Web Primer, 2nd Edition When an inferred triple is already present in the set of triples (either explicit or implicit), it is NOT inserted again! Chapter 3

A Semantic Web Primer, 2nd Edition Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data

Chapter 3A Semantic Web Primer, 2nd Edition Why an RDF Query Language? Different XML Representations XML at a lower level of abstraction than RDF There are various ways of syntactically representing an RDF statement in XML Thus we would require several XQuery queries, e.g. – //uni:lecturer/uni:title if uni:title element – if uni:title attribute – Both XML representations equivalent!

Chapter 3A Semantic Web Primer, 2nd Edition Why an RDF Query Language? Understanding the Semantics Grigoris Antoniou David Billington A query for the names of all lecturers should return both Grigoris Antoniou and David Billington

SPARQL Query Language A W3C Recommendation for querying RDF – Specification 1.0: – Specification 1.1: / / All major RDF query tools had implemented support for SPARQL Chapter 3A Semantic Web Primer, 2nd Edition

Triple stores To perform a SPARQL query, one needs software to execute the query. – Called Triple Store or Graph Store (e.g. a database for RDF) – Sesame (70 million), OpenLink Virtuoso (>15.4 billion), OWLIM (>12 b), Apache Jena (200 m), AllegroGraph (1 trillion), IBM DB2, Oracle, 4store (15 b), Bigdata (12.7 b), YARS2 (7 b), Mulgara (500 m), … A Semantic Web Primer, 2nd EditionChapter 3

Loading triples Before one can query a triple store, it needs to be populated with RDF. Most triple stores provide bulk upload options. SPARQL Update: provides a series of mechanisms for inserting, loading, and deleting RDF into a triple store A Semantic Web Primer, 2nd EditionChapter 3

SPARQL protocol A triple store can be queried by sending SPARQL queries using the SPARQL protocol. Each triple store provides an endpoint, where SPARQL queries can be submitted. Clients can send queries to an endpoint using the HTTP protocol. – You can issue a SPARQL query to an endpoint by entering it into the browser’s URL bar – It’s preferable to have a client designed specifically for SPARQL A Semantic Web Primer, 2nd EditionChapter 3

Dbpedia SPARQL endpoint A Semantic Web Primer, 2nd Edition More endpoints can be found at: Chapter 3

Basic Idea SPARQL is based on matching graph patterns Simplest graph pattern = triple pattern – like an RDF triple – a variable can be in the position of the subject, predicate, or object Combining triple patterns gives a basic graph pattern – An exact match to a graph is needed Chapter 3A Semantic Web Primer, 2nd Edition

Basic Query Example PREFIX rdf: PREFIX rdfs: SELECT ?c WHERE { ?c rdf:type rdfs:Class. } Chapter 3A Semantic Web Primer, 2nd Edition

Query Explanation Retrieve all triple patterns – where the property is rdf:type, and – the object is rdfs:Class – I.e. Retrieve all classes SPARQL allows to define prefixes for namespaces – Use prefixes in the query pattern, to make queries shorter and easier to read Chapter 3A Semantic Web Primer, 2nd Edition

Get all instances of a class PREFIX uni: SELECT ?i WHERE { ?i rdf:type uni:course. } Chapter 3A Semantic Web Primer, 2nd Edition

SPARQL and RDF Semantics SPARQL makes no explicit commitment to support RDFS semantics. The result depends on whether the system answering the query supports RDFS semantics. – If yes, then result will include all instances of the subclasses of course. – If not, it will only retrieve those instances that are explicitly of type course. Chapter 3A Semantic Web Primer, 2nd Edition

Using select-from-where SELECT specifies the projection: – the number and order of retrieved data FROM specifies the source being queried – Optional – When not specified, assume querying the knowledge base of a particular system. WHERE imposes constraints on solutions – Graph pattern templates and boolean constraints Chapter 3A Semantic Web Primer, 2nd Edition

Example Retrieve all phone numbers of staff members SELECT ?x ?y WHERE { ?x uni:phone ?y. } ?x, ?y – variables ?x uni:phone ?y – A resource-property-value triple pattern Chapter 3A Semantic Web Primer, 2nd Edition

Implicit Join Retrieve all lecturers and their phone numbers SELECT ?x ?y WHERE { ?x rdf:type uni:Lecturer ; uni:phone ?y. } Chapter 3A Semantic Web Primer, 2nd Edition Collects all instances of class Lecturer and binds result to variable ?x Syntax shortcut: a semicolon ; indicates that the following triple pattern shares its subject with the previous one. Collects all triples with predicate phone Implicit join: restrict the 2nd pattern only to those triples whose subject is ?x

Equivalent Query SELECT ?x ?y WHERE { ?x rdf:type uni:Lecturer. ?x uni:phone ?y. } Chapter 3A Semantic Web Primer, 2nd Edition

Retrieve all information about (1) SELECT ?x ?p ?o WHERE { ?x rdf:type uni:Lecturer ; ?p ?o. } A Semantic Web Primer, 2nd EditionChapter 3

Retrieve all information about (2) SELECT ?p ?o WHERE { uni:T rdf:type uni:Lecturer ; ?p ?o. } Or SELECT ?p ?o WHERE { uni:T ?p ?o. } A Semantic Web Primer, 2nd EditionChapter 3

Limiting results On large data sets we may write queries that can return millions of triples. – E.g. ?i rdf:type dbpedia-owl:Place It is good practice to limit the number of answers a query returns – Public endpoints (e.g. DBPedia) A Semantic Web Primer, 2nd EditionChapter 3

LIMIT PREFIX dbpedia-owl:. SELECT ?i WHERE { ?i rdf:type dbpedia-owl:Place. } LIMIT A Semantic Web Primer, 2nd EditionChapter 3

Explicit Join Retrieve names of courses taught by lecturer with ID T SELECT ?n WHERE { ?x rdf:type uni:Course ; uni:isTaughtBy :T ?c uni:name ?n. FILTER (?c = ?x). } Chapter 3A Semantic Web Primer, 2nd Edition FILTER condition: a boolean constraint Explicit join of variables ?c, ?x using equality ( = ) operator.

Another Example with FILTER SELECT ?x ?y WHERE { ?x rdf:type uni:Lecturer ; uni:age ?y. FILTER (?y > 30). } Chapter 3A Semantic Web Primer, 2nd Edition

SPARQL built-in filter functions Logical: !, &&, || Math: +, -, *, / Comparison: =, !=, >, <,... SPARQL tests: isURI, isBlank, isLiteral, bound SPARQL accessors: str, lang, datatype Strings (SPARQL 1.1): STRLEN, SUBSTR, UCASE, LCASE, STRSTARTS, STRENDS, CONTAINS, CONCAT, … More math (SPARQL 1.1): abs, round, ceil, floor, RAND Date/time (SPARQL 1.1): now, year, month, day, hours, minutes, seconds, timezone Chapter 3A Semantic Web Primer, 2nd Edition

Optional Patterns The graph patterns so far are mandatory – Either the knowledge base matches the complete pattern, in which case an answer is returned, – or – it doesn’t, in which case the query does not produce a result. However, in many cases we may wish to be more flexible. Chapter 3A Semantic Web Primer, 2nd Edition

Example RDF fragment Grigoris Antoniou David Billington Chapter 3A Semantic Web Primer, 2nd Edition

Optional patterns - Example This fragment contains information on two lecturers. – For one lecturer it only lists the name – For the other it also lists the address. We want to query for all lecturers and their e- mail addresses Chapter 3A Semantic Web Primer, 2nd Edition

Querying with mandatory patterns SELECT ?name ? WHERE { ?x rdf:type uni:Lecturer ; uni:name ?name ; uni: ? . } Chapter 3A Semantic Web Primer, 2nd Edition

Querying with mandatory patterns Result ?name? David Chapter 3A Semantic Web Primer, 2nd Edition Despite the fact that Grigoris Antoniou is listed as a lecturer, the query does not return his name. The query pattern does not match because he has no address.

Querying with optional patterns SELECT ?name ? WHERE { ?x rdf:type uni:Lecturer ; uni:name ?name. OPTIONAL { ?x uni: ? } } Chapter 3A Semantic Web Primer, 2nd Edition Meaning: "give all the names of lecturers, and if known also their addresses"

Querying with optional patterns Result Chapter 3A Semantic Web Primer, 2nd Edition ?name? Grigoris Antoniou David

Querying alternatives We want a contact detail for all lecturers – This can be either a phone or an SELECT ?name ?contact WHERE { ?x rdf:type uni:Lecturer ; uni:name ?name. {?x uni:phone ?contact.} UNION {?x uni: ?contact.} } Chapter 3A Semantic Web Primer, 2nd Edition

Results of UNION ?name?contact Harald9922 nbassili97913 Chapter 3A Semantic Web Primer, 2nd Edition People with both contact details will be included twice in the result

Querying alternatives If we don’t want the same person twice we must choose the most preferred contact detail (e.g. phone) and write a different query SELECT ?x ?contact WHERE { ?x rdf:type :Faculty. {?x :phone ?contact.} UNION {?x : ?contact. OPTIONAL { ?x :phone ?p. } FILTER(!bound(?p)) } Chapter 3A Semantic Web Primer, 2nd Edition In case the lecturer has also a phone, filter him out! (Variable ?p should not be bound)

Results of UNION + OPTIONAL + FILTER ?name?contact Harald9922 nbassili97913 Chapter 3A Semantic Web Primer, 2nd Edition

SPARQL 1.1 Property Paths Property Paths give a more succinct way to write parts of basic graph patterns and also extend matching of triple pattern to arbitrary length paths. Property paths do change any existing SPARQL query. Chapter 3A Semantic Web Primer, 2nd Edition

Simple Paths: Sequence Find the name of any people that Alice knows. { ?x foaf:mbox. ?x foaf:knows/foaf:name ?name. } This is equivalent to: { ?x foaf:mbox. ?x foaf:knows ?y. ?y foaf:name ?name. } Chapter 3A Semantic Web Primer, 2nd Edition

Complex Paths Find the names of all the people that can be reached from Alice by foaf:knows { ?x foaf:mbox. ?x foaf:knows+/foaf:name ?name. } Chapter 3A Semantic Web Primer, 2nd Edition or more

Limited Inference Capabilities All classes and super-classes ?c of a resource: { uni:nick rdf:type/rdfs:subClassOf* ?c } All direct and indirect instances ?x of a class: { ?x rdf:type/rdfs:subClassOf* uni:Person } Chapter 3A Semantic Web Primer, 2nd Edition or more

DISTINCT - rationale Find all Greek cities with a University select ?c where { ?u rdf:type dbpedia-owl:University. ?u dbpedia-owl:country dbpedia:Greece. ?u dbpedia-owl:city ?c. } A Semantic Web Primer, 2nd EditionChapter 3

Result A Semantic Web Primer, 2nd Edition c duplicates Chapter 3

DISTINCT Find all Greek cities with a University select DISTINCT ?c where { ?u rdf:type dbpedia-owl:University. ?u dbpedia-owl:country dbpedia:Greece. ?u dbpedia-owl:city ?c. } A Semantic Web Primer, 2nd EditionChapter 3

Results A Semantic Web Primer, 2nd Edition c … No duplicates unordered Chapter 3

ORDER BY Find all Greek cities with a University select DISTINCT ?c where { ?u rdf:type dbpedia-owl:University. ?u dbpedia-owl:country dbpedia:Greece. ?u dbpedia-owl:city ?c. } ORDER BY ?c A Semantic Web Primer, 2nd EditionChapter 3

Results A Semantic Web Primer, 2nd Edition No duplicates Ordered c … How many? Chapter 3

COUNT Find how many Greek cities have a University select count(?c) as ?TotalCities where { ?u rdf:type dbpedia-owl:University. ?u dbpedia-owl:country dbpedia:Greece. ?u dbpedia-owl:city ?c. } A Semantic Web Primer, 2nd Edition TotalCities 68 Result Can’t be!!! Chapter 3

COUNT DISTINCT Find how many Greek cities have a University select count(DISTINCT ?c) as ?TotalCities where { ?u rdf:type dbpedia-owl:University. ?u dbpedia-owl:country dbpedia:Greece. ?u dbpedia-owl:city ?c. } A Semantic Web Primer, 2nd Edition TotalCities 3838 Result Chapter 3

Lecture Outline 1. Basic Ideas of RDF 2. XML-based Syntax of RDF 3. Basic Concepts of RDF Schema 4. Τhe Language of RDF Schema 5. The Namespaces of RDF and RDF Schema 6. Direct Semantics based on Inference Rules 7. Querying of RDF/RDFS Documents using SPARQL 8. Linked Open Data A Semantic Web Primer, 2nd EditionChapter 3

Linked Open Data Linked Data is about using the Web to – connect related data that wasn't previously linked, or – lower the barriers to linking data currently linked using other methods A recommended best practice for exposing, sharing, and connecting pieces of data, information, and knowledge on the Semantic Web using URIs and RDF. – Wikipedia definition Chapter 3A Semantic Web Primer, 2nd Edition

Linked Data – Tim Berners Lee’s thoughts ( ) Semantic Web isn't just about putting data on the web It is about making links, so that a person or machine can explore the web of data. – With linked data, when you have some of it, you can find other, related, data. In the web of hypertext (or web of documents), links are relationships between documents written in HTML In the web of data, links are relationships between arbitrary things described by RDF. – The URIs identify any kind of object or concept. Chapter 3A Semantic Web Primer, 2nd Edition

Linked Data Principles Use URIs as names for things – Real inanimate or animate things, abstract concepts, … Use HTTP URIs so that names can be looked up – E.g. using a browser When someone looks up a URI, provide useful information, using the standards (RDF, SPARQL) Include links to other URIs so that more things can be discovered – Links are actually RDF properties interpreted as hyperlinks Chapter 3A Semantic Web Primer, 2nd Edition Don't just link the documents, link the things

Advantages of LOD Linked Data is a way of publishing data on the Web that: – encourages reuse – reduces redundancy – maximises its (real and potential) inter- connectedness – enables network effects to add value to data Chapter 3A Semantic Web Primer, 2nd Edition

Linked Data Technology Stack URIs – as a mechanism to identify things (IDs) HTTP – as a mechanism to access things RDF – as a mechanism to describe things and their relationships RDFS/OWL – as a mechanism to describe vocabularies of properties and relationships of things Chapter 3A Semantic Web Primer, 2nd Edition

Linked Data Example Chapter 3A Semantic Web Primer, 2nd Edition Prefixes rc: rdf: foaf: dbpedia: dp: skos: Data Merging with RDF Mix schemas/vocabularies within one document Less painful data merging

Dbpedia:Berlin select ?p ?o where { dbpedia:Berlin ?p ?o. } A Semantic Web Primer, 2nd Edition See attached file Chapter 3

Dbpedia:Berlin Dbpedia:Berlin expands to full URI: – Unique ID that represents the resource in the Web of Data However, if you type the above URI at a browser, you will be re-directed at: – Manifestation (or visualization) of the resource in the Web of Documents A Semantic Web Primer, 2nd EditionChapter 3

Dbpedia:Berlin A Semantic Web Primer, 2nd EditionChapter 3

Dbpedia:Berlin If you type at the browser: The browser will retrieve an RDF/XML file that contains all information for BerlinRDF/XML – All triples with as a subjecthttp://dbpedia.org/resource/Berlin A Semantic Web Primer, 2nd EditionChapter 3

Why Publish Linked Data? Ease of discovery Ease of consumption – standards-based data sharing Reduced redundancy Added value – build ecosystems around your data/content Chapter 3A Semantic Web Primer, 2nd Edition

The Linking Open Data cloud diagram Now Chapter 3A Semantic Web Primer, 2nd Edition

The Linking Open Data cloud diagram May 2007 Chapter 3A Semantic Web Primer, 2nd Edition

DBpedia ( A project aiming to extract structured content from the information created as part of the Wikipedia. – This structured information is then made available on the Web DBpedia allows users to query relationships and properties associated with Wikipedia resources, including links to other related datasets. One of the more famous parts of the Linked Data project, according to TBL Chapter 3A Semantic Web Primer, 2nd Edition

DBpedia dataset Wikipedia articles include structured information embedded in the articles (mostly free text) – E.g. "infobox" tables, categorisation information, images, geo-coordinates and links to external pages.pages – This structured information is extracted and put in a uniform dataset which can be queried. The DBpedia project uses RDF to represent the extracted information. – 2.46 billion RDF triples 470 million from the English edition 1.98 billion from other language editions (119) 45 million data links to external RDF data sets Chapter 3A Semantic Web Primer, 2nd Edition

DBpedia challenges The same concepts can be expressed using different properties in templates – E.g. birthplace and placeofbirth – Queries about where people were born must search for both properties to get complete results. The DBpedia Mapping Language helps mapping properties to an ontology – Reduces the number of synonyms The development of the ontology and the mappings are open to public – Due to large diversity of infoboxes and properties Chapter 3A Semantic Web Primer, 2nd Edition

GeoNames GeoNames is a geographical database available and accessible through various Web services Contains over 10,000,000 geographical names corresponding to over 7,500,000 unique features. – E.g. names of places, latitude, longitude, elevation, population, administrative subdivision, postal codes, … Web services: – Direct and reverse geocoding, finding places through postal codes, finding places next to a given place, and finding Wikipedia articles about neighbouring places. Chapter 3A Semantic Web Primer, 2nd Edition

GeoNames and LOD Each GeoNames feature is represented as a Web resource identified by a stable URI.Web resourceURI – Provides access to the HTML wiki page or to RDF description, using GeoNames ontology RDFontology This ontology describes the GeoNames features properties using the OWL – The classes and codes are described in SKOS (RDFS).SKOS GeoNames data are linked to DBpedia data and other RDF Linked Data.DBpediaLinked Data – Through Wikipedia articles URL linked in the RDF descriptions Chapter 3A Semantic Web Primer, 2nd Edition

Geonames – Example page Chapter 3A Semantic Web Primer, 2nd Edition

Chapter 3A Semantic Web Primer, 2nd Edition Summary RDF provides a foundation for representing and processing metadata RDF has a graph-based data model RDF has an XML-based syntax to support syntactic interoperability. – XML and RDF complement each other because RDF supports semantic interoperability RDF has a decentralized philosophy and allows incremental building of knowledge, and its sharing and reuse

Chapter 3A Semantic Web Primer, 2nd Edition Summary (2) RDF is domain-independent RDF Schema provides a mechanism for describing specific domains RDF Schema is a primitive ontology language – It offers certain modelling primitives with fixed meaning Key concepts of RDF Schema are class, subclass relations, property, subproperty relations, and domain and range restrictions There exist query languages (SPARQL) for RDF/RDFS

Chapter 3A Semantic Web Primer, 2nd Edition Points for Discussion in Subsequent Chapters RDF Schema is quite primitive as a modelling language for the Web Many desirable modelling primitives are missing Therefore we need an ontology layer on top of RDF and RDF Schema