Semantic Web Unit - 3
Semantic Web Unit - 3
Ontology
Ontology is the study of the kinds of things that exist. In AI, the programs and sentences
deal with various kinds of objects, and we study what these kinds are and what their basic
properties are.
In general, ontology is the study or concern about what kinds of things exist -
what entities there are in the universe. It is a branch of Meta physics, the study of first
principles or the essence of things.
In the context of database systems, ontology can be viewed as a level of abstraction of data
models, analogous to hierarchical and relational models, but intended for modeling
knowledge about individuals, their attributes, and their relationships to other individuals.
Uses:
Ontologies are used for integrating heterogeneous databases, enabling interoperability
among disparate systems, and specifying interfaces to independent, knowledge-based
services. There are now standard languages and a variety of commercial and open source
tools for creating and working with ontologies.
KEY APPLICATIONS
Ontologies are part of the W3C standards stack for the Semantic Web, in which they are used
to Specify standard conceptual vocabularies in which to
exchange data among systems,
provide services for answering queries,
publish reusable knowledge bases,
and offer services to facilitate interoperability across multiple heterogeneous
systems and databases.
1
Semantic Web UNIT – 3
FOAF
FOAF (an acronym of Friend of a friend) is a machine-readable ontology describing
persons, their activities and their relations to other people and objects. Anyone can use
FOAF to describe him or herself. FOAF allows groups of people to describe social networks
without the need for a centralized database.
Example:
The following FOAF profile (written in Turtle format) states that Jimmy Wales is the name of
the person described here. His e-mail address, homepage and depiction are resources, which
means that each can be described using RDF as well. He has Wikimedia as an interest, and
knows Angela Beesley (which is the name of a 'Person' resource).
<#JW>
a foaf:Person ;
foaf:name "Jimmy Wales" ;
foaf:mbox <mailto:[email protected]> ;
foaf:homepage <http://www.jimmywales.com/> ;
foaf:nick "Jimbo" ;
foaf:depiction <http://www.jimmywales.com/aus_img_small.jpg> ;
foaf:interest <http://www.wikimedia.org> ;
foaf:knows [
a foaf:Person ;
foaf:name "Angela Beesley"
2
Semantic Web UNIT – 3
].
<http://www.wikimedia.org>
rdfs:label "Wikipedia" .
Turtle (syntax)
Turtle (Terse RDF Triple Language) is a serialization format for Resource Description
Framework (RDF) graphs. A subset of Tim Berners-Lee and Dan Connolly's Notation3 (N3)
language, it was defined by Dave Beckett, and is a superset of the minimal N-Triples format.
Unlike full N3, Turtle doesn't go beyond RDF's graph model. SPARQL uses a similar N3 subset
to Turtle for its graph patterns, but using N3's brace syntax for delimiting sub graphs. Turtle
was accepted as a first working draft by the World Wide Web Consortium (W3C) RDF
Working Group on 9 August 2011.
<http://www.w3.org/TR/rdf-syntax-grammar>
dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor [
ex:fullname "Dave Beckett";
ex:homePage <http://purl.org/net/dajobe/>
].
3
Semantic Web UNIT – 3
Diagram of URI scheme categories. Schemes in the URL (locator) and URN (name)
categories form subsets of URI, and also (generally) disjoint sets. Technically URL and URN
function as resource IDs; however, one cannot exactly categorize many schemes as one or the
other: we can treat all URIs as names, and some schemes embody aspects of both categories.
The ISBN system for uniquely identifying books provides a typical example of the use of
URNs.ISBN 0-486-27557-4 (urn:isbn:0-486-27557-4) cites, unambiguously, a specific edition
of Shakespeare's play Romeo and Juliet. To gain access to this object and read the book, one
needs its location: a URL address. A typical URL for this book on a Unix-like operating system
would be a file path such as file:///home/username/RomeoAndJuliet.pdf, identifying the
electronic book saved in a file on a local hard disk. So URNs and URLs have complementary
purposes.
4
Semantic Web UNIT – 3
The Resource Description Framework (RDF) is a family of World Wide Web Consortium
(W3C) specifications originally designed as a metadata data model. RDF is a standard model
for data interchange on the Web. RDF has features that facilitate data merging even if the
underlying schemas differ, and it specifically supports the evolution of schemas over time without
requiring all the data consumers to be changed.
RDF extends the linking structure of the Web to use URIs to name the relationship
between things as well as the two ends of the link (this is usually referred to as a “triple”).
Using this simple model, it allows structured and semi-structured data to be mixed, exposed,
and shared across different applications.
This linking structure forms a directed, labeled graph, where the edges
represent the named link between two resources, represented by the graph nodes.
This graph view is the easiest possible mental model for RDF and is often used in easy-
to-understand visual explanations.
5
Semantic Web UNIT – 3
The RDF data model is similar to classic conceptual modeling approaches such
as entity-relationship or class diagrams, as it is based upon the idea of
making statements about resources (in particular Web resources) in the form of subject-
predicate-object expressions. These expressions are known as triples in RDF
terminology. The subject denotes the resource, and the predicate denotes traits or aspects of
the resource and expresses a relationship between the subject and the object. For example,
one way to represent the notion "The sky has the color blue" in RDF is as the triple:
a subject denoting "the sky", a predicate denoting "has the color", and an object denoting
"blue". Therefore RDF swaps object for subject that would be used in the classical notation of
an Entity–attribute–value model within Object oriented design; object (sky), attribute
(color) and value (blue). RDF is an abstract model with several serialization formats (i.e., file
formats), and so the particular way in which a resource or triple is encoded varies from
format to format.
6
Semantic Web UNIT – 3
Example:
RDF Vocabulary
The vocabulary defined by the RDF specification is as follows:
Classes
rdf
rdf:XMLLiteral - the class of XML literal values
rdf:Property - the class of properties
rdf:Statement - the class of RDF statements
rdf:Alt, rdf:Bag, rdf:Seq - containers of alternatives, unordered containers, and ordered
containers (rdfs:Container is a super-class of the three)
rdf:List - the class of RDF Lists
rdf:nil - an instance of rdf:List representing the empty list
rdfs
rdfs:Resource - the class resource, everything
rdfs:Literal - the class of literal values, e.g. strings and integers
rdfs:Class - the class of classes
7
Semantic Web UNIT – 3
Properties
rdf
rdf:type - an instance of rdf:Property used to state that a resource is an instance of a class
rdf:first - the first item in the subject RDF list
rdf:rest - the rest of the subject RDF list after rdf:first
rdf:value - idiomatic property used for structured values
rdf:subject - the subject of the subject RDF statement
rdf:predicate - the predicate of the subject RDF statement
rdf:object - the object of the subject RDF statement
rdf:Statement, rdf:subject, rdf:predicate, rdf:object are used for reification (see below).
rdfs
rdfs:subClassOf - the subject is a subclass of a class
rdfs:subPropertyOf - the subject is a subproperty of a property
rdfs:domain - a domain of the subject property
rdfs:range - a range of the subject property
rdfs:label - a human-readable name for the subject
rdfs:comment - a description of the subject resource
rdfs:member - a member of the subject resource
rdfs:seeAlso - further information about the subject resource
rdfs:isDefinedBy - the definition of the subject resource
8
Semantic Web UNIT – 3
In addition to serializing RDF as XML, the W3C introduced Notation 3 (or N3) as a non-XML
serialization of RDF models designed to be easier to write by hand, and in some cases easier
to follow. Because it is based on a tabular notation, it makes the underlying triples encoded in
the documents more easily recognizable compared to the XML serialization. N3 is closely
related to the Turtle and N-Triples formats. Triples may be stored in a triplestore.
Resource identification
The subject of an RDF statement is either a Uniform Resource Identifier (URI) or a blank
node, both of which denote resources. Resources indicated by blank nodes are called
anonymous resources. They are not directly identifiable from the RDF statement. The
9
Semantic Web UNIT – 3
predicate is a URI which also indicates a resource, representing a relationship. The object is a
URI, blank node or a Unicode string literal.
Therefore, producers and consumers of RDF statements must agree on the semantics
of resource identifiers. Such agreement is not inherent to RDF itself, although there are some
controlled vocabularies in common use, such as Dublin Core Metadata, which is partially
mapped to a URI space for use in RDF. The intent of publishing RDF-based ontologies on the
Web is often to establish, or circumscribe, the intended meanings of the resource identifiers
used to express data in RDF. For example, the URI http://www.w3.org/TR/2004/REC-owl-
guide-20040210/wine#Merlot is intended by its owners to refer to the class of all Merlot red
wines by vintner (i.e., instances of http://www.w3.org/TR/2004/REC-owl-guide-
20040210/wine#Merlot each represent the class of all wine produced by a single vintner), a
definition which is expressed by the OWL ontology — itself an RDF document — in which it
occurs. Without careful analysis of the definition, one might erroneously conclude that an
instance of http://www.w3.org/TR/2004/REC-owl-guide-20040210/wine#Merlot was
something physical, instead of a type of wine.
Note that this is not a 'bare' resource identifier, but is rather a URI reference, containing the
'#' character and ending with a fragment identifier.
#############################################################
Examples
[edit]Example 1: RDF Description of a person named Eric Miller[17]
The following example is taken from the W3C website[17] describing a resource with
statements "there is a Person identified byhttp://www.w3.org/People/EM/contact#me,
whose name is Eric Miller, whose email address is [email protected], and whose title is Dr.".
11
Semantic Web UNIT – 3
http://www.w3.org/People/EM/contact#me, http://www.w3.org/2000/10/swap/pim/
contact#personalTitle, "Dr."
http://www.w3.org/People/EM/contact#me, http://www.w3.org/1999/02/22-rdf-
syntax-ns#type,http://www.w3.org/2000/10/swap/pim/contact#Person
http://www.w3.org/People/EM/contact#me, http://www.w3.org/2000/10/swap/pim/
contact#mailbox, [email protected]
13
Semantic Web UNIT – 3
14
Semantic Web UNIT – 3
The following example shows how such simple claims can be elaborated on, by combining
multiple RDF vocabularies. Here, we note that the primary topic of the Wikipedia page is a
"Person" whose name is "Tony Benn":
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="http://en.wikipedia.org/wiki/Tony_Benn">
<dc:title>Tony Benn</dc:title>
<dc:publisher>Wikipedia</dc:publisher>
<foaf:primaryTopic>
<foaf:Person>
<foaf:name>Tony Benn</foaf:name>
</foaf:Person>
</foaf:primaryTopic>
</rdf:Description>
</rdf:RDF>
[edit]Applications
Sigma - Application from DERI in National University of Ireland, Galway(NUIG).
Creative Commons - Uses RDF to embed license information in web pages and mp3 files.
DOAC (Description of a Career) - supplements FOAF to allow the sharing
of résumé information.
Enterprise Architect: MDG Technology for ODM (ODM supports RDF and OWL).
FOAF (Friend of a Friend) - designed to describe people, their interests and
interconnections.
Haystack client - Semantic web browser from MIT CS & AI lab.[19]
IDEAS Group - developing a formal 4D Ontology for Enterprise Architecture using RDF as
the encoding.[20]
Microsoft shipped a product, Connected Services Framework,[21] which provides RDF-
based Profile Management capabilities.
MusicBrainz - Publishes information about Music Albums.[22]
NEPOMUK, an open-source software specification for a Social Semantic desktop uses RDF
as a storage format for collected metadata. NEPOMUK is mostly known because of its
integration into the KDE SC 4 desktop environment.
15
Semantic Web UNIT – 3
RDF Site Summary - one of several "RSS" languages for publishing information about
updates made to a web page; it is often used for disseminating news article summaries
and sharing weblog content.
ResumeRDF - developed to express information contained in a personal Resume or
Curriculum Vitae (CV) on the Semantic Web. This includes information about work and
academic experience, skills, etc.
Simple Knowledge Organization System (SKOS) - a KR representation intended to support
vocabulary/thesaurus applications
SIOC (Semantically-Interlinked Online Communities) - designed to describe online
communities and to create connections between Internet-based discussions from
message boards, weblogs and mailing lists.[23]
Smart-M3 - provides an infrastructure for using RDF and specifically uses the ontology
agnostic nature of RDF to enable heterogeneous mashing-up of information[24]
Many other RDF schemas are available by searching SchemaWeb.[25]
Some uses of RDF include research into social networking. This is important because it could
help governments keep track of undesirables. It will also help people in business fields
understand better their relationships with members of industries that could be of use for
product placement.[26] It will also help scientists understand how people are connected to one
another.
RDF is being used to have a better understanding of traffic patterns. This is because the
information regarding traffic patterns is on different websites, and RDF is used to integrate
information from different sources on the web. Before, the common methodology was using
keyword searching, but this method is problematic because it does not consider synonyms.
This is why ontologies are useful in this situation. But one of the issues that comes up when
trying to efficiently study traffic is that to fully understand traffic, concepts related to people,
streets, and roads must be well understood. Since these are human concepts, they require the
addition of fuzzy logic. This is because values that are useful when describing roads, like
slipperiness, are not precise concepts and cannot be measured. This would imply that the
best solution would incorporate both fuzzy logic and ontology.[27]
RDF Schema
RDF Schema (variously abbreviated as RDFS, RDF(S), RDF-S, or RDF/S) is a set of classes
with certain properties using the RDF extensible representation language, providing basic
elements for the description of ontologies, otherwise called RDF vocabularies, intended to
16
Semantic Web UNIT – 3
structure RDF resources. These resources can be saved in a triple store to reach them with
the query language SPARQL.
17
Semantic Web UNIT – 3
For example, the following declarations are used to express that the
property ex:employer relates a subject, which is of typefoaf:Person, to an object, which is of
type foaf:Organization:
ex:employer rdfs:domain foaf:Person
ex:employer rdfs:range foaf:Organization
Given the previous two declarations, the following triple requires that ex:John is necessarily
a foaf:Person, and ex:CompanyX is necessarily a foaf:Organization:
ex:John ex:employer ex:CompanyX
rdf:type is a property used to state that a resource is an instance of a class.
rdfs:subClassOf allows to declare hierarchies of classes.
[edit]Utility Properties
rdfs:seeAlso is an instance of rdf:Property that is used to indicate a resource that might
provide additional information about the subject resource.
rdfs:isDefinedBy is an instance of rdf:Property that is used to indicate a resource
defining the subject resource. This property may be used to indicate an RDF vocabulary in
which a resource is described.
[edit]RDFS Entailment
An entailment regime defines by RDFs (,OWL, etc.) not only which entailment relation is used,
but also which queries and graphs are well-formed for the regime. The RDFS entailment is a
standard entailment relations in the semantic web.
18
Semantic Web UNIT – 3
For example, the following declares that 'Dog is an animal','Cat1 is a cat', 'Zoos host animals'
and 'Zoo1 hosts the Cat2' :
But this graph is not well formed because the system can not guess that a cat is an animal. We
have to add 'Cats are animals' to do a well-formed graph with :
Dog1 is an animal
Cat1 is a cat
Cats are animals
Zoos host animals
Zoo1 hosts the Cat2
RDF/turtle
If your triplestore (or RDF database) implements the regime entailment of RDF and RDFS,
the SPARQL query as follows (the keyword "a" is equivalent to rdf:type in SPARQL):
PREFIX ex: <http://example.org/>
SELECT ?animal
19
Semantic Web UNIT – 3
WHERE
{ ?animal a ex:animal . }
Give the following result with cat2 because the Cat's type inherits of Animal's type:
animal
<http://example.org/dog1>
<http://example.org/cat1>
<http://example.org/cat2>
RDFS Example
The following example demonstrates some of the RDFS facilities:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">
<rdf:Description rdf:ID="animal">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Description>
<rdf:Description rdf:ID="horse">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#animal"/>
</rdf:Description>
</rdf:RDF>
Example Abbreviated
Since an RDFS class is an RDF resource we can abbreviate the example above by using
rdfs:Class instead of rdf:Description, and drop the rdf:type information:
<?xml version="1.0"?>
<rdf:RDF
20
Semantic Web UNIT – 3
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">
<rdfs:Class rdf:ID="horse">
<rdfs:subClassOf rdf:resource="#animal"/>
</rdfs:Class>
</rdf:RDF>
XML Schema
An XML Schema describes the structure of an XML document.
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The XML Schema language is also referred to as XML Schema Definition (XSD).
21
Semantic Web UNIT – 3
An XML Schema:
22
Semantic Web UNIT – 3
With XML Schemas, the sender can describe the data in a way that the receiver will understand.
A date like: "03-11-2004" will, in some countries, be interpreted as 3.November and in other countries
as 11.March.
<date type="date">2004-03-11</date>
ensures a mutual understanding of the content, because the XML data type "date" requires the format
"YYYY-MM-DD".
Even if documents are well-formed they can still contain errors, and those errors can have serious
consequences.
23
Semantic Web UNIT – 3
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
A DTD File
The following example is a DTD file called "note.dtd" that defines the elements of the XML document
above ("note.xml"):
The first line defines the note element to have four child elements: "to, from, heading, body".
Line 2-5 defines the to, from, heading, body elements to be of type "#PCDATA".
An XML Schema
The following example is an XML Schema file called "note.xsd" that defines the elements of the XML
document above ("note.xml"):
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
24
Semantic Web UNIT – 3
The note element is a complex type because it contains other elements. The other elements (to, from,
heading, body) are simple types because they do not contain other elements. You will learn more about
simple and complex types in the following chapters.
A Reference to a DTD
This XML document has a reference to a DTD:
<?xml version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
25