Chapter 5 Semantic Web
Chapter 5 Semantic Web
Shadbot, Hall, Berners-Lee, The Semantic Web revisited, IEEE Intelligent Systems, May 2006
Web Technologies II 2
What is the Semantic Web?
• The Semantic Web builds upon
• the principles and technologies of the web
• It reuses the Web’s global indexing and naming scheme
• Semantic Web documents can be accessed through standard Web browsers as well as
through semantically aware applications
• the Web is a shared resource, and therefore, within a machine-readable Web,
meaning should be shared too.
Web Technologies II 3
What is the Web?
• Web is a global document repository.
Web Technologies II 4
Web Architecture
• It is simple.
• Functional services of the Web
• A worldwide addressing schema: using URLs – resource identification and describing
its network location
• A transport layer- HTTP – supports remote access to content over a network layer
(TCP-IP). HTTP functions as a request –respond protocol in client-server computing
model.
• A platform-independent interface – enable users to easily access any online resource
Web Technologies II 5
What Are the Problems with the Web?
• Huge collection of documents
• Accessing data
• Documents are indexed and accessed via plain text (i.e. string matching algorithms).
For example: ‘‘Paris’’ can denote: the capital of France; towns in Canada, Kiribati, and
the USA.
• The current paradigm is dominated by returning single ‘‘best fit’’ documents for a
search.
• Underlying data are not available. A significant number of websites are generated
through databases but the underlying data are hidden behind the presented HTML.
(Dark Web)
• Enabling delegation of tasks such as the integration of information, data analysis, and
sense making to machines, at least partially
Web Technologies II 6
What Are the Problems with the Web?
• Semantic Web extends the Web with ‘‘meaning’’ supporting access to data
at web-scale and enabling the delegation of certain classes of tasks.
• The Web has documents at the center
• The Semantic Web places data and the semantics of data at its core.
Web Technologies II 7
What Are Semantics?
• Semantic technology provides machine-understandable (or
better machine-processable) descriptions of data,
programs, and infrastructure, enabling computers to reflect
on these artifacts.
Web Technologies II 8
Semantic Web Languages
• HTML
• It provides a number of ways to express the semantics of data. An obvious one is the
META tag
<META name = “Author” lang= “fr” content = “Arnaud Le Hors”>
• Ontobroker used the attribute of the anchor tag to encode semantic information.
• But, HTML was not designed to provide descriptions of documents beyond that of
informing the browser on how to render the contents.
• Semantic HTML
• The Extensible Markup Language (XML)
• It is a generic way to structure documents on the Web. It generalizes HTML by
allowing user-defined tags.
• It is flexible but reduces the possibilities for the type of semantic interpretation that
was possible with the predefined tags of HTML.
Web Technologies II 9
Semantic Web Languages
• The Resource Description Framework (RDF)
• It is a simple data model for semantically describing resources on the Web.
• Binary properties interlink terms forming a directed graph.
• Terms as well as properties are described using URIs.
• As a property can be a URI, it can be used as a term interlinked to another property.
• Unlike most logical languages or databases, it is not possible to distinguish the language or
schema from statements in the language or schema.
• Example: <rdf:type, rdf:type, rdf:Property>
• RDF schema (RDFS)
• It uses basic RDF statements and defines a simple ontology language.
• It defines entities such as rdfs:class, rdfs:subclass, rdfs:subproperty, rdfs:domain, and
rdfs:range, enabling one to model classes, properties with domain and range restrictions, and
hierarchies of classes and properties.
• It is RDF + some more definitions (statements) in RDF.
Web Technologies II 10
Semantic Web Languages
• The Web Ontology Language OWL
• It extends vocabulary to a full-fledged spectrum of Descriptions Logics defined in RDF,
namely, OWL Lite, OWL DL, and OWL Full.
• It allows mechanisms for defining properties to be inverse, transitive, symmetric, or
functional. Properties can be used to define the membership of instances for classes
or hierarchies of classes and of properties.
• OWL2
• Defined some of the issues around OWL.
• OWL Lite had been defined as an over expressive Description Logic. Three sub-
languages:
• OWL2EL - all the standard reasoning tasks of description logic
• OWL2QL enables efficient query answering over large instance populations
• OWL2RL restricts the expressiveness with respect to extensibility toward rule languages.
Web Technologies II 11
Semantic Web Languages
• The Rule Interchange Format (RIF)
• It complements OWL with a language framework centered on the rule paradigm.
• RIF-BLD – defines a simple logic-oriented rule language
• RIF-PRD captures most of the aspects of production rule systems
• RIF-Core is the intersection of both of these languages
• SPARQL
• It is a query language for the graph-based data model of RDF.
• SPARQL has been developed without considering RDFS, OWL, and RIF
Web Technologies II 12
Semantic Web Languages <person>
<name>Sir Tim</name>
<phone number>01-444444 </phone number>
</person
Concept – Person
Property: Name, Phone number
How do we know that Sir Tim is then name of a person?
• Microformats : are predefined formats to add meta information to elements in HTML and
XML. It provides a language structure to present information and provide domain specific
terminologies as well.
• hCard can be used for representing people, companies, organizations, and places, using
vCard, a file format standard for electronic business cards.
• RDFa provides a set of XHTML attributes to include RDF metadata directly into HTML and XML
documents.
• GRDDL has been developed as a mechanism for Gleaning Resource Descriptions from Dialects
of Languages to derive RDFa definitions from Microformats so as to integrate information
from heterogeneous sources.
Web Technologies II 13
The Semantic Web: why?
• The traditional web is web of documents and it is meant mainly for humans
and has two major problems
• Problem 1: web documents do not distinguish between information content
and presentation
• (“solved” by XML)
• Problem 2: different web documents may represent in different ways
semantically related pieces of information
• this leads to hard problems for “intelligent” information search on the Web
Web Technologies II 14
Separating content and presentation
Problem 1: web documents do not distinguish between information content
and presentation
• Cause of the problem: the HTML language
• Current Technology solution: – stylesheets (HTML, XML), XML
• stylesheets allow for separating formatting attributes from the information
presented
Web Technologies II 15
Separating content and presentation
• XML: eXtensible Mark-up Language
• XML documents are written through a user defined set of tags
• tags are used to express the “semantics” of the various pieces of information
Web Technologies II 16
Example: HTML
<html>
<body>
<H1> Seminar: Article Review Presentation Schedule</H1>
<UL>
<LI>[email protected]</LI> <LI>[email protected]</LI>
<LI>CoSc 705 - Seminar: Article Review Presentation Schedule</LI >
<LI> The presentations of the seminar course are scheduled from July 4 - 8, 2016. Please
find attached the presentation schedule</LI>
</UL>
</body>
</html>
Web Technologies II 17
Example: XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<from>[email protected] </from>
<to>[email protected] </to>
<subject> CoSc 705 - Seminar: Article Review Presentation Schedule
</subject>
<body> The presentations of the seminar course are scheduled from July 4
- 8, 2011. Please find attached the presentation schedule </body>
</note>
Web Technologies II 18
Example: XML - DTD
Web Technologies II 19
Limitations of XML
• XML does not solve all
the problems:
• legacy HTML
documents
• different XML
documents may
express information
with the same
meaning but using
different tags
Web Technologies II 20
The need for a “Semantic” Web
• Problem 2: different web documents may represent in different ways
semantically related pieces of information different XML documents do not
share the “semantics” of information
• idea: annotate (mark-up) pieces of information to express the “meaning” of
such a piece of information the meaning of such tags is shared! ⇒ shared
semantics
Web Technologies II 21
The Semantic Web initiative
• Sir Tim Berners-Lee started provide a layered approach to structure the
Semantic Web
• Viewpoint:
• the Web = a web of data
• Goal:
• to provide a common framework to share data on
• the Web across application boundaries
• Main ideas:
• Ontology
• Standards
• “layers”
Web Technologies II 22
The Semantic Web Tower
five layers of semantics: RDF, OWL, RIF, and
layers for proof and trust
SELECT ?book
WHERE {
SPARQL (SPARQL Protocol ?book <http://purl.org/dc/terms/author> "John Doe" .
and RDF Query Language): }
Web Technologies II 27
The XML Layer – example
<course date=“2016”>
<title>Web Technologies II</title>
<teacher>
<name>Animaw Kerie</name>
<office>FBE, 217</office>
<email>[email protected]</email>
</teacher>
<prereq>none</prereq>
</course>
Web Technologies II 28
The XML Layer – example
• XML: document = labelled tree
• node = label + attributes/ values + contents
course
<course date=“2016”>
<title>Web Technologies II</title>
<teacher>
<name>Animaw Kerie</name> date title teacher prereq
<office>4th floor</office>
<email>[email protected]</em
ail>
</teacher> 2016 Web Tech … name office email None..
<prereq>none</prereq>
</course>
aniamw … 4th floor. [email protected]
Web Technologies 29
The RDF + RDFS layer
• RDF = a simple conceptual data model
• W3C standard (1999)
• RDF model = set of RDF triples
• triple = expression (statement)
• (subject, predicate, object)
• subject is a resource
• predicate is a property (of the resource)
• object is the value (of the property)
• an RDF model is a graph
Web Technologies II 30
The RDF + RDFS layer
The RDF + RDFS layer
• RDFS is RDF Schema
• It contains “vocabulary” for RDF: Class, domain, range, subClassOf, subPropertyOf
• It is a W3C standard (2004)
Person
subClassOf subClassOf
domain range
RDFS Student hasSupervisor Researcher
type type
hasSupervisor
RDF Frank Jeen
The Ontology - OWL layer
• Ontology is a shared conceptualization of a domain of interest
• It is a conceptual model (more expressive than RDF + RDFS)
• It is expressed in a true knowledge representation language i.e. OWL (Web
Ontology Language), the standard language for ontologies
• The ontology can be
• A simple (shallow) that contain shared vocabulary
• Deep ontology that represent (complex) relationships between “terms”
Web Technologies II 33
Ontologies: example
class-def animal
class-def plant
subclass-of NOT animal
class-def tree
subclass-of plant The use of "subclass-of NOT" denotes that a class is a subclass
class-def branch of a broader category but excludes another specified subclass.
slot-constraint is-part-of In this case, 'defined herbivore' is a subclass of 'animal' but
has-value tree explicitly not a subclass of 'carnivore'. This setup allows for
max-cardinality 1 defining specific relationships and constraints within the
class-def defined carnivore ontology, creating a structured understanding of the
subclass-of animal relationships between different types of entities in this system.
slot-constraint eats
value-type animal
class-def defined herbivore herbivores consume plants.
subclass-of animal, NOT carnivore
slot-constraint eats
value-type plant
Web Technologies II 34
Ontologies and Description Logics
Web Technologies II 35
The proof/ rule layer
• rule: informal notion
• rules are used to perform inference over ontologies
• rules are used as a tool for capturing further knowledge (not expressible in
OWL ontologies)
Web Technologies II 36
Ontologies: the role of logic
• Ontology = logical theory
• Why?
• Declarative
• formal semantics
• reasoning (sound and complete inference techniques)
• well-established correspondence between conceptual
modeling formalisms and logic
Web Technologies II 37
Rule-based formalisms
• Prolog
• Logic programming
• Constraint (logic) programming
• Production rules
• Datalog
• ...
• RIF (Rule Interchange Format): W3C recommendation
(2010)
Web Technologies II 38
The Trust layer
• It is the top layer of the Semantic web
• It provides support for provenance/ trust
• To judge the value of the data item and how to use the data appropriately, one has to
know the origin of the data.
• provenance: it answers the following main questions
• which pieces of data were chosen and composed together?
• where do they come from? who created them?
• or which inference rules were used to create implicit statements?
• can I trust this information? trust is related to data source, authorship, certainty, …
• It is largely unexplored issue and there is no standardization effort to handle it.
Web Technologies II 39
Semantic Web Applications
Applications
• Intelligent Business and Management (e.g. e-commerce – matchmaking for
e-business)
Web Technologies II 41
Semantic Web Applications
• Main categories
• Search (also browsing, personalization) e.g. Taalee search engine
• Integration (also interoperability)
• Analysis (also visualization)
Web Technologies II 42
The Building Block for the Semantic Web(
Resource Description Framework – RDF)
RDF
• It is a framework to publish statements on the Web about anything.
• It allows anyone to describe resources, in particular Web resources, such as
the author, creation date, subject, and copyright of an image.
• RDF is a data model
• it is domain-neutral, application-neutral and ready for internationalization
• it can be viewed as directed, labeled graphs or as an object-oriented model (object/
attribute/value)
• It is an abstract, conceptual layer independent of XML
• XML is a transfer syntax for RDF, not a component of RDF
• RDF data might never occur in XML form
• it provides interoperability between applications that exchange machine-
understandable information.
Web Technologies 44
RDF
• Resources are a core concept on the Semantic Web:
• everything one might refer to is considered a resource. Everything that
can be identified by a URI is considered as a resource.
• Descriptions of resources are essential for understanding and reasoning
about them.
• In the most general case, a description is a set of attributes, features,
and relations concerning the resource.
• The Framework means it provides models, languages, and syntaxes for
these descriptions.
• RDF provides a standard data structure and a model to encode data and
metadata about any subject on the Web
Web Technologies 45
RDF model
• RDF model is a set of RDF triples
• A triple is an expression (statement) of the format
(subject, predicate, object)
• Subject: resource or blank node
• Predicate: property (of the resource)
• Object: value (of the property) – literal or blank node
subject predicate object
Resource Value
property
Web Technologies 46
Triplet data model
• Example: represent the assertion ‘‘Fabien has written a page doc.html
about music’’ can be broken down into two RDF statements:
(doc.html, author, Fabien) and
(doc.html, theme, music).
• The logical view of the RDF triples is that RDF makes an open-world
assumption (i.e. what is not known to be true is simply unknown - the
absence of a triple is not significant) as opposed to the closed-world
assumption of classical systems (i.e. what is not known to be true must be
false).
Web Technologies 47
Graph-Oriented data model
• RDF triples can be seen as two vertices and one arc of a graph describing
and linking resources.
• RDF is a decentralized data representation model relying on distributed
triples that form a global graph.
• The identity of the resources is based on the URI mechanism: if two
resources have the same URI they are one and the same node in the graph.
• An RDF graph is:
• A multi-graph: a graph that can contain both multiple edges and loops
between its vertices
• A directed graph: every edge is oriented going from the end-vertex
representing the subject to the end-vertex representing the object
• A labeled graph: edges are labeled with URIs, vertices are labeled with
URIs, blank node identifiers, or literals
Web Technologies 48
English: ‘‘The report doc.html has the authors Fabien and York, the theme music and is 23-pages long.’’
Logic predicates: Triples:
Report(doc.html) (doc.html , type , Report)
creator(doc.html , Fabien (doc.html, creator , Fabien)
creator(doc.html , York) (doc.html, creator , York)
theme(doc.html , Music) (doc.html, theme , Music)
nbPages(doc.html , 23) (doc.html, nbPages, ‘‘23’’)
http://...#Report
type
creator
http://...#fabien
http://.../doc.html creator
http://...#york
theme
http://...#music
nbPages
23
Example – Graph-oriented data model
Describe a Person identified by http://www.w3.org/People/EM/contact#me, whose
name is Eric Miller, whose email address is [email protected], and whose title is Dr.
http://www.w3.org/2000/10/swap/pim/contact#Person
http://www.w3.org/1999/02/22-rdf-syntax-ns#type
http://www.w3.org/2000/10/swap/pim/contact#fullName
http://www.w3.org/People/EM/contact#me Eric Miller
http://www.w3.org/2000/10/swap/pim/contact#mailbox
http://www.w3.org/2000/10/swap/pim/contact#personaltitle mailto:[email protected]
Dr.
50
RDF/XML
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#">
<contact:Person
rdf:about="http://www.w3.org/People/EM/contact#me">
<contact:fullName>Eric Miller</contact:fullName>
<contact:mailbox rdf:resource="mailto:[email protected]"/>
<contact:personalTitle>Dr.</contact:personalTitle>
</contact:Person>
</rdf:RDF>
51
Example:
Describe “the document at http://www.w3c.org/TR/REC-rdf-syntax is created by
Eric Miller on 1999-02-22 and is published by W3C”
Triple:
http://www.w3c.org/TR/REC-rdf-syntax creator Eric Miller
http://www.w3c.org/TR/REC-rdf-syntax date 1999-02-22
http://www.w3c.org/TR/REC-rdf-syntax publisher W3C
W3C
dc:publisher
http://www.w3.org/TR/REC-rdf-syntax/
dc:date dc:creator
52
1999-02-22 Eric Miller
Node and edge labels in RDF graphs
Web Technologies 53
Blank nodes
• blank node (bnode) = RDF graph node with “anonymous label” (i.e., not associated with an URI)
Example: "Jean has a friend born the 21st of April“
ex:Jean foaf:knows _:p1
_:p1 foaf:birthDate 04-21
_:p1 is the blank node (bnode)
• bnode can be used both
as subjects and objects
Web Technologies 54
Complex values
• values of properties need not be simple strings
• the value of a property can also be a graph node (corresponding to a
resource)
• using blank nodes, arbitrarily complex tree and graph structures are possible
dc:publisher
http://www.w3.org/TR/REC-rdf-syntax/ W3C
dc:creator
p:Name
p:email
Eric Miller
mailto:[email protected]
Web Technologies II 55
RDF Graphs as XML Trees
• RDF/ XML syntax is the standardized way of serializing RDF triplet.
• The principal aim of RDF/XML is to be machine-processable and compliant
to the de facto standard of Web document formatting, XML.
• RDF/ XML syntax allows RDF documents to be easily exchanged between
very different types of systems and applications.
Web Technologies 56
<?xml version=‘‘1.0’’?>
RDF/ XML <rdf:RDF
xmlns:rdf=‘‘http://www.w3.org/1999/02/22-rdf-syntax-ns#’’
xmlns:exs= ‘‘http://example.org/schema#’’>
• There are <rdf:Description rdf:about=‘‘http://example.org/doc.html’’>
several <rdf:type rdf:resource=‘‘http://example.org/schema#Report’’/>
possibilities to <exs:theme rdf:resource=‘‘http://example.org#Music’’/>
<exs:theme rdf:resource=‘‘http://example.org#History’’/>
express the <exs:nbPages rdf:datatype= ‘‘http://www.w3.org/2001/XMLSchema#int’’> 23
same RDF </exs:nbPages>
graph (i.e. the </rdf:Description>
serialization is </rdf:RDF>
<?xml version=‘‘1.0’’?>
not unique) <rdf:RDF
xmlns:rdf=‘‘http://www.w3.org/1999/02/22-rdf-syntax-ns#’’
xmlns:exs= ‘‘http://example.org/schema#’’>
<exs:Report rdf:about=‘‘http://example.org/doc.html’’ exs:nbPages=‘‘23’’>
<exs:theme rdf:resource=‘‘http://example.org#Music’’/>
<exs:theme rdf:resource=‘‘http://example.org#History’’/>
</exs:Report>
</rdf:RDF>
Web Technologies 57
N-Triples – N3 format
• N-Triples requires one triple to be written per line.
• Every triple is provided as subject, predicate, and object that are separated
by whitespaces and terminated by a dot (.).
<http://example.org/doc.html> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://example.org/schema#Report>.
<http://example.org/doc.html> <http://example.org/schema#theme> <http://example.org#Music>.
<http://example.org/doc.html> <http://example.org/schema#theme> <http://example.org#History>.
<http://example.org/doc.html> <http://example.org/schema#nbPages> ‘‘23’’^^
<http://www.w3.org/2001/XMLSchema#integer>.
Web Technologies 58
Triple Serialization in Turtle
• Turtle (Terse RDF Triple Language) is a compact textual format for serializing an RDF graph, is
less constrained than N-Triples
• Turtle, for example, does not have the restriction of single-lined statement as in N-Triples, and
provides various abbreviations.
• Further shortcuts are supported for repeated subjects, or multiple objects.
• To abbreviate multiple statements with the same subject, Turtle provides a semicolon (;)
notation which makes it possible to list predicate–object pairs for the same subject.
• Multiple statements with the same subject–predicate pair but different objects can be similarly
abbreviated using the comma (,) notation.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix exs: <http://example.org/schema#>.
<http://example.org/doc.html> a exs:Report ;
exs:theme <http://example.org#Music> ,<http://example.org#History> ;
exs:nbPages ‘‘23’’^^xsd:int .
Web Technologies 59
Containers
• Containers are collections: allow grouping of resources (or literal values)
• It is possible to make statements about the container (as a whole) or about
its members individually
• Different types of containers exist
• rdf:Bag defines an unordered group of resources or literals.
• rdf:Seq defines an ordered group of resources or literals.
• rdf:Alt represents a group of resources or literals that are alternatives;
that is, only one of the values can be selected.
• It is also possible to create collections based on URI patterns
• Duplicate values are permitted (no mechanism to enforce unique value
constraints)
Web Technologies 60
rdf:Bag
exs:report rdf:_1
http://example.org#Fabien
rdf:type
rdf:_2
rdf:type :x http://example.org#York
dc:creator Turtle
<http://example.org/doc.html>
http://example.org/doc.html a exs:Report ;
dc:creator [ a rdf:Bag ;
rdf:_1 <http://example.org#Fabien> ;
rdf:_2 <http://example.org#York> ].
RDF/XML
<exs:Report rdf:about=‘‘http://example.org/doc.html’’>
<dc:creator>
<rdf:Bag>
<rdf:li rdf:resource=‘‘http://example.org#Fabien’’/>
<rdf:li rdf:resource=‘‘http://example.org#York’’/>
</rdf:Bag>
</dc:creator>
</exs:Report>
RDF Containers: Bag
“The lecture is attended by John, Mary and Chris”
62
RDF Containers: Seq
“[RDF-Concepts] is edited by Graham and Jeremy
(in that order)”
63
RDF Containers: Alt
“The source code for the application may be found at:
ftp1.example.org, ftp2.example.org, ftp3.example.org”
64
Reification
• It is a mechanism to make statement about statements
• Reification in RDF is represented using an RDF statement as the subject (or
object) of another RDF statement
Examples
<rdf:Description rdf:about="#949352">
<uni:name>Grigoris Antoniou</uni:name>
</rdf:Description>
reifies as
<rdf:Statement rdf:ID="StatementAbout949352">
<rdf:subject rdf:resource="#949352"/>
<rdf:predicate rdf:resource="http://www.mydomain.org/uni-ns#name"/>
<rdf:object>Grigoris Antoniou</rdf:object>
</rdf:Statement>
Web Technologies 65
Reification
• RDF provides a built-in predicate vocabulary for reification:
• rdf:subject
• rdf:predicate
• rdf:object
• rdf:statement
• Using this vocabulary (i.e., these URIs from the rdf:namespace) it is
possible to represents a triple through a blank node
Web Technologies 66
Reification
Examples Triple
<http://example.org/doc.html> a exs:Report.
Reified triple in Turtle syntax
exr:triple1 a rdf:Statement ;
rdf:subject <http://example.org/doc.html>;
rdf:predicate rdf:type ;
rdf:object exs:Report.
rdf :subject
68
RDFS is recommendation from W3C and it is an
extensible knowledge representation language
that one can use to create a vocabulary for
describing classes, subclasses and properties of
RDF resources.
RDF Vocabulary Description Language
• Types in RDF:
<#john, rdf:type, #Student>
• What is a “#Student”?
Web Technologies II 70
RDF Vocabulary Description Language
• We need a language for defining RDF types:
• Define classes:
• “#Student is a class”
• Relationships between classes:
• “#Student is a sub-class of #Person”
• Properties of classes:
• “#Person has a property hasName”
Web Technologies II 71
RDF Vocabulary Description Language
• Classes:
<#Student, rdf:type, #rdfs:Class>
• Class hierarchies:
<#Student, rdfs:subClassOf, #Person>
• Properties:
<#hasName, rdf:type, rdf:Property>
• Property hierarchies:
<#hasMother, rdfs:subPropertyOf, #hasParent>
Web Technologies II 72
RDFS Vocabulary
• RDFS Extends the RDF Vocabulary
• RDFS vocabulary is defined in the namespace:
http://www.w3.org/2000/01/rdf-schema#
ex:Faculty-
Staff
Web Technologies II 75
Triples
exs:Report, rdfs:subClassOf, exs:Document.
exs:Advert, rdfs:subClassOf, exs:Document.
exs:Presentation, rdfs:subClassOf, exs:Document.
exs:PresentationReport, rdfs:subClassOf, exs:Report, exs:Presentation.
exs:Document
rdsf:subClassOf rdsf:subClassOf
rdsf:subClassOf
rdsf:subClassOf
rdsf:subClassOf
exs:PresentationReport
Triples
exs:Researcher rdfs:subClassOf foaf:Person.
foaf:name rdfs:domain foaf:Person.
exs:TimBernersLee a exr:Researcher;
foaf:name ‘‘Tim Berners-Lee’’;
foaf:interest <http://www.w3.org/sw/>,
<http://www.w3.org/RDF/>.
exs:BlogEntry rdfs:subClassOf foaf:Document.
<http://example.org/blog/4 a exs:BlogEntry;
exs:mainSubject exs:TimBernersLee;
foaf:maker, exs:TimBernersLee;
foaf:topic <http://www.w3.org/sw/>,
<http://www.w3.org/RDF/> ;
rdfs:seeAlso <http://example.org/blog/feed/4>.
<http://example.org/blog/feed/4> a foaf:Document;
rdfs:comment ‘‘This blog is provided by an RSS
channel.’’.
RDFS Vocabulary Example
Web Technologies II 78
RDFS Metadata Properties
• Metadata is “data about data”
• Any meta-data can be attached to a resource, using:
• rdfs:comment
• Human-readable description of the resource, e.g.
• <ex:Person>, rdfs:comment, ”A person is any human being”
• rdfs:label
• Human-readable version of the resource name, e.g.
• <ex:Person>, rdfs:label, ”Human being”
• rdfs:seeAlso
• Indicate additional information about the resource, e.g.
• <ex:Person>, rdfs:seeAlso, <http://xmlns.com/wordnet/1.6/Human>
• rdfs:isDefinedBy
• A special kind of rdfs:seeAlso, e.g.
• <ex:Person>,rdfs:isDefinedBy,<http://xmlns.com/wordnet/1.6/Human>
Web Technologies II 79
RDF
RDFs
Web Technologies II
Web Ontology Language : OWL
Requirements for Ontology Languages
• Ontology languages allow users to write explicit, formal conceptualizations of
domain models
• The main requirements are:
• a well-defined syntax
• efficient reasoning support
• a formal semantics
• sufficient expressive power
• convenience of expression
Web Technologies II 82
Tradeoff between Expressive Power and Efficient Reasoning Support
• The richer the language is, the more inefficient the reasoning support
becomes
• Sometimes it crosses the border of noncomputability
• We need a compromise:
• A language supported by reasonably efficient reasoners
• A language that can express large classes of ontologies and knowledge
Web Technologies II 83
Reasoning About Knowledge in Ontology Languages
• Class membership
• If x is an instance of a class C, and C is a subclass of D, then we can infer that x is an
instance of D
• Equivalence of classes
• If class A is equivalent to class B, and class B is equivalent to class C, then A is
equivalent to C, too
• Consistency
• X instance of classes A and B, but A and B are disjoint
• This is an indication of an error in the ontology
• Classification
• Certain property-value pairs are a sufficient condition for membership in a class A; if
an individual x satisfies such conditions, we can conclude that x must be an instance of
A
Web Technologies II 84
Uses for Reasoning
• Reasoning support is important for
• checking the consistency of the ontology and the knowledge
• checking for unintended relationships between classes
• automatically classifying instances in classes
• Checks like the preceding ones are valuable for
• designing large ontologies, where multiple authors are involved
• integrating and sharing ontologies from various sources
Web Technologies II 85
Reasoning Support for OWL
• Semantics is a prerequisite for reasoning support
• Formal semantics and reasoning support are usually provided by
• mapping an ontology language to a known logical formalism using automated
reasoners that already exist for those formalisms
• OWL is (partially) mapped on a description logic, and makes use of reasoners
such as FaCT and RACER
• Description logics are a subset of predicate logic for which efficient reasoning
support is possible
Web Technologies II 86
Three Species of OWL
• W3C’sWeb Ontology Working Group defined OWL as three different sublanguages:
• OWL Full
• OWL DL
• OWL Lite
• Each sublanguage geared toward fulfilling different aspects of requirements.
Web Technologies II 87
OWL Full
• It uses all the OWL languages primitives
• It allows the combination of these primitives in arbitrary ways with RDF and
RDF Schema
• OWL Full is fully upward-compatible with RDF, both syntactically and
semantically
• Any legal RDF document is also a legal OWL Full document, and any valid
RDF/RDF Schema conclusion is also a valid OWL Full conclusion.
• OWL Full is so powerful that it is undecidable
– No complete (or efficient) reasoning support
Web Technologies II 88
OWL DL
Web Technologies II 89
OWL Lite
• An even further restriction limits OWL DL to a subset of the
language constructors
• E.g., OWL Lite excludes enumerated classes, disjointness
statements, and arbitrary cardinality.
• The advantage of this is a language that is easier to
• grasp, for users
• implement, for tool builders
• The disadvantage is restricted expressivity
Web Technologies II 90
OWL Syntactic Varieties
• OWL builds on RDF and uses RDF’s XML-based syntax
• Other syntactic forms for OWL have also been defined:
• An alternative, more readable XML-based syntax that does not
follow the RDF conventions and is thus more easily read by
human users.
• An abstract syntax, that is much more compact and readable
than the XML languages
• A graphic syntax based on the conventions of UML
Web Technologies II 91
OWL XML/RDF Syntax: Header
• OWL documents are usually called OWL ontologies and are RDF documents.
The root element of an OWL ontology is an rdf:RDF element, which also
specifies a number of namespaces:
<rdf:RDF
xmlns:owl ="http://www.w3.org/2002/07/owl#"
xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd ="http://www.w3.org/2001/XLMSchema#">
• An OWL ontology may start with a collection of assertions for housekeeping
purposes using owl:Ontology element, which contains comments, version
control, and inclusion of other ontologies.
Web Technologies II 92
OWL XML/RDF Syntax: Header (2)
Example:
<owl:Ontology rdf:about="">
<rdfs:comment>An example OWL ontology </rdfs:comment>
<owl:priorVersion rdf:resource="http://www.mydomain.org/uni-ns-old"/>
<owl:imports rdf:resource="http://www.mydomain.org/persons"/>
<rdfs:label>University Ontology</rdfs:label>
</owl:Ontology>
• owl:imports, lists other ontologies whose content is assumed to be part of
the current ontology.
• owl:imports is a transitive property, if ontology A imports ontology B, and
ontology B imports ontology C, then ontology A also imports ontology C.
Web Technologies II 93
Classes
• Classes are defined using owl:Class
• owl:Class is a subclass of rdfs:Class
<owl:Class rdf:ID="associateProfessor">
<rdfs:subClassOf rdf:resource="#academicStaffMember"/>
</owl:Class>
• Disjointness is defined using owl:disjointWith
<owl:Class rdf:about="#associateProfessor">
<owl:disjointWith rdf:resource="#professor"/>
<owl:disjointWith rdf:resource="#assistantProfessor"/>
</owl:Class>
Web Technologies II 94
Classes (2)
• owl:equivalentClass defines equivalence of classes
<owl:Class rdf:ID="faculty">
<owl:equivalentClass rdf:resource=
"#academicStaffMember"/>
</owl:Class>
• owl:Thing is the most general class, which contains
everything
• owl:Nothing is the empty class
Web Technologies II 95
Properties
• In OWL there are two kinds of properties
• Object properties, which relate objects to other objects E.g. is-
TaughtBy , supervises
• Data type properties, which relate objects to datatype values
E.g. phone, title, age, etc.
• OWL does not have any predefined data types, nor does it
provide special definition facilities.
• Instead, it allows one to use XML Schema data types, thus
making use of the layered architecture of the Semantic Web
Web Technologies II 96
Datatype Properties
• OWL makes use of XML Schema data types, using the layered architecture of
the SW
<owl:DatatypeProperty rdf:ID="age">
<rdfs:range rdf:resource=
"http://www.w3.org/2001/XLMSchema#nonNegativeInte
ger"/>
</owl:DatatypeProperty>
Web Technologies II 97
Object Properties
• User-defined data types will usually be collected in an XML schema and then
used in an OWL ontology.
• Example:
<owl:ObjectProperty rdf:ID="isTaughtBy">
<owl:domain rdf:resource="#course"/>
<owl:range rdf:resource= "#academicStaffMember"/>
<rdfs:subPropertyOf rdf:resource="#involves"/>
</owl:ObjectProperty>
• More than one domain and range may be declared. In this case the
intersection of the domains, respectively ranges, is taken.
Web Technologies II 98
Inverse Properties
<owl:ObjectProperty rdf:ID="teaches">
<rdfs:range rdf:resource="#course"/>
<rdfs:domain rdf:resource= "#academicStaffMember"/>
<owl:inverseOf rdf:resource="#isTaughtBy"/>
</owl:ObjectProperty>
Web Technologies II 99
Equivalent Properties
• Equivalence of properties can be de fined through the use
of the element owl:equivalentProperty.
<owl:equivalentProperty
<owl:ObjectProperty rdf:ID="lecturesIn">
<owl:equivalentProperty rdf:resource="#teaches"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:ID="isTaughtBy">
<rdf:type rdf:resource="&owl;FunctionalProperty" />
</owl:ObjectProperty>
<course rdf:ID="CIT1111">
<isTaughtBy rdf:resource="#949318"/>
<isTaughtBy rdf:resource="#949352"/>
</course>
Web Technologies II 115
Distinct Objects
• To ensure that different individuals are indeed recognized as such, we must
explicitly assert their inequality:
<lecturer rdf:about="949318">
<owl:differentFrom rdf:resource="949352"/>
</lecturer>
118
Overview
• SPARQL [1] is a query language designed for the Semantic
Web and is the language recommended by W3C for this
use.
• SPARQL is completely integrated into the Semantic Web and
uses other W3C recommendations.
• It assumes that data are represented as RDF graphs, that
resources are identified by IRIs, and that RDF literals are
typed with XML Schema
[1] Prud’hommeaux, E., Seaborne, A. (ed.): SPARQL query language for RDF, W3C Recommendation. World
Wide Web Consortium (2008)
Web Technologies II 119
SPARQL
• SPARQL stands for “SPARQL Protocol and RDF Query Language”.
Web Technologies II
SPARQL Basics
• SPARQL is based on matching graph patterns against RDF graphs.
• What is a graph pattern?
• To define graph patterns, we must first define triple patterns:
• A triple pattern is like an RDF triple, but with the option of a variable in
place of RDF terms (i.e., IRIs, literals or blank nodes) in the subject,
predicate or object positions.
• Example:
<http://example.org/book/book1>
<http://purl.org/dc/elements/1.1/title> ?title .
• ?title is a variable.
Web Technologies II
SPARQL Basics
• SPARQL is based on matching graph patterns against RDF graphs.
Web Technologies II
Anatomy of a SPARQL Query
• A SPARQL query is composed of five
parts:
• zero or more prefix declarations,
• a query result clause,
• zero or more FROM or FROM NAMED
clauses,
• a WHERE clause,
• and zero or more query modifiers.
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .
}
Web Technologies II 123
Anatomy of a SPARQL Query (2)
• Query result clause: specifies the form of the result.
• A SPARQL query can take four forms: SELECT, ASK, CONSTRUCT, and DESCRIBE.
• SELECT queries provide answers in a tabular form as if the SPARQL query were a SQL query
executed against a relational database.
• The ASK form checks whether the SPARQL endpoint can provide at least one result; if it does,
the answer to the query is YES, otherwise the answer is NO.
• The CONSTRUCT form is similar to the SELECT form, but it provides the answer to the query as
an RDF graph.
• The DESCRIBE form is conceived to retrieve information from a SPARQL endpoint without
knowing the vocabulary in use, producing as result an RDF graph.
• The optional set of FROM or FROM NAMED clauses define the dataset against which
the query is executed.
• The WHERE clause is the core of a SPARQL query. It is specified in terms of a set of
triple patterns.
CONSTRUCT {
?person foaf:knows ?friend .
} SELECT Queries:
WHERE { •Used to retrieve specific variables
?person rdf:type foaf:Person . (bindings) from the data.
?person foaf:knows ?friend .
} SELECT ?name ?age
WHERE {
?person rdf:type foaf:Person .
•Determine whether a specific pattern exists in the data. ?person foaf:name ?name .
?person foaf:age ?age .
ASK { }
?person rdf:type foaf:Person .
?person foaf:name "Alice" .
}
Web Technologies II
Basic Patterns
• SPARQL is a query language for pattern matching against RDF graphs.
• A query contains at least a triple pattern.
• A triple pattern is like an RDF triple except that the subject, the predicate,
and the object may be a variable.
• Syntactically a variable is formed by a question mark ‘‘?’’ followed by a term,
for example, ?name.
• A triple pattern matches the triples in the RDF data whose RDF terms may be
substituted for the variables.
?s ?o
dbcat:Visitor_attractions_in_Milan dbcat:Visitor_attractions_by_city
dbcat:Visitor_attractions_in_Milan dbcat:Visitor_attractions_in_Italy
dbcat:Visitor_attractions_in_Milan dbcat:Milan
129
Matching RDF Literals
• Literals in RDF contains language and data-type information and hence the
matching may not return matched graph. For instance
• “Milan Cathedral”@en (label in English), “Milan Cathedral”@it (in Italy) ,
“40000”^^xsd:integer (no of population)
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?s
FROM <http://dbpedia.org/data/Milan_Cathedral.rdf>
WHERE { ?s rdfs:label “Milan Cathedral”. }
132
Optional patterns
133
Union – to provide alternative graph pattern
Solution Modifiers Input Modifier Output
• Projection modifier: Select
• Order Modifier: Order by
• Distinct and reduced modifier: Distinct and reduced
• Limit and offset modifier: Limit, offset
Web Technologies
Query Forms CONSTRUCT, ASK, and DESCRIBE
• The CONSTRUCT query form returns an RDF graph specified by the query
designer as graph template.
• Example: the graph template at row 4 states that a church is an
ex:Big_Church if it has a capacity larger than 30,000 people.
Web Technologies