Introduction to the Semantic Web

Principal Ideas

RDF describes resources

through URIs

RDF consists of "triples" of Information Subject:

Something

Predicate:

has some
relationship to
to

Object:

something else

The declarations can be mixed

label "creator" "creador" lang "es" label same as primary Author contributor subClass

An example

A work (unidentified) has

Visualising it:

the previous slide in pictures

To arrive at the Web as it was imagined

Information Management: A Proposal,

--Tim Berners-Lee, CERN, Marzo 1989

Resources linked to each other in useful ways

En Action

Foafnaut shows information as informations nodes with relations...

Una herramienta grafica para tratar RDF de tipo determinado

No structure?!

But it's XML, no?

Clearly:

<rdf:RDF 
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:foaf="http://xmlns.com/foaf/0.1/" >
   <foaf:Person>
      <foaf:mbox rdf:resource="mailto:charles@w3.org"/> 
      <foaf:givenname xml:lang="en">Charles</foaf:givenname>
   </foaf:Person>
</rdf:RDF>

What does that say?

A useful tool: the RDF validator

The "triples" (the declarations):

Subject Predicate Object
1 genid:ARP14847 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://xmlns.com/foaf/0.1/Person
2 genid:ARP14847 http://xmlns.com/foaf/0.1/mbox mailto:charles@w3.org
3 genid:ARP14847 http://xmlns.com/foaf/0.1/givenname "Charles"@en

genid:... What?!

"Blank nodes" aren't "identified" (named), just described.

something has the rdf type Person, the foaf mbox property charles@w3.org and the foaf given_name (in english) Charles

Let's make some RDF

For example, we can use

foaf-a-matic
It makes "FOAF" - an RDF vocabulary describing people
By Leigh Dodds
Hera
Create information in EARL about the accessibility of a Web Page
By Emmanuelle Gutiérrez and Carlos Benvidez

(Here is an example of foaf, and example of EARL, that I prepared eaerlier)

Looking at the results...

Mix the information

Introducing "cwm"

python cwm.py --rdf rdf-ejem.rdf rdf2-ejem.rdf

result: The information from the two files, mixed

Where did it get "rdf:Description"?

Cwm, n3 and rules

Usando otra forma de RDF llamada n3, cwm puede

N3 syntax is consistent and can represent RDF/XML accurately, but it is not XML

What is n3 like?

python cwm.py --rdf rdf-ejem.rdf rdf2-ejem.rdf --n3

(it is useful to make an instruction cwm instead of using python cwm.py...)

gives:

      [      a <http://xmlns.com/foaf/0.1/Person>;
             <http://xmlns.com/foaf/0.1/givenname> "Charles"@en;
             <http://xmlns.com/foaf/0.1/mbox> <mailto:charles@w3.org> ].
    
      [      a <http://xmlns.com/foaf/0.1/Person>;
             <http://xmlns.com/foaf/0.1/mbox> <mailto:charles@w3.org>;
             <http://xmlns.com/foaf/0.1/name> "Charles McCathieNevile"@fr ].

[ < a ; . @ ?!

The idea of n3 was to create something easier to read and write.

(Personally I prefer to use a tool for that :-)

The basic syntax: <url1> <url2> <url3> .

For two declarations:

<url1> <url2> <url3> . 
<url4> <url5> <url6> .

Shortcuts for syntax in N3

[ <predicado> <objeto> ]
Blank node - the subject is not identified
<x> a <y> .
<x> is a member of the class <y> - literally
<x> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <y> .
<x> <pred1> <obj1> ; <pred2> <obj2> .
abbreviation for
<x> <pred1> <obj1> .
<x> <pred2> <obj2> .
"texto"@es
The text is in the language specificed (here, spanish)

Rules --think, --filter, ...

Cwm allows some options in the instructions

filename
read it and process it
--n3
use n3 (for reading files, or producing output)
--rdf
use RDF/XML (you can swap back and forth several times in a line)
--think
apply rules, to draw conclusions
--purge
leave out "the rubbish" (anything of type "http://www.w3.org/2000/10/swap/log#Chaff")
--filter=filename
filter the results

A simple rule...

{ ?x a <http://xmlns.com/foaf/0.1/Person> ;
       <http://xmlns.com/foaf/0.1/mbox> ?direction ;
       <http://xmlns.com/foaf/0.1/name> ?nombre  .

  ?y a  <http://xmlns.com/foaf/0.1/Person> ; 
       <http://xmlns.com/foaf/0.1/mbox> ?direction ;
       <http://xmlns.com/foaf/0.1/givenname> ?apellido  .
} =>
{ ?x a <http://xmlns.com/foaf/0.1/Person> ;
       <http://xmlns.com/foaf/0.1/mbox> ?direction ;
       <http://xmlns.com/foaf/0.1/givenname> ?apellido ;
       <http://xmlns.com/foaf/0.1/name> ?nombre } .

...explained

If ?x is a Person, with a given value for mbox and for name,

and ?y is a Person with the same value for mbox and some value for givenname,

Then ?x has the same value for givenname

=>
abbreviation for <http://www.w3.org/2000/10/swap/log#implies>
?algo
use "algo" as a name of a variable (in n3 - there is no equivalent in RDF/XML yet)
{ <x> <y> <z> }
una expresión que se evalua para aplicar reglas (only in N3)

To apply it:

cwm --rdf rdf-ejem.rdf rdf2-ejem.rdf --n3 regla-ejem.n3 --think

The result includes all the information given (including the rule itself)

@prefix log: <http://www.w3.org/2000/10/swap/log#> .
How to declare a namespace prefix in n3
<x> <pred> <objUno> , <objDos> .
Abbreviation for
<x> <pred> <objUno> .
<x> <pred> <objDos> .

Filter the results

To only give the results we are interested in use

cwm --rdf rdf-ejem.rdf rdf2-ejem.rdf --n3 regla-ejem.n3 --think --filter=regla-ejem.n3

This only gives declarations corresponding to something implied by a rule in regla-ejem.n3

Note If you want to include other declarations, you have to include them as implications in the filter:

{  ?z a ical:Vcalendar } =>
{  ?z a ical:Vcalendar } .

Use the power...

The rules in evaluador.n3 include a blank node

{ [ a <http://xmlns.com/foaf/0.1/Person> ;
    <http://xmlns.com/foaf/0.1/mbox> ?direction ;
    ?relation ?objeto ] .

     ?y a earl:Assertor ; 
        earl:email ?direction } 

=> { ?y ?relation ?objeto } .

... to increase your knowledge

We can use the example FOAF and EAR files:

cwm --rdf earl-ejem.rdf foaf-ejem2.rdf --n3 > cwm-ejem.n3
cwm cwm-ejem.n3 evaluador.n3 --think --filter=evaluador.n3

To find all the declarations with the earl:Assertor as subject

More complex rules

{ ?ev a act:ActionItem ; dc:title ?title ;
    log:racine ?desde . ?desde dc:date ?fecha} =>
{ ?ev a ical:Vtodo ; ical:summary ?title ;
    ical:dtstart [ ical:dateTime ?fecha ]; 
     is ical:component of <foo> } .

Note Another syntax construction: <objeto> is <relacion> of <subjeto>

To continue with cwm?

More information about cwm

It is open source, developed collaboratively...

It also includes arithmetic functions expressed as RDF, and other interesting possiblities

RDF and vocabularies

Remember

Etc...

Defining vocabularies

Basic RDF:

Subject - Predicate - Object

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:exterms="http://www.example.org/terms/">

  <rdf:Description rdf:about="http://www.example.org/index.html">
      <exterms:creation-date>August 16, 1999</exterms:creation-date>
  </rdf:Description>

</rdf:RDF>

about, ID, nodeID

Three similar attributes to identify what is described

ID
Like ID in XML. Puede aparecer una vez en un documento, y se refiere de fuera

p.ej. <rdf:Description rdf:ID="aquí"> defines #aquí in the document (or its xml:base)

about
Describes the URIRef (it can be relative, such as "../#alli") that is its value.
It can appear repeatedly.

eg. <rdf:Description rdf:about="http://www.example.com/#aquí">

nodeID
Identifies a blank node inside a document.
Like ID, but it can appear repeatedly.
Its value has no meaning as a reference outside a document.

Properties...

Properties are the relations

Each one has a URI - so we can decribe it in RDF

<rdf:Description rdf:about="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property">
  <rdfs:comment xml:lang="es">Una relation entre 2 cosas identificados (normalmente) por URIs</rdf:label>
</rdf:Description>

...and classes

A class is a type of resource.

For example, every RDF class is of type

http://www.w3.org/1999/02/22-rdf-syntax-ns#Class

(and possibly of other classes at the same time)

type and datatype (and xml:lang)

Different things, but similar

type
Se usa para decir que algo pertenece a una clase.
(Algo puede pertenecer a muchas clases a la vez)
datatype
Para dar mas information sobre cómo interepretar algo
Por example un texto de datatype gDate es una fecha
xml:lang
Para identificar el tipo de data de texto (objetos literales)

Literals, XMLLiteral, lists, etc

Literal
The object of a declaration can be plain text.
<foaf:Person><foaf:name>Charles</foaf:name></foaf:Person>
or <algo:Anónimo><dc:title rdf:value="Un titulo"/></algo:Anónimo>
XMLLiteral
It is possible to include XML as text without trying to interpret it as RDF
Lists
The object can also be a list of objects, defined like in LISP with first, rest, nil, ...

subClass - hierarchy in RDFS

A class can be a subclass of others

For example, we can say that "myclass" is a subclass of Class

implica que todo de tipo myclass es de tipo Class (pero no viceversa)

Hay también subProperty para propiedades

RDFS! And what else besides?

There are 6 specifications for RDF (including a primer and test cases), and 6 more for OWL...

RDFS is a common nickname for the RDF language for describing voccabularies

It includes the properties label and comment, which are useful to present a label in an interface, or describe it more meaningfully.

<rdf:Description rdf:about="http://www.w3.org/2000/01/rdf-schema#label">
  <rdfs:label xml:lang="no">Navn</rdfs:label>
  <rdfs:label xml:lang="es">Titulo</rdfs:label>
  <rdfs:comment xml:lang="es">Un titulo breve para un termino en un vocabulario RDF</rdfs:comment>
</rdf:Description>

There is also OWL...

An RDF vocabulary that can define a vocabulary more precisely

For example

Vocabularies

Build (use rdfs:label and rdfs:comment!) or "Borrow"?

Better to use something already made. But where to find it?