Very basic introductory talk about the Semantic Web, given to undergraduate and posgraduate students of Universidad del Valle (Cali, Colombia) in September 2010
DevoxxFR 2024 Reproducible Builds with Apache Maven
Introduction to the Semantic Web
1. Introduction to the
Semantic Web
Oscar Corcho (ocorcho@fi.upm.es)
Universidad Politécnica de Madrid
Universidad del Valle, Cali, Colombia
September 7th 2010
Acknowledgements: Asunción Gómez-Pérez, Jesús Barrasa,
Angel López Cima, Oscar Muñoz, Jose Angel Ramos Gargantilla,
María del Carmen Suárez de Figueroa, Boris Villazón, Mariano
Fernández López, Luis Vilches, Carlos Ruíz Moreno
Work distributed under the license Creative Commons Attribution-
Noncommercial-Share Alike 3.0
2. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
3. Health and Safety Notice
Classification
Disclaimer: This is not the only way that applications can be classified or
grouped. In fact, many other possibilities exist for the classification of
Semantic Web application.
4. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
6. From Web1.0 to Web2.0
More than
30M pages
More than
1000M users
New requirements start arising
• Cooperation
WWW
• Dynamicity
HTTP, HTML, URI • Decentralised change
• Heterogeneity
• Multimedia content
9. Web Applications
• Who doesn‟t know what is a Web application?
• Let‟s define it
• A web application is an application that is accessed over a
network such as the Internet or an intranet.
• The term may also mean a computer software application that is…
• … hosted in a browser-controlled environment (e.g. a Java
applet)
• … or coded in a browser-supported language (such as
JavaScript, combined with a browser-rendered markup
language like HTML)
• … and reliant on a common web browser to render the
application executable.
• Some comments
• Too many technology-related terms in the definition
• No mentions to the evolution of user-generated content (Web1.0
Web2.0), although it is already well understood.
10. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
11. (Syntactic) Web Limitations
Resource
href href href
Resource Resource Resource Resource
href href href
href Resource
href href
href
Resource Resource Resource
href href
Resource
• A place where computers do the
presentation (easy) and people do
the linking and interpreting (hard).
• Why not get computers to do more
of the hard work?
12. Hard Work using the Syntactic Web…
Find images of Oscar Corcho
…Marta Millán (Universidad del Valle)…
13. What’s the Problem?
• Typical web page
markup consists of:
• Rendering information
(e.g., font size and
colour)
• Hyper-links to related
content
• Semantic content is
accessible to humans
but not (easily) to
computers…
14. Information we can see…
Universidad del Valle
Organización Universitaria
Alumnos
Investigación
Deporte
Eventos y actividades… (en la universidad/fuera…?)
Noticias
Tipos de personas a los que va dirigido
Alumnos
Profesores
Personal de Administración y Servicios
…
15. Information a machine can see…
WWW2002
The eleventh inteqnational woqld wide webcon
Sheqaton waikiki hotel
Honolulu, hawaii, USA
7-11 may 2002
1 location 5 days leaqn inteqact
Registeqed paqticipants coming fqom
austqalia, canada, chile denmaqk, fqance,
geqmany, ghana, hong kong, india, iqeland,
italy, japan, malta, new zealand, the
netheqlands, noqway, singapoqe, switzeqland,
the united kingdom, the united states,
vietnam, zaiqe
Registeq now
On the 7th May Honolulu will pqovide the
backdqop of the eleventh inteqnational woqld
wide web confeqence. This pqestigious event
Speakeqs confiqmed
Tim beqneqs-lee
Tim is the well known inventoq of the Web,…
16. Solution: XML markup with “meaningful”
tags?
<name>WWW2002
The eleventh inteqnational woqld wide webcon</name>
<date>7-11 may 2002</date>
<location>Sheqaton waikiki hotel
Honolulu, hawaii, USA</location>
<introduction>Registeq now
On the 7th May Honolulu will pqovide the
backdqop of the eleventh inteqnational woqld
wide web confeqence. This pqestigious event
Speakeqs confiqmed</introduction>
<speaker>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the Web,</bio>
</speaker>
<speaker>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the Web,</bio>
</speaker>
<registration>Registeqed paqticipants coming fqom
austqalia, canada, chile denmaqk, fqance,
geqmany, ghana, hong kong, india, iqeland,
italy, japan, malta, new zealand, the
netheqlands, noqway, singapoqe, switzeqland, the
united kingdom, the united states, vietnam,
zaiqe<registration>
17. But What About…?
<conf>WWW2002
The eleventh inteqnational woqld wide webcon</conf>
<date>7-11 may 2002</date>
<place>Sheqaton waikiki hotel
Honolulu, hawaii, USA</place>
<introduction>Registeq now
On the 7th May Honolulu will pqovide the
backdqop of the eleventh inteqnational woqld
wide web confeqence. This pqestigious event
Speakeqs confiqmed</introduction>
<speaker>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the Web,</bio>
</speaker>
<speaker>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the Web,</bio>
</speaker>
<registration>Registeqed paqticipants coming fqom
austqalia, canada, chile denmaqk, fqance,
geqmany, ghana, hong kong, india, iqeland,
italy, japan, malta, new zealand, the
netheqlands, noqway, singapoqe, switzeqland, the
united kingdom, the united states, vietnam,
zaiqe<registration>
18. Still the Machine only sees…
<conf>WWW2002
The eleventh inteqnational woqld wide webcon<conf>
<date>7-11 may 2002</date>
<place>Sheqaton waikiki hotel
Honolulu, hawaii, USA<place>
<intqoduction>Registeq now
On the 7th May Honolulu will pqovide the
backdqop of the eleventh inteqnational woqld
wide web confeqence. This pqestigious event
Speakeqs confiqmed</intqoduction>
<speakeq>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the
Web,</bio>
</speakeq>
<speakeq>Tim beqneqs-lee
<bio>Tim is the well known inventoq of the
Web,</bio>
</speakeq>
<qegistqation>Registeqed paqticipants coming fqom
austqalia, canada, chile denmaqk, fqance,
geqmany, ghana, hong kong, india, iqeland,
italy, japan, malta, new zealand, the
netheqlands, noqway, singapoqe, switzeqland, the
united kingdom, the united states, vietnam,
19. What is the Semantic Web?
• An extension of the current
Web…
• … where information and services
are given well-defined and
explicitly represented meaning, …
• … so that it can be shared and
used by humans and machines, ...
• ... better enabling them to work in
cooperation
• How?
• Promoting information exchange
by tagging web content with
machine processable descriptions
of its meaning.
• And technologies and
infrastructure to do this
20. Need to Add “Semantics”
• Agreement on the meaning of annotations
• Shared understanding of a domain of interest
• Formal and machine manipulable model of a domain of interest
• An ontology is an engineering artifact, which provides:
• A vocabulary of terms
• A set of explicit assumptions regarding the intended meaning of the
vocabulary.
• Almost always including concepts and their classification
• Almost always including properties between concepts
• Besides...
• The meaning (semantics) of such terms is formally specified
• New terms can be formed by combining existing ones
• Can also specify relationships between terms in multiple ontologies
21. Types of ontologies
Thesauri General
“narrower term” Frames Logical
Formal
relation (properties) constraints
Catalog/ID is-a
Terms/ Informal Formal Value Disjointness,
glossary is-a instance Restrs. Inverse, part-Of ...
Lassila O, McGuiness D (2001) The Role of Frame-Based Representation on the
Semantic Web. Technical Report. Knowledge Systems Laboratory. Stanford University.
KSL-01-02
22. A catalog
Consoles and Accessories (1150)
Amiga (12)
Amstrad (28)
Atari (22)
Commodore (13)
Microsoft (31)
Xbox (20)
Catalog: finite list of terms. It can provide
Xbox360 (11)
an unambiguous interpretation of terms.
Nintendo (338)
(E.g. 1150 unambiguously denotes
GameBoy (47)
“consoles and accessories“.)
GameBoy Advance (40)
GameBoy Color (16)
Gamecube (38)
GameBoy Micro (2)
Nintendo 64 (74)
http://www.todocoleccion.net/catalogo.cfm
SuperNintendo (51)
Nintendo DS (52)
Nintendo wii (16)
23. A glossary of terms
Action - Proceeding taken in a court of law. Synonymous
with case, suit lawsuit.
Adjudication - A judgment or decree
Adversary system - Basic U.S. trial system in which each
Glossary: list of terms and meanings,
of the opposing parties has opportunity to state his
which are expressed as natural language
viewpoints before the court. Plaintiff argues for defendant's
statements.
guilt (criminal) or liability (civil). Defense argues for
defendant's innocence (criminal) or against liability civil)
Affidavit - A written or printed declaration or statement http://www.headinjury.com/lawglossary.htm
under oath
Affirm - The assertion of an appellate court that the
judgment of the lower court is correct and should stand.
24. Thesauri
Agricultural economics MT 6.35 Agriculture
FR Agroéconomie
SP Economía agraria
NT1 Agricultural credit
NT1 Agricultural development Thesaurus: list of terms that specifies
NT2 Subsistence agriculture what terms are preferred, the relation
NT1 Agricultural markets narrower term, etc. (e.g. “agricultural
NT1 Agricultural planning credit“ is a narrower term [NT] than
NT1 Agricultural policy “agricultural economics“)
NT2 Agricultural prices
NT2 Food security
NT1 Agricultural production
NT1 Agricultural statistics
NT2 Food statistics
NT1 Land economics
NT2 Agrarian structure http://www2.ulcc.ac.uk/unesco/
NT3 Land reform
NT2 Farm size
NT2 Land reclamation
A searching system uses ”agroindustry” when the query
NT2 Land tenure
includes ”agrocultural industry”,
NT2 Land value
RT Agricultural enterprises
RT Agroindustry Agricultural industry USE Agroindustry
RT Rural economy
25. Informal is-a
Term hierarchies: they
provide a general notion of
generalization and specialization.
http://dir.yahoo.com/
26. Formal is-a
Strict subclass hierarchies: if A is a subclass of B,
then if an object is an instance of A necessarily
implies that the object is instance of B.
http://www.xml.com/pub/a/2005/01/26/formtax.html
…
<owl:Class rdf:ID="Transportation"/>
<owl:Class rdf:ID="AirVehicle">
<rdfs:subClassOf rdf:resource="#Transportation"/>
</owl:Class>
<owl:Class rdf:about="#GroundVehicle">
<rdfs:subClassOf rdf:resource="#Transportation"/>
</owl:Class>
<owl:Class rdf:about="#Automobile">
<rdfs:subClassOf> <owl:Class rdf:ID="GroundVehicle"/>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:ID="Truck">
<rdfs:subClassOf> <owl:Class rdf:about="#GroundVehicle"/>
</rdfs:subClassOf>
</owl:Class>
…
27. Logical constraints
Ontologies with general logical constraints:
they include constraints, explicit formal definitions,
etc.
<!-- http://www.owl-ontologies.com/unnamed.owl#hasDeparturePlace -->
<owl:ObjectProperty rdf:about="#hasDeparturePlace">
<rdfs:domain rdf:resource="#travel"/>
<rdfs:range rdf:resource="#place"/>
</owl:ObjectProperty>
<!-- http://www.owl-ontologies.com/unnamed.owl#hasArrivalPlace -->
<owl:ObjectProperty rdf:about="#hasArrivalPlace">
<rdfs:domain rdf:resource="#travel"/>
<rdfs:range rdf:resource="#place"/>
</owl:ObjectProperty>
TRAVEL
Gómez-Pérez A, Fernández-López M, Corcho O (2003) Has departure place Has arrival place
Ontological engineering. Springer-Verlag, London
PLACE
travel (= 1 departurePlace.place) (= 1 arrivalPlace.place) ( hasTransportMean.string)
28. Ontology Languages
• A large amount of work on Semantic Web has concentrated on
the definition of a collection or “stack” of languages.
• Used to support the representation and use of metadata
• Basic machinery that we can use to represent the extra semantic
information needed for the Semantic Web
SWRL
OWL
RDFS
RDF(S)
RDF
XML
30. RDF: Resource Description Framework
• W3C recommendation
• RDF is graphical formalism ( + XML syntax + semantics)
• For representing metadata
• For describing the semantics of information in a machine-
accessible way
• Resources are described in terms of properties and property
values using RDF statements
• Statements are represented as triples, consisting of a subject,
predicate and object. [S, P, O]
“Oscar Corcho García”
person:hasName
person:hasColleague
oeg:Oscar oeg:Asun
person:hasColleague person:hasHomePage
oeg:Raul “http://www.fi.upm.es/”
30
31. URIs (Universal-Uniform Resource Identifer)
• Two types of identifiers can be used to identify Linked
Data resources
• Hash URIs or URIRefs (Unique Resource Identifiers
References)
• A URI and an optional Fragment Identifier separated
from the URI by the hash symbol „#‟
• http://www.ontology.org/people#Person
• people:Person
• Slash URIs or plain URIs can also be used, as in FOAF:
• http://xmlns.com/foaf/0.1/Person
31
32. RDF Serialisations
• Normative
• RDF/XML (www.w3.org/TR/rdf-syntax-grammar/)
• Alternative (for human consumption)
• N3 (http://www.w3.org/DesignIssues/Notation3.html)
• Turtle (http://www.dajobe.org/2004/01/turtle/)
• TriX (http://www.w3.org/2004/03/trix/)
• …
Important: the RDF serializations allow different
syntactic variants. E.g., the order of RDF statements
has no meaning
32
35. Exercise
• Objective
• Get used to the different syntaxes of RDF
• Tasks
• Take the text of an RDF file and create its corresponding graph
• Take an RDF graph and create its corresponding RDF/XML and N3 files
35
36. Exercise 1.a. Create a graph from a file
• Open the file StickyNote_PureRDF.rdf
• Create the corresponding graph from it
• Compare your graph with those of your colleagues
36
38. Exercise 1.b. Create files from a graph
• Transform the following graph into N3 syntax
hasMeasurement
Measurement8401
includes Sensor029
hasTemperature atTime
Class01
includes
29 2010-06-12T12:00:12
Computer101
hasOwner
User10A
hasName
Pedro
38
39. Blank nodes: structured property values
• Most real-world data involves structures that are more
complicated than sets of RDF triple statements
This intermediate URI does not
“Oscar Corcho García” need to have a name
person:hasName
person:hasPostalAddress
oeg:Oscar
address:city address:hasStreetName
city:BoadillaDelMonte Campus de Montegancedo s/n
• In RDF/XML, it is an <rdf:Description> node with no
rdf:about
• In N3, it is a resource identifier that starts with „_‟
• E.g., “_:nodeX”
39
40. Typed literals
• So far, all values have been presented as strings
• XML Schema datatypes can be used to specify
values (objects in some RDF triple statements)
person:hasBirthDate
oeg:Oscar 1976-02-02
• In RDF/XML, this is expressed as:
• <rdf:Description rdf:about=”#Oscar”>
<person:hasBirthDate
rdf:datatype="http://www.w3.org/2001/XMLSchema#date">1976-02-02
</person:hasBirthDate>
</rdf:Description>
• In N3, this is expressed as:
• oeg:Oscar person:hasBirthDate ”1976-02-02”^^xsd:date .
40
41. RDF Containers
• There is often the need to describe groups of things
• A book was created by several authors
• A lesson is taught by several persons
• etc.
• RDF provides a container vocabulary
• rdf:Bag A group of resources or literals, possibly including
duplicate members, where the order of members is not
significant
• rdf:Seq A group of resources or literals, possibly including
duplicate members, where the order of members is significant
• rdf:Alt A group of resources or literals that are alternatives
(typically for a single value of a property)
person:hasEmailAddress rdf:type
oeg:Oscar rdf:Seq
rdf:_1 rdf:_2
“ocorcho@fi.upm.es” “oscar.corcho@upm.es”
41
42. RDF Reification
• RDF statements about other RDF statements
• “Raúl believes that Oscar‟s birthdate is on Feb 2nd, 1976 and that
his e-mail address is ocorcho@fi.upm.es”
modal:believes
oeg:Raúl oeg:Oscar
person:hasEmailAddress person:hasBirthDate
“ocorcho@fi.upm.es” 02/02/1976
• RDF Reification
• Allows expressing beliefs (and other modalities)
• Allows expressing trust models, digital signatures, etc.
• Allows expressing metadata about metadata
42
43. Main value of a structured value
• Sometimes one of the values of a structured value is
the main one
• The weight of an item is 2.4 kilograms
• The most important value is 2.4, which is expressed with
rdf:value
• Scarcely used
product:hasWeight
product:Item1
rdf:value units:hasWeightUnit
2.4 units:kilogram
43
45. RDF inference. Graph matching techniques
• RDF inference is based on graph matching
techniques
• Basically, the RDF inference process consists of the
following steps:
• Transform an RDF query into a template graph that has to
be matched against the RDF graph
• It contains constant and variable nodes, and constant
and variable edges between nodes
• Match against the RDF graph, taking into account constant
nodes and edges
• Provide a solution for variable nodes and edges
45
46. RDF inference. Examples (I)
• Sample RDF graph
“Oscar Corcho García”
person:hasName
person:hasColleague
oeg:Oscar oeg:Asun
person:hasColleague person:hasHomePage
oeg:Raúl “http://www.fi.upm.es/”
• Query: “Tell me who are the persons who have Asun as a
colleague”
person:hasColleague
? oeg:Asun
• Result: oeg:Oscar and oeg:Raúl
46
47. RDF inference. Examples (II)
• Query: “Tell me which are the relationships between
Oscar and Asun”
?
oeg:Oscar oeg:Asun
• Result: oeg:hasColleague
• Query: “Tell me the homepage of Oscar colleagues”
person:hasColleague
oeg:Oscar
person:hasHomePage
?
• Result: “http://www.fi.upm.es/”
47
50. RDFS: RDF Schema
• W3C Recommendation
• RDF Schema extends RDF to enable talking about classes of
resources, and the properties to be used with them
• Class definition: rdfs:Class, rdfs:subClassOf
• Property definition: rdfs:subPropertyOf, rdfs:range, rdfs:domain
• Other primitives: rdfs:comment, rdfs:label, rdfs:seeAlso,
rdfs:isDefinedBy
• RDFS vocabulary adds constraints on models, e.g.:
• x,y,z type(x,y) and subClassOf(y,z) type(x,z)
ex:Animal
rdfs:subClassOf
rdf:type
ex:Oscar ex:Person
50
55. Exercise
•Objective
• Get used to the different syntaxes of RDF(S)
•Tasks
• Take the text of an RDF(S) file and create its corresponding graph
• Take an RDF(S) graph and create its corresponding RDF/XML and N3 files
55
56. Exercise 2.a. Create a graph from a file
• Open the files StickyNote.rdf and StickyNote.rdfs
• Create the corresponding graph from them
• Compare your graph with those of your colleagues
56
59. Exercise 2.b. Create files from a graph
• Transform the following graph into N3 syntax
Room Object Measurement Person
hasMeasurement
includes Sensor029
hasTemperature atTime
Class01
includes
29 2010-06-12T12:00:12
Computer101
hasOwner
User10A
hasName
Pedro
59
63. RDF(S) limitations
• RDFS too weak to describe resources in sufficient detail
• No localised range and domain constraints
• Can‟t say that the range of hasChild is person when applied to
persons and elephant when applied to elephants
• No existence/cardinality constraints
• Can‟t say that all instances of person have a mother that is also a
person, or that persons have exactly 2 parents
• No boolean operators
• Can‟t say or, not, etc.
• No transitive, inverse or symmetrical properties
• Can‟t say that isPartOf is a transitive property, that hasPart is the
inverse of isPartOf or that touches is symmetrical
• Difficult to provide reasoning support
• No “native” reasoners for non-standard semantics
• May be possible to reason via FOL axiomatisation
63
64. Exercise
•Objective
• Understand the features of RDF(S) for implementing ontologies, including its
limitations
•Tasks
• Given a scenario description, build a simple ontology in RDF Schema
64
65. Exercise 3. Domain description
• Un lugar puede ser un lugar de interés.
• Los lugares de interés pueden ser lugares turísticos o
establecimientos, pero no las dos cosas a la vez.
• Los lugares turísticos pueden ser palacios, iglesias, ermitas y
catedrales.
• Los establecimientos pueden ser hoteles, hostales o albergues.
• Un lugar está situado en una localidad, la cual a su vez puede ser
una villa, un pueblo o una ciudad.
• Un lugar de interés tiene una dirección postal que incluye su calle y
su número.
• Las localidades tienen un número de habitantes.
• Las localidades se encuentran situadas en provincias.
• Covarrubias es un pueblo con 634 habitantes de la provincia de
Burgos.
• El restaurante “El Galo” está situado en Covarrubias, en la calle
Mayor, número 5.
• Una de las iglesias de Covarrubias está en la calle de Santo
Tomás.
65
68. Sample RDF APIs
• RDF libraries for different languages:
• Java, Python, C, C++, C#, .Net, Javascript, Tcl/Tk, PHP, Lisp, Obj-C,
Prolog, Perl, Ruby, Haskell
• List in http://esw.w3.org/topic/SemanticWebTools
• Usually related to a RDF repository
• Multilanguage:
• Redland RDF Application Framework (C, Perl, PHP, Python and Ruby):
http://www.redland.opensource.ac.uk/
• Java:
• Jena: http://jena.sourceforge.net/
• Sesame: http://www.openrdf.org/
• PHP:
• RAP - RDF API for PHP: http://www4.wiwiss.fu-berlin.de/bizer/rdfapi/
• Python:
• RDFLib: http://rdflib.net/
• Pyrple: http://infomesh.net/pyrple/
68
69. Jena
• Java framework for building Semantic Web
applications
• Open source software from HP Labs
• The Jena framework includes:
• A RDF API
• An OWL API
• Reading and writing RDF in RDF/XML, N3 and N-Triples
• In-memory and persistent storage
• A rule based inference engine
• SPARQL query engine
69
70. Sesame
• A framework for storage, querying and inferencing of RDF
and RDF Schema
• A Java Library for handling RDF
• A Database Server for (remote) access to repositories of
RDF data
• Highly expressive query and transformation languages
• SeRQL, SPARQL
• Various backends
• Native Store
• RDBMS (MySQL, Oracle 10, DB2, PostgreSQL)
• main memory
• Reasoning support
• RDF Schema reasoner
• OWL DLP (OWLIM)
• domain reasoning (custom rule engine)
70
71. Jena example. Graph creation
http://.../JohnSmith
vcard:FN vcard:N
John Smith
vcard:Given vcard:Family
John Smith
// some definitions
String personURI = "http://somewhere/JohnSmith";
String givenName = "John";
String familyName = "Smith";
String fullName = givenName + " " + familyName;
// create an empty
Model Model model = ModelFactory.createDefaultModel();
// create the resource
// and add the properties cascading style
Resource johnSmith = model.createResource(personURI)
.addProperty(VCARD.FN, fullName)
.addProperty(VCARD.N, model.createResource()
.addProperty(VCARD.Given, givenName)
.addProperty(VCARD.Family, familyName));
71
72. Jena example. Read and write
// create an empty model
Model model = ModelFactory.createDefaultModel();
// use the FileManager to find the input file
InputStream in = FileManager.get().open( inputFileName );
if (in == null) {
throw new IllegalArgumentException("File not found");
}
<rdf:RDF
// read the RDF/XML file
model.read(in, ""); xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
// write it to standard out >
model.write(System.out);
<rdf:Description rdf:nodeID="A0">
<vcard:Family>Smith</vcard:Family>
<vcard:Given>John</vcard:Given>
</rdf:Description>
<rdf:Description rdf:about='http://somewhere/JohnSmith/'>
<vcard:FN>John Smith</vcard:FN>
<vcard:N rdf:nodeID="A0"/>
</rdf:Description>
...
</rdf:RDF>
72
76. RDF(S) query languages
• Languages developed to allow accessing datasets expressed in RDF(S)
(and in some cases OWL)
Application Application
SQL queries SPARQL, RQL, etc., queries
Relational RDF(S)
DB OWL
• Supported by the most important language APIs
• Jena (HP labs)
• Sesame (Aduna)
• Boca (IBM)
• ...
• There are some differences wrt. languages like SQL, such as
• Combination of different sources
• Trust management
• Open World Assumption
76
77. Query types
• Selection and extraction
• “Select all the essays, together with their authors and their authors‟
names”
• “Select everything that is related to the book „Bellum Civille‟”
• Reduction: we specify what it should not be returned
• “Select everything except for the ontological information and the book
translators”
• Restructuring: the original structure is changed in the final result
• “Invert the relationship „author‟ by „is author of‟”
• Aggregation
• “Return all the essays together with the mean number of authors per
essay”
• Combination and inferences
• “Combine the information of a book called „La guerra civil‟ and whose
author is Julius Caesar with the book whose identifier is „Bellum Civille‟”
• “Select all the essays, together with its authors and author names”,
including also the instances of the subclasses of Essay
• “Obtain the relationship „coauthor‟ among persons who have written the
same book”
77
78. RDF(S) query language families
• SquishQL Family Triple • RQL Family Description
• SquishQL
database • RQL graphs
Query Query
• SeRQL
• rdfDB Query Language
structure semantics
• eRQL
• RDQL • Controlled natural language
• BRQL • Metalog
• TriQL • Other
• XPath, XSLT, XQuery XML • Algae
• XQuery for RDF repository • iTQL
Query • N3QL
• XsRQL syntax
• PerlRDF Query Language
• TreeHugger and RDFTwig • RDEVICE Deductive
• RDFT, Nexus Query Language
Language • RDFQBE
• RDFPath, Rpath and RXPath • RDFQL
• Versa • TRIPLE
SPARQL • WQL
W3C Recommendation
15 January 2008
78
79. SPARQL
• SPARQL Protocol and RDF Query Language
• Supported by: Jena, Sesame, IBM Boca, etc.
• Features
• It supports most of the aforementioned queries
• It supports datatype reasoning (datatypes can be requested instead
of actual values)
• The domain vocabulary and the knowledge representation
vocabulary are treated differently by the query interpreters
• It allows making queries over properties with multiple values, over
multiple properties of a resource and over reifications
• Queries can contain optional statements
• Some implementations support aggregation queries
• Limitations
• Neither set operations nor existential or universal quantifiers can be
included in the queries
• It does not support recursive queries
79
80. SPARQL is also a protocol
• SPARQL is a Query Language …
Find names and websites of contributors to PlanetRDF:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?website
FROM <http://planetrdf.com/bloggers.rdf>
WHERE {
?person foaf:weblog ?website .
?person foaf:name ?name .
?website a foaf:Document }
• ... and a Protocol
http://.../qps?query-lang=http://www.w3.org/TR/rdf-sparql-query/
&graph-id=http://planetrdf.com/bloggers.rdf&query=PREFIXfoaf:
<http://xmlns.com/foaf/0.1/...
• Services running SPARQL queries over a set of graphs
• A transport protocol for invoking the service
• Based on ideas from earlier protocol work such as Joseki
• Describing the service with Web Service technologies
80
81. SPARQL Endpoints
• SPARQL protocol services
• Enables users (human or other) to query a knowledge base using
SPARQL
• Results are typically returned in one or more machine-processable
formats
• List of SPARQL Endpoints
• http://esw.w3.org/topic/SparqlEndpoints
• Programmatic access using libraries:
• ARC, RAP, Jena, Sesame, Javascript SPARQL, PySPARQL, etc.
• Examples:
Project Endpoint
DBpedia http://dbpedia.org/sparql
BBC Programmes and Music http://bbc.openlinksw.com/sparql/
data.gov http://semantic.data.gov/sparql
data.gov.uk http://data.gov.uk/sparql
Musicbrainz http://dbtune.org/musicbrainz/sparql
81
82. A simple SPARQL query
Data:
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix : <http://example.org/book/> .
:book1 dc:title "SPARQL Tutorial" .
Query:
SELECT ?title
WHERE
{
<http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title .
}
Query result: title
"SPARQL Tutorial"
• A pattern is matched against the RDF data
• Each way a pattern can be matched yields a solution
• The sequence of solutions is filtered by: Project, distinct, order, limit/offset
• One of the result forms is applied: SELECT, CONSTRUCT, DESCRIBE, ASK
82
83. Graph patterns
• Basic Graph Patterns, where a set of triple patterns
must match
• Group Graph Pattern, where a set of graph patterns
must all match
• Optional Graph patterns, where additional patterns
may extend the solution
• Alternative Graph Pattern, where two or more
possible patterns are tried
• Patterns on Named Graphs, where patterns are
matched against named graphs
83
92. Patterns on named graphs II
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?src ?bobNick
FROM NAMED <http://example.org/foaf/aliceFoaf> src bobNick
FROM NAMED <http://example.org/foaf/bobFoaf> <http://example.org/foaf/aliceFoaf> "Bobby"
WHERE
{ <http://example.org/foaf/bobFoaf> "Robert"
GRAPH ?src
{ ?x foaf:mbox <mailto:bob@work.example> .
?x foaf:nick ?bobNick
}
}
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX data: <http://example.org/foaf/>
SELECT ?nick
FROM NAMED <http://example.org/foaf/aliceFoaf>
nick
FROM NAMED <http://example.org/foaf/bobFoaf>
WHERE "Robert"
{
GRAPH data:bobFoaf {
?x foaf:mbox <mailto:bob@work.example> .
?x foaf:nick ?nick }
}
92
94. Value tests
• Based on XQuery 1.0 and XPath 2.0 Function and
Operators
• XSD boolean, string, integer, decimal, float, double,
dateTime
• Notation <, >, =, <=, >= and != for value comparison
Apply to any type
• BOUND, isURI, isBLANK, isLITERAL
• REGEX, LANG, DATATYPE, STR (lexical form)
• Function call for casting and extensions functions
94
95. Solution sequences and modifiers
• Order modifier: put the solutions in SELECT ?name
order WHERE { ?x foaf:name ?name ; :empId ?emp }
ORDER BY ?name DESC(?emp)
• Projection modifier: choose certain SELECT ?name
variables WHERE
{ ?x foaf:name ?name }
• Distinct modifier: ensure solutions
in the sequence are unique SELECT DISTINCT ?name
WHERE { ?x foaf:name ?name }
• Reduced modifier: permit
elimination of some non-unique SELECT REDUCED ?name
solutions WHERE { ?x foaf:name ?name }
• Limit modifier: restrict the number of
solutions SELECT ?name
WHERE { ?x foaf:name ?name }
LIMIT 20
• Offset modifier: control where the
solutions start from in the overall SELECT ?name WHERE { ?x foaf:name ?name }
sequence of solutions ORDER BY ?name
LIMIT 5
OFFSET 10
95
96. SPARQL query forms
• SELECT
• Returns all, or a subset of, the variables bound in a query
pattern match
• CONSTRUCT
• Returns an RDF graph constructed by substituting variables
in a set of triple templates
• ASK
• Returns a boolean indicating whether a query pattern
matches or not
• DESCRIBE
• Returns an RDF graph that describes the resources found
96
103. OWL Basics (on top of RDF and RDFS)
• Set of constructors for concept expressions
• Booleans: and/or/not
• A Session is a TheoreticalSession or a HandsonSession
• Slides are not the same as Code
• Quantification: some/all
• Sessions must have some EducationalMaterial
• Sessions can only have Presenters that have developed Grid
applications or Grid middleware
• Axioms for expressing constraints
• Necessary and Sufficient conditions on classes
• A Session that hasEducationalMaterial Code is a
HandsonSession.
• Disjointness
• TheoreticalSessions are disjoint with HandsonSessions
• Property characteristics: transitivity, inverse
105. Description Logics
• A family of logic based Knowledge Representation formalisms
• Descendants of semantic networks and KL-ONE
• Describe domain in terms of concepts (classes), roles (relationships)
and individuals
• Specific languages characterised by the constructors and axioms
used to assert knowledge about classes, roles and individuals.
• Example: ALC (the least expressive language in DL that is
propositionally closed)
• Constructors: boolean (and, or, not)
• Role restrictions
• Distinguished by:
• Model theoretic semantics
• Decidable fragments of FOL
• Closely related to Propositional Modal & Dynamic Logics
• Provision of inference services
• Sound and complete decision procedures for key problems
• Implemented systems (highly optimised)
106. Structure of DL Ontologies
• A DL ontology can be divided into two parts:
• Tbox (Terminological KB): a set of axioms that describe the
structure of a domain :
• Doctor Person
• Person Man Woman
• HappyFather Man hasDescendant.(Doctor
hasDescendant.Doctor)
• Abox (Assertional KB): a set of axioms that describe a
specific situation :
• John HappyFather
• hasDescendant (John, Mary)
107. Most common constructors in class definitions
• Intersection: C1 ... Cn Human Male
• Union: C1 ... Cn Doctor Lawyer
• Negation: C Male
• Nominals: {x1} ... {xn} {john} ... {mary}
• Universal restriction: P.C hasChild.Doctor
• Existential restriction: P.C hasChild.Lawyer
• Maximum cardinality: nP.C 3hasChild.Doctor
• Minimum cardinality: nP.C 1hasChild.Male
• Specific Value: P.{x} hasColleague.{Matthew}
• Nesting of constructors can be arbitrarily complex
• Person hasChild.(Doctor hasChild.Doctor)
• Lots of redundancy
• A B is equivalent to ( A B)
• P.C is equivalent to P. C
108. OWL (1.0 and 1.1)
February 2004
Web Ontology Language
Built on top of RDF(S)
Three layers:
- OWL Lite
- A small subset of primitives
- Easier for frame-based tools to transition to
- OWL DL
- Description logic
- Decidable reasoning
- OWL Full
- RDF extension, allows metaclasses
Several syntaxes:
- Abstract syntax
- Manchester syntax
- RDF/XML
109. OWL 2 (I). New features
• October 2009
• New features
• Syntactic sugar
• Disjoint union of classes
• New expressivity
• Keys
• Property chains
• Richer datatypes, data ranges
• Qualified cardinality restrictions
• Asymmetric, reflexive, and disjoint properties
• Enhanced annotation capabilities
• New syntax
• OWL2 Manchester syntax
110. OWL 2 (II). Three new profiles
• OWL2 EL
• Ontologies that define very large numbers of classes and/or properties,
• Ontology consistency, class expression subsumption, and instance
checking can be decided in polynomial time.
• OWL2 QL
• Sound and complete query answering is in LOGSPACE (more precisely, in
AC0) with respect to the size of the data (assertions),
• Provides many of the main features necessary to express conceptual
models (UML class diagrams and ER diagrams).
• It contains the intersection of RDFS and OWL 2 DL.
• OWL2 RL
• Inspired by Description Logic Programs and pD*.
• Syntactic subset of OWL 2 which is amenable to implementation using rule-
based technologies, and presenting a partial axiomatization of the OWL 2
RDF-Based Semantics in the form of first-order implications that can be
used as the basis for such an implementation.
• Scalable reasoning without sacrificing too much expressive power.
• Designed for
• OWL applications trading the full expressivity of the language for
efficiency,
• RDF(S) applications that need some added expressivity from OWL 2.
111. OWL: Most common constructors
Intersection: C1 ... Cn intersectionOf Human Male
Union: C1 ... Cn unionOf Doctor Lawyer
Negation: C complementOf Male
Nominals: {x1} ... {xn} oneOf {john} ... {mary}
Universal restriction: P.C allValuesFrom hasChild.Doctor
Existential restriction: P.C someValuesFrom hasChild.Lawyer
Maximum cardinality: nP[.C] maxCardinality (qualified or not) 3hasChild[.Doctor]
Minimum cardinality: nP[.C] minCardinality (qualified or not) 1hasChild[.Male]
Exact cardinality: =nP[.C] exactCardinality (qualified or not) =1hasMother[.Female]
Specific Value: P.{x} hasValue hasColleague.{Matthew}
Local reflexivity: -- hasSelf Narcisist Person hasSelf(loves)
Keys -- hasKey hasKey(Person, passportNumber, country)
Subclass C1 C2 subClassOf Human Animal Biped
Equivalence C1 C2 equivalentClass Man Human Male
Disjointness C1 C2 disjointWith, AllDisjointClasses Male Female
DisjointUnion C C1 ... Cn and
Ci Cj forall i≠j disjointUnionOf Person DisjointUnionOf (Man, Woman)
Metaclasses and annotations on axioms are also valid in OWL2, and declarations of classes have to provided.
Full list available in reference specs and in the Quick Reference Guide: http://www.w3.org/2007/OWL/refcard
112. OWL: Most common constructors
Subproperty P1 P2 subPropertyOf hasDaughter hasChild
Equivalence P1 P2 equivalentProperty cost price
DisjointProperties P1 ... Pn disjointObjectProperties hasDaughter hasSon
Inverse P1 P2- inverseOf hasChild hasParent-
Transitive P+ P TransitiveProperty ancestor+ ancestor
Functional 1P FunctionalProperty T 1hasMother
InverseFunctional 1P- InverseFunctionalProperty T 1hasPassportID-
Reflexive ReflexiveProperty
Irreflexive IrreflexiveProperty
Asymmetric AsymmetricProperty
Property chains P P1 o ... o Pn propertyChainAxiom hasUncle hasFather o hasBroth
Equivalence {x1} {x2} sameIndividualAs {oeg:OscarCorcho} {img:Oscar}
Different {x1} {x2} differentFrom, AllDifferent {john} {peter}
NegativePropertyAssertion NegativeDataPropertyAssertion {hasAge john 35}
NegativeObjectPropertyAssertion {hasChild john peter}
Besides, top and bottom object and datatype properties exist
113. Basic Inference Tasks
• Subsumption – check knowledge is correct (captures intuitions)
• Does C subsume D w.r.t. ontology O? (in every model I of O, CI DI )
• Equivalence – check knowledge is minimally redundant (no
unintended synonyms)
• Is C equivalent to D w.r.t. O? (in every model I of O, CI = DI )
• Consistency – check knowledge is meaningful (classes can have
instances)
• Is C satisfiable w.r.t. O? (there exists some model I of O s.t. CI )
• Instantiation and querying
• Is x an instance of C w.r.t. O? (in every model I of O, xI CI )
• Is (x,y) an instance of R w.r.t. O? (in every model I of O, (xI,yI) RI )
• All reducible to KB satisfiability or concept satisfiability w.r.t. a KB
• Can be decided using highly optimised tableaux reasoners
115. Main References
W3C OWL Working Group (2009) OWL2 Web Ontology Language Document Overview.
http://www.w3.org/TR/2009/REC-owl2-overview-20091027/
Dean M, Schreiber G (2004) OWL Web Ontology Language Reference. W3C Recommendation.
http://www.w3.org/TR/owl-ref/
Gómez-Pérez, A.; Fernández-López, M.; Corcho, O. Ontological Engineering. Springer Verlag. 2003
Capítulo 4: Ontology languages
Baader F, McGuinness D, Nardi D, Patel-Schneider P (2003)
The Description Logic Handbook: Theory, implementation and applications.
Cambridge University Press, Cambridge, United Kingdom
Jena web site: http://jena.sourceforge.net/
Jena API: http://jena.sourceforge.net/tutorial/RDF_API/
Jena tutorials: http://www.ibm.com/developerworks/xml/library/j-jena/index.html
http://www.xml.com/pub/a/2001/05/23/jena.html
Pellet: http://clarkparsia.com/pellet
RACER: http://www.racer-systems.com/
FaCT++: http://owl.man.ac.uk/factplusplus/
HermIT: http://hermit-reasoner.com/
116. Ontology Languages
• A large amount of work on Semantic Web has concentrated on
the definition of a collection or “stack” of languages.
• Used to support the representation and use of metadata
• Basic machinery that we can use to represent the extra semantic
information needed for the Semantic Web
SWRL
Inference
OWL
Integration
Integration
RDFS
RDF(S)
Annotation
RDF Reasoning over the information we have
Could be light-weight (taxonomy)
XML Could be heavy-weight (logic-style)
Integrating information sources
Associating metadata to resources (bindings)
117. The evolution of the Semantic Web
pre-Semantic Web Semantic Web 1.0 Semantic Web 3.0
Semantic Web
Challenge
2004 2008
No standardised formats RDFS, OWL • Cooperation Dynamicity
e.g., (KA)2 • Decentralised change
• Heterogeneity Multimedia
118. [Semantic | Web]+ Applications (I)
• No definition in Wikipedia… ;-(
• Why [Semantic | Web]+ application?
119. [Semantic | Web]+ Applications (II)
• Why [Semantic | Web]+ application?
• Most of them are focused on the use of semantics
• In fact, probably it would be better to use
Semantic [Web]* application
• However, many of them are not so Web-oriented
• E.g., very common in data integration approaches
• http://www.readwriteweb.com/archives/10_semantic_
apps_to_watch.php
• A key element [of a Semantic Web App] is that the apps all
try to determine the meaning of text and other data, and
then create connections for users. Besides, data
portability and connectibility are keys to these new
semantic apps - i.e. using the Web as platform.
120. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
121. What is the Web of Linked Data?
• An extension of the current
Web…
• … where informationdata services
and
are given well-defined and explicitly
represented meaning, …
• … so that it can be shared and used
by humans and machines, ...
• ... better enabling them to work in
cooperation
• How?
• Promoting information exchange by
tagging web content with machine
processable descriptions of its
meaning.
• And technologies and infrastructure
to do this
• And clear principles on how to
publish data
122. What is a Linked Data application
• Again, no definition yet
• Linked Data is a term used to describe a recommended best
practice for exposing, sharing, and connecting pieces of data,
information, and knowledge on the Semantic Web using URIs and
RDF.
• So every element from the definition of SW application applies
123. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
130. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
131. Annotation-focused applications: key characteristics
• Available at all stages (pre-Semantic Web, SW1.0
and SW3.0), although predominantly in the early
ones
• Single (usually small) ontologies, many of them built
manually
• Centralised ontologies
• Instances stored in a centralised manner, together
with the ontologies, or in separate files/DBs
• Low heterogeneity and relatively small scale
• Homogeneous quality in data
138. Overview
• Coming to terms: The Web (1.0 and 2.0), the Semantic Web, the
Web of Linked Data and all its applications
• The Web (1.0 and 2.0)
• Web applications
• The Semantic Web (pre-SemanticWeb, SW1.0 and SW3.0)
• Semantic Web Applications Or [Semantic | Web]+ Applications
• The Web of Linked Data
• Linked Data Applications
• Semantic-based Applications
• preSemanticWeb Applications
• Annotation
• Semantic Web 1.0 Applications
• Annotation, Data Integration and Decision Support Systems
• Semantic Web 3.0 Applications
• (Collaborative) Annotation and Data Integration
• Conclusions and Trends
139. Data integration applications: key characteristics
• Available at later stages (SW1.0 and SW3.0).
• Still single (usually small) ontologies, many of them
built manually
• Although sometimes mappings between local and global
ontologies
• Still centralised ontologies
• Instances live in distributed DBs, with a focus on run-
time queries, although also data warehousing
approach
• Medium heterogeneity and medium scale
• Heterogeneous quality in data
141. IGN Catalogue Integration: Exploitation of Mappings
Cated.
Query: NGN
NC ¿Edif. Religioso
de Soria?
Construcción Rel.
Soria
BCN200 BCN25
Cated.
Edif. Religioso
NS Nieves
Catedral
Cated. Response:
Ig. Sto. Ermita
Catedral Soria
Ig. Sto. Tomás
Catedral Soria Soria
Ermita N.S. Nieves
Soria Catedral Soria
143. Alignments between ontologies and the DB
Land Fishing Biological Fisheries Vessel types Gear
areas areas entities commodities and size types
R2O R2O R2O R2O R2O R2O
Document Document Document Document Document Document
FAO
FIGIS DB
http://www.fao.org/aims/aos/fi/