Cover page images (keys)

Tutorial on Semantic Web Technologies

Trento, Italy, on the 14th December, 2005

Ivan Herman, W3C

Tutorial on Semantic Web Technologies

Logo of the SWAP conference

Slides of the tutorial given in Trento, Italy, on the 14th of December, 2005, as part of the 2nd Italian Semantic Web Workshop on Semantic Web Applications and Perspectives (SWAP2005), held at the University of Trento on the 14-15-16 December, 2005.

These slides are in XHTML. A printable version in PDF is also available.

 

 

Introduction

Towards a Semantic Web

Towards a Semantic Web

However…

Example: Searching

Example: Automatic Assistant

Example: Data(base) Integration

Example: Digital Libraries

Example: Semantics of Web Services

What Is Needed?

What Is Needed (Technically)?

The Semantic Web is Not

This Course Will

 

Basic RDF

Problem Example for the Course

W3C Membership Evolution

Statements

Resource Description Framework

RDF is a Graph

A Simple RDF Example

A Simple RDF Graph with full URI-s
<rdf:Description rdf:about="http://.../membership.svg#FullSlide>
    <axsvg:graphicsType>Chart</axsvg:graphicsType>
    <axsvg:labelledBy rdf:resource="http://...#BottomLegend/>
    <axsvg:chartType>Line</axsvg:chartType>
</rdf:Description>

URI-s Play a Fundamental Role

URI-s: Merging

What Merge Can Do...

Basic
Link to me Scott's nodes linked from me link to RDF from basic Link to graphs from RDF Link to Graph vis from graphs link to overview paper nodes from graph vis connect the paper to me, scott, and guy

RDF/XML Principles

A Simple RDF Graph with without full URIs and namespaces
«Element for #FullSlide»
  «Element for labelledBy»
      «Element for #BottomLegend»
  «/Element for labelledBy»
«/Element for #FullSlide»
«Element for #FullSlide»
  «Element for graphicsType»
      Chart
  «/Element for graphicsType»
«/Element for #FullSlide»

RDF/XML Principles (cont)

A Simple RDF Graph with one single predicate
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about="#FullSlide">
       «Element for labelledBy»
           <rdf:Description rdf:about="#BottomLegend"/>
       «/Element for labelledBy»
    </rdf:Description>
<rdf:RDF>

RDF/XML Principles (cont)

A Simple RDF Graph without full URI-s
<rdf:RDF
  xmlns:axsvg="http://svg.example.org#"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about="#FullSlide">
       <axsvg:labelledBy>
           <rdf:Description rdf:about="#BottomLegend"/>
       </axsvg:labelledBy>
    </rdf:Description>
<rdf:RDF>

Several Properties on the Same Node

A Simple RDF Graph with namespaces on predicates
<rdf:Description rdf:about="#FullSlide">
   <axsvg:labelledBy>
       <rdf:Description rdf:about="#BottomLegend"/>
   </axsvg:labelledBy>
</rdf:Description>
<rdf:Description rdf:about="#FullSlide">
   <axsvg:graphicsType>
       Chart
   </axsvg:graphicsType>
</rdf:Description>

Several property on the same node

A Simple RDF Graph with namespaces on predicates
<rdf:Description rdf:about="#FullSlide">
   <axsvg:labelledBy>
       <rdf:Description rdf:about="#BottomLegend"/>
   </axsvg:labelledBy>
   <axsvg:graphicsType>
       Chart
   </axsvg:graphicsType>
</rdf:Description>

Adding a New property

A Simple RDF Graph with showing the chaining of resources
<rdf:Description rdf:about="#FullSlide">
   <axsvg:labelledBy>
      <rdf:Description rdf:about="#BottomLegend"/>
   </axsvg:labelledBy>
</rdf:Description>
<rdf:Description rdf:about="#BottomLegend">
   <axsvg:isAnchor>True</axsvg:isAnchor>
</rdf:Description>

Adding a New property

A Simple RDF Graph with showing the chaining of resources
<rdf:Description rdf:about="#FullSlide">
  <axsvg:labelledBy>
    <rdf:Description rdf:about="#BottomLegend">
      <axsvg:isAnchor>True</axsvg:isAnchor>
    </rdf:Description>
  </axsvg:labelledBy>
</rdf:Description>

A Very Useful Simplification

<property>
  <rdf:Description rdf:about="URI"/>
</property>
<property rdf:resource="URI"/>

Simplification in Our Example

A Simple RDF Graph without full URI-s
<rdf:Description rdf:about="#FullSlide">
  <axsvg:labelledBy rdf:resource="#BottomLegend"/>
</rdf:Description>

RDF in Programming Practice

Python Example

In Python syntax:

 # import the libraries
 from rdflib.Graph import Graph
 from rdflib.URIRef import URIRef
 # resource for a specific URI:
 subject = URIRef("URI_of_Subject")
 # create the graph
 # (or "triple store, model, ...)
 graph = Graph()
 # parse an RDF file and store it in the graph
 graph.parse("membership.rdf")
 # do something with (p,o) pairs
 for (p,o) in graph.predicate_objects(subject) :
 	  do_something(p,o) 

Use of RDF in Our Example

The tool:

  1. Uses an RDF parser to extract metadata
  2. Resolves the URI-s in RDF to access the SVG elements
  3. Extracts information for the output
    • e.g., text element content, hyperlink data, descriptions
  4. Combines this with a general text
  5. Produces a (formatted) text for each RDF statement

Merge in Practice

Adding New Statements

Blank Nodes

A graph with a blank node in the middle (labelled with '?')

Blank Nodes: Turn Them Into Regulars

<rdf:Description rdf:about="#FullSlide">
   <axsvg:isA>
       <rdf:Description rdf:about="#Thing"/>
   </axsvg:isA>
</rdf:Description>
<rdf:Description rdf:ID="Thing">
   <axsvg:consistsOf rdf:resource="#Axes"/>
   <axsvg:consistsOf rdf:resource="#Legend"/>
   <axsvg:consistsOf rdf:resource="#Datalines"/>
</rdf:Description>

Blank Nodes: Blank Node Identifiers

<rdf:Description rdf:about="#FullSlide">
   <axsvg:isA>
       <rdf:Description rdf:nodeID="A234"/>
   </axsvg:isA>
</rdf:Description>
<rdf:Description rdf:nodeID="A234">
   <axsvg:consistsOf rdf:resource="#Axes"/>
</rdf:Description>

Blank Nodes: Let the System Do It

<rdf:Description rdf:about="#FullSlide">
  <axsvg:isA>
      <rdf:Description>
          <axsvg:consistsOf rdf:resource="#Axes"/>
      </rdf:Description>
  </axsvg:isA>
</rdf:Description>
A graph with a blank node in the middle

Blank Nodes: Some More Remarks

<rdf:Description rdf:about="#FullSlide">
    <axsvg:isA rdf:parseType="resource">
        <axsvg:consistsOf rdf:resource="#Axes"/>
    </axsvg:isA>
</rdf:Description>

 

RDF Vocabulary Description Language

(a.k.a. RDFS)

Need for RDF Schemas

Classes, Resources, …

Classes, Resources, … (cont.)

Classes, Resources in RDF(S)

A slide showing the Fullslide (in appl. space) with its own Schema and the RDFS entitites, all merged

Schema Example in RDF/XML

<rdf:Description rdf:ID="SVGEntity">
  <rdf:type rdf:resource=
    "http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Description>
<rdf:Description rdf:about="#Datalines">
   <rdf:type rdf:resource="axsvg-schema.rdf#SVGEntity"/>
</rdf:Description>

An Aside: Typed Nodes in RDF/XML

<rdf:Description rdf:about="http://...">
    <rdf:type rdf:resource="http://..../something#ClassName>
    ...
</rdf:Description>
<yourNameSpace:ClassName rdf:about="http://...">
    ...
</yourNameSpace:ClassName>

Schema Example in RDF/XML (alt.)

<rdfs:Class rdf:ID="SVGEntity">
   ...
</rdfs:Class>
<rdf:RDF xmlns:axsvg="axsvg-schema.rdf#"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
  <axsvg:SVGEntity rdf:about="#Datalines">
      ... 
  </axsvg:SVGEntity>

Typed Nodes (cont)

Inferred Properties

A slide showing an inferred property

Inference: Let Us Be Formal…

If:
  uuu rdfs:subClassOf xxx .
  vvv rdf:type uuu .
Then add:
  vvv rdf:type xxx .

Properties (Predicates)

Properties (cont.)

Property Specification Example

A slide showing the Fullslide (in appl. space) with its own Schema and the RDFS entitites, all merged

Property Specification in XML

Same example in XML/RDF:

<rdfs:Property rdf:ID="chartType">
  <rdf:domain rdf:resource="#SVGEntity"/>
  <rdf:range rdf:resource="http://...#Literal"/>
</rdfs:Property>

Literals

RDFS Literals

Literals in RDF/XML

<rdf:Description rdf:about="#Datalines">
   <axsvg:isAnchor
    rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">
         false
   </axsvg:isAnchor>
</rdf:Description/>

Literals in RDF/XML (cont.)

<rdf:Description rdf:about="#Path">
   <axsvg:algorithmUsed rdf:parseType="Literal"
        <math xmlns="...">
          <apply>
            <laplacian/>
            <ci>f</ci>
          </apply>
        </math>
   </axsvg:algorithmUsed>
</rdf:Description/>

 

Some Predefined Classes (Collections, Containers)

Predefined Classes

Collections (Lists)

Collections (Lists) (cont.)

Example for RDF Lists

The Same in RDF/XML

<rdf:Description rdf:about="#FullSlide">
    <axsvg:consistsOf rdf:parseType="Collection">
        <rdf:Description rdf:about="#Axes"/>
        <rdf:Description rdf:about="#Legend"/>
        <rdf:Description rdf:about="#Datalines"/>
    </axsvg:consistsOf>
</rdf:Description>

Our Graphical Shorthand

<rdf:Description rdf:about="#FullSlide">
    <axsvg:consistsOf rdf:parseType="Collection">
        <rdf:Description rdf:about="#Axes"/>
        <rdf:Description rdf:about="#Legend"/>
        <rdf:Description rdf:about="#Datalines"/>
    </axsvg:consistsOf>
</rdf:Description>
Example for RDF Lists, our own abbreviated form

Sequences

A graph with a blank node in the middle with three _x predicate and a type to a Seq

Sequences (in RDF/XML)

<rdf:Description rdf:about="#FullSlide">
  <axsvg:consistsOf>
      <rdf:Description>
          <rdf:type rdf:resource="http:...rdf-syntax-ns#Seq>
          <rdf:_1 rdf:resource="#Axes>
          ...
      </rdf:Description>
  </axsvg:consistsOf >
</rdf:Description/>

Sequences (in simplified RDF/XML)

<rdf:Description rdf:about="#FullSlide">
    <axsvg:consistsOf>
        <rdf:Seq>
            <rdf:li rdf:resource="#Axes>
            ...
        </rdf:Seq>
    </axsvg:consistsOf >
</rdf:Description/>

Other Containers

Some Words of Warning

 

RDF(S) in Practice

Small Practical Issues

Binding RDF to an XML Resource

<svg ...>
  ...
  <metadata>
    <rdf:RDF xmlns:rdf="http://../rdf-syntax-ns#">
      ...
    </rdf:RDF>
  </metadata>
    ...
</svg>

RDF/XML with XHTML

RDF Can Also Be Generated

Formalizing the Scraper Approach: GRDDL

<html xmlns="http://www.w3.org/1999/">
  <head profile="http://www.w3.org/2003/g/data-view">
    <title>Some Document</title>
    <link rel="transformation" href=
       href="http://…/dc-extract.xsl" />
    <meta name="DC.Subject" content="Some subject"/>      
    ...
  </head>
  ...
</html>
<rdf:Description rdf:about="">
  <dc:subject>Some subject</dc:subject>
</rdf:Description>

GRDDL (cont)

Another Future Solution: XHTML2

<span property="dc:date">March 23, 2004</span>
<span property="dc:title">Rollers hit casino for £1.3m</span>
  By <span property="dc:creator">Steve Bird</span> …	
<rdf:Description rdf:about="">
  <dc:date>March 23, 2004</dc:date>
  <dc:title>Rollers hit casino for £1.3m</dc:title>
  <dc:creator>Steve Bird</dc:creator>
</rdf:Description>

RDF/XML has its Problems

Example for Another Serialization

@prefix axsvg: <http://svg.example.org#>.
@prefix : <http://this.file.uri>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
:FullSlide 
    axsvg:labelledBy :bottomLegend;
    axsvg:isA [
        axsvg:consistsOf :Axes, :Legend, :Datalines.
    ].
:bottomLegend axsvg:isAnchor "True"^^xsd:boolean.

 

RDF Data Access, a.k.a. Query (SPARQL)

Querying RDF Graphs/Depositories

# do something with (p,o) pairs
for (p,o) in graph.predicate_objects(subject) :
 	 do_something(p,o) 

Analyse the Python Example

# do something with (p,o) pairs
for (p,o) in graph.predicate_objects(subject) :
 	 do_something(p,o) 
A slide showing the simple RDFLib pattern as graph pattern

General: Graph Patterns

Our Python Example in SPARQL

SELECT ?p ?o
WHERE {subject ?p ?o}
A slide showing the simple RDFLib pattern as graph pattern

Simple SPARQL Example

SELECT ?cat ?val #note: not ?x!
WHERE { ?x rdf:value ?val. ?x category ?cat }
A simple RDF Graph, with some matching patterns highlighted

Pattern Constraints

SELECT ?cat ?val
WHERE { ?x rdf:value ?val. ?x category ?cat. FILTER(?val>=200). }
An RDF Graph showing some of the matching graphs in highlights (of the code above)

More Complex Example

SELECT ?cat ?val ?uri
WHERE { ?x rdf:value ?val. ?x category ?cat.
        ?al contains ?x.  ?al linkTo ?uri }
An RDF Graph showing some of the matching graphs in highlights (of the code above)

Optional Pattern

SELECT ?cat ?val ?uri
WHERE    { ?x rdf:value ?val. ?x category ?cat. 
           OPTIONAL ?al contains ?x. ?al linkTo ?uri }
An RDF Graph showing some of the matching graphs in highlights (of the code above)

Other SPARQL Features

SPARQL Usage in Practice

Remote Query Example

GET /qps?query-lang=http…&graph-id=http://my.example/3.rdf
    &query=SELECT+:…+WHERE:+…:HTTP/1.1
User-Agent: my-sparql-client/0.0
Host: my.example
                
200 OK HTTP/1.1
Server: my-sparql-server/0.0
Content-Type: application/xml
                
<?xml version="1.0" encoding="UTF-8"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#>
  <head>
    <variable name="a/>
    ...
  </head>
  <results>
    <result ordered="false" distinct="false">
      <binding name="a"><uri>http:…</uri></binding>
      ...
    </result>
    <result> ... </result>
  </results>
</sparql>

 

Programming Practice

Programming Practice

   # import the libraries
   from rdflib.Graph import Graph
   from rdflib.URIRef import URIRef
   # resource for a specific URI:
   subject = URIRef("URI_of_Subject")
   # create the graph
   graph = Graph()
   # parse an RDF file and store it in the triple store
   graph.parse("membership.rdf")
   # do something with (p,o) pairs
   for (p,o) in graph.predicate_objects(subject) :
    	  do_something(p,o) 

Programming Practice (cont)

   # add a triple to the triple store
   graph.add((subject,pred,object))
   # remove it
   graph.remove_triples((subject,pred,object))
   # save it in a file in RDF/XML
   graph.serialize("filename.rdf")

Programming Practice (cont.)

from rdflib.sparql import SPARQLGraph, GraphPattern
p = GraphPattern([("?x",RDF.type,"?val"),("?x",category,"?cat")])
select = ("?cat","?val")
sparqlGraph = SPARQLGraph(graph)
results = sparqlGraph.query(select,p)

Another example: Jena

   // create a model (a.k.a. Graph in python)
  Model model=new ModelMem();
  Resource subject=model.createResource("URI_of_Subject")
  // 'in' refers to the input file
  model.read(new InputStreamReader(in));
  StmtIterator iter=model.listStatements(subject,null,null);
  while(iter.hasNext()) { 
     st = iter.next();
     p = st.getProperty();
     o = st.getObject();
     do_something(p,o);
  }

Jena (cont)

Lots of Other tools

 

Ontologies (OWL)

Ontologies

Ontologies (cont.)

“defines the concepts and relationships used to describe and represent an area of knowledge”

W3C’s Ontology Language (OWL)

It was a long road…

Why “OWL” and not “WOL”?

The drawing of Winnie the Pooh and OWL

 

Classes in OWL

OWL Resource and Thing

Need for Enumeration

Simplified version for property specification

(OWL) Classes can be Enumerated

Showing owl:oneOf with chart types

Same in RDF/XML

<rdf:Property rdf:ID="chartType">
   <rdf:range>
       <owl:Class>
           <owl:oneOf rdf:parseType="Collection">
               <owl:Thing rdf:ID="Bar"/>
               <owl:Thing rdf:ID="Pie"/>
               <owl:Thing rdf:ID="Radar"/>
           </owl:oneOf>
       </owl:Class>
   </rdf:range>
</rdf:Property>

Union of Classes

Showing unionOf with animation

Same in RDF/XML

<owl:Class rdf:ID="AnimationEntity">
   <owl:unionOf rdf:parseType="Collection">
       <owl:Class rdf:about="#animate"/>
       <owl:Class rdf:about="#animateMotion"/>
       <owl:Class rdf:about="#animateColor"/>
   </owl:unionOf>
</owl:Class>

Property Restrictions

Property Restrictions in OWL

Property Restriction Example

Restriction example, using allValuesFrom

Restrictions Formally

Same in RDF/XML

<owl:Class rdf:ID="Delphin">
    <rdfs:subClassOf rdf:resorce="#Mammal"/>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty rdf:resource="#livingIn"/>
        <owl:allValuesFrom rdf:resource="#UnionOfSeaAnAmazonas">
      </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

allValuesFrom could be replaced by:

Cardinality Constraint in RDF/XML

<owl:Class rdf:ID="SVGFigure">
    . . .
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onProperty rdf:resource="#shape"/>
        <owl:cardinality rdf:datatype=".../nonNegativeInteger">
          1
        </owl:cardinality>
      </owl:Restriction>
    </rdfs:subClassOf>
    . . .
</owl:Class>

Property Characterization

The top level OWL property definitions

Characterization Example

Restriction example, using cardinality

Same in RDF/XML

<owl:ObjectProperty rdf:ID="ChartType">
   <rdf:type rdf:resource="...../#FunctionalProperty"/>
</owl:ObjectProperty>

OWL: Additional Requirements

Term Equivalence/Relations

Example: Connecting to Italian

Example of equivalence between English and Italian terms

Another Use of Equivalence

<owl:Class rdf:ID="SVGFigure_Chart">
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:about="#chartType"/>
            <owl:cardinality
                rdf:dataype="...#nonNegativeInteger">
                1
            </owl:cardinality>
        </owl:Restriction>
    </owl:equivalentClass>
</owl:Class>

Versioning, Annotation

OWL and Logic

However: Ontologies are Hard!

OWL Full

Example for a Possible Problem (in OWL Full)

<owl:Class rdf:ID="A">
  <owl:equivalentClass>
    <owl:Restriction>
      <owl:onProperty rdf:resource=".../22-rdf-syntax-ns#type"/>
      <owl:allValueFrom rdf:about="#B"/>
    </owl:Restriction>					
  </owl:equivalentClass>				
</owl:Class>
<owl:class rdf:ID="B">
  <owl:complementOf rdf:parseType="Collection">
    <owl:Class rdf:about="#A"/>
  </owl:complementOf>
</owl:class>
<owl:Thing rdf:ID="C">
  <rdf:type rdf:resource="#A"/>
</owl:Thing>

OWL Description Logic (DL)

Goal: maximal subset of OWL Full against which current research can assure that a decidable reasoning procedure is realizable

OWL Lite

Note on OWL layers

“Description Logic”

“Description Logic” (cont.)

OWL-DL “Abstract Syntax”

Class(animate)
Class(animateMotion)
Class(animationEntity) { complete 
  unionOf(animate animateMotion …)
)

Ontology Developement

Ontology Examples

 

Simple Knowledge Organisation System (SKOS)

Simple Knowledge Organisation System

Example: Entries in a Glossary (1)

“Assertion”
“(i) Any expression which is claimed to be true. (ii) The act of claiming something to be true.”
“Class”
“A general concept, category or classification. Something used primarily to classify or categorize other things.”
“Resource”
“(i) An entity; anything in the universe. (ii) As a class name: the class of everything; the most inclusive category possible.”

(from the RDF Semantics Glossary)

Example: Entries in a Glossary (2)

A slide for a simple SKOS glossary

Example: Entries in a Glossary (3)

A slide for a simple SKOS glossary

Example: Taxonomy (1)

Illustrates “broader” and “narrower”

General
  • Travelling
  • Politics
SemWeb
  • RDF
    • OWL

(From MortenF’s weblog categories. Note that the categorization is arbitrary!)

Example: Taxonomy (2)

A slide for a simple SKOS taxonomy

Example: Thesaurus (1)

Term
Economic cooperation
Used For
Economic co-operation
Broader terms
Economic policy
Narrower terms
Economic integration, European economic cooperation, …
Related terms
Interdependence
Scope Note
Includes cooperative measures in banking, trade, …

(from UK Archival Thesaurus)

Example: Thesaurus (2)

A slide for a simple SKOS thesaurus

SKOS Core Overview

Why Having SKOS and OWL?

SKOS Documents

“Core” Vocabularies

 

What is Coming?

Semantic Web Activity “Phase 2”

Rules

W3C’s Rules Workshop

Rules Interchange Format Working Group

RIF Phase 1 Goals

RIF Phase 2 Goals

Lots of Theoretical Questions to Solve

The traditional layercake model of SW The two tower lternative for the SW architecture (with Rules and Ontologies side by side)

Beyond Rules: Trust

A Number of Other Issues…

 

Available Documents, Tools

Available Specifications: Primers, Guides

Available Specifications (cont)

Available Specifications (cont)

Some Books

Further Information

SWBP Working Group Documents

Further Information (cont)

Public Fora at W3C

Semantic Web Interest Group
a forum for discussions on applications
RDF Logic
public (archived) mailing list for technical discussions

Some Tools

(Graphical) Editors
Further info on RDF/OWL tools at:
SemWebCentral (see also previous links…)
Programming environments
We have already seen some;
but Jena 2 and SWI-Prolog do OWL reasoning, too!

Some Tools (Cont.)

Validators
For RDF: W3C RDF Validator; For OWL-DL: WonderWeb, Pellet (can also be downloaded as a reasoner tool)
Reasoners that can be built into an application
Pellet, KAON2
Ontology converter (to OWL)
at the Mindswap project
Relational Database to RDF/OWL converter
D2R Map
Schema/Ontology/RDF Data registries
e.g., SchemaWeb, SemWeb Central, Ontaria, rdfdata.org,
Metadata Search Engine
Swoogle

Oracle's Spatial RDF Data Model

Oracle's announcement drawing

 

IBM – Life Sciences and Semantic Web

IBM screen dump

 

 

Some Application Examples

SW Applications

Data integration

MuseoSuomi Application dump

Portals

Vodaphone screen dump

 

OKAR Fujitsu's and Ricoh's OKAR

Okar structural image

Adobe's XMP

XMP Application dump

Improved Search via Ontology: GoPubMed

GoPubMed Application dump

Creative Commons

CC logos

 

Baby CareLink

XMP Application dump

Further Information

These slides are at:
http://www.w3.org/2005/Talks/1214-Trento-IH/
Semantic Web homepage
http://www.w3.org/2001/sw/
More information about W3C:
http://www.w3.org/ or http://www.w3c.it/
Mail me:
ivan@w3.org