Introduction to the Semantic Web

Kjetil Kjernsmo <kjetil@kjernsmo.net>.

NUUG Meeting, 2011-01-11.

http://www.nuug.no/pub/dist/20110111-semantic-web/

Creative Commons Attribution-Sharealike 3.0 Norway License.

History

Motivations

Connolly's Bane

The bane of my existence is doing things that I know the computer could do for me.

If the Web page with your personal calendar says you'll be in New York next Thursday, and the page with your workgroup calendar says you'll be in London all week, shouldn't the computer be able to warn you about the conflict? And shouldn't it go ahead and ask you if it's OK to cancel your flight to London and purchase this other ticket to New York?

Dan Connolly, 1998

Motivations

Simple use cases

Motivations

Distinguishing features

  • Economy of arbitrary combination.
  • The value of links.
  • ...and a dash of reasoning.

Where are we?

1996 of the Web

  • Lots of data.
  • Some mature standards, others in the works.
  • Big players coming on board. Governments (UK, Norway, US, etc), Yahoo, IBM, BestBuy, etc.)
  • Large deployment (e.g. Sindice, Garlik).
  • Tool support is somewhat lacking.
  • More developer training needed.

Available data

Open Data vs Linked Open Data

Available on the web (whatever format), but with an open licence
★★ Available as machine-readable structured data (e.g. excel instead of image scan of a table)
★★★ as (2) plus non-proprietary format (e.g. CSV instead of excel)
★★★★ All the above plus, Use open standards from W3C (RDF and SPARQL) to identify things, so that people can point at your stuff
★★★★★ All the above, plus: Link your data to other people's data to provide context

Tim Berners-Lee

Resource Description Framework (RDF)

404 Building not found
  1. From two documents to a triple.
    • Subject - Predicate - Object
  2. Add semantics to the link.
  3. Generalize the URI to identify anything.
  4. The object can be a string (with language or datatype).

Example

Turtle syntax:

<http://www.kjetil.kjernsmo.net/foaf#me> a foaf:Person ;
    foaf:name "Kjetil Kjernsmo" ;
    rel:parentOf <http://synne.kjernsmo.net/foaf#me> .

<http://synne.kjernsmo.net/foaf#me> a foaf:Person ;
    foaf:givenName "Synne" ;
    bio:event [ bio:date "2008-11-25"^^xsd:date ;
                a bio:Birth ] .

Describing and organizing your world

Continuum of technologies for building ontologies.

Ontology Spectrum

Originally from AAAI 1999- Ontologies Panel by Gruninger, Lehmann, McGuinness, Uschold, Welty; – updated by McGuinness.

Simple Knowledge Organization System (SKOS)

  • "Anything goes"-modelling
  • Defines broader and narrower relations (taxonomy)
  • Transitive and non-transitive relations
  • cross-links is built-in but any extension is accomodated for.
  • ABC Startsiden's catalog available as SKOS under CC license.

SKOS Example

@base <http://synne.kjernsmo.net/world1> . 
<> dc:title 
     "The world according to Synne, aged 1,
       as recorded by her parents"@en ;
     foaf:maker <http://synne.kjernsmo.net/foaf#me> .

<#vovv> a skos:Concept ;
     skos:prefLabel "Vovv-vovv" ;
     skos:narrower <#fur> . 

<#fur> a skos:Concept ;
     skos:prefLabel "Fur"@en ;
     owl:sameAs <http://dbpedia.org/resource/Category:Fur> .

Web Ontology Language (OWL)

@base <http://synne.kjernsmo.net/world2> . 
<> dc:title 
     "The world according to Synne, as recorded 
       by her parents, take two"@en ;
     foaf:maker <http://synne.kjernsmo.net/foaf#me> .

<#gakk> a owl:Class
     rdfs:label "Gakk-gakk" ;
     owl:unionOf <#badeand>, <#real-duck> .

<#badeand> a owl:Class ;
     rdfs:label "Badeand"@no .

OWL continued

<#real-duck> a owl:Class ;
     rdfs:label "Ender, gjess, svaner"@no ;
     rdfs:label "Duck, geese, swans"@en ;
     owl:sameAs <http://dbpedia.org/resource/Anatidae>

<#vovv> a owl:Class ;
     rdfs:label "Vovv-vovv" ;
     owl:disjointWith <#gakk> .

<#tux> a <#vovv> ;
     rdfs:label  "Tux, the Linux penguin"@en ;
     foaf:page <http://en.wikipedia.org/wiki/Tux> .

Build your world

Don't let anyone force their ontology on you!

But...

Economy makes it wise to adopt when you can

Unexpected reuse makes it wise to map when you can

SPARQL

A query language for the Semantic Web

Hides complexity

SELECT ?childname WHERE {
  ?parent a foaf:Person ;           
          rel:parentOf ?child .
  ?child  foaf:givenName ?childname .
}
DESCRIBE ?child WHERE {
  ?parent a foaf:Person ;           
          rel:parentOf ?child .
}

Real, big SPARQL example


PREFIX geo: <http://www.geonames.org/ontology#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mo: <http://purl.org/ontology/mo/>

SELECT ?name ?homepage ?place ?population 
WHERE
{ ?artisturi a mo:MusicArtist ; 
     foaf:based_near ?placeuri ; 
     foaf:name ?name .
  OPTIONAL { ?artisturi foaf:homepage ?homepage . }
  ?placeuri 
     geo:name ?place ; 
     geo:inCountry <http://www.geonames.org/countries/#NO> .
  OPTIONAL {?placeuri geo:population ?population .   }
} 
ORDER BY ?population

RDF classes in Object Oriented Programming

High object-relational impedance mismatch

Schema migration is usually painful

RDF and the Metaobject protocol is an interesting topic!

  • Chris Prather's Class::OWL - Class::MOP-based. Master thesis available!
  • Clark & Parsia's Empire

Bridging technologies

RDFa - embedding RDF in (X)HTML

  • A collection of attributes and processing rules for extending XHTML to support RDF
  • W3C Recommendation 14 October 2008
<div xmlns:dc="http://purl.org/dc/elements/1.1/">
   <h2 property="dc:title">The trouble with Bob</h2>
   <h3 property="dc:creator">Alice</h3>
   ...
</div>
  • RDFa 1.1 is needed
  • HTML5 may get a "microdata" syntax.

GoodRelations ontology


<div typeof="product:Product gr:ProductOrServicesSomeInstancesPlaceholder" about="http://products.semweb.bestbuy.com/y/products/9509686/#ProductOrServicesSomeInstancesPlaceholder_9509686">
  <span rel="rdfs:seeAlso" resource="http://www.bestbuy.com/site/olspage.jsp?skuId=9509686&type=product&id=1218116795548&cmp=RMX&ky=1whYTIhnZ0ydleik4tkW4Z7Fn1kPFrBgb"></span>
  <div id="proddetails">
    <h2 property="rdfs:label">Mac OS X v10.6 Snow Leopard: Mac</h2>


<div rel="gr:hasPriceSpecification" id="price">
  <h3>Reg. Price:</h3>
  <span typeof="gr:UnitPriceSpecification" about="http://products.semweb.bestbuy.com/y/products/9509686/#UnitPriceSpecification_9509686_1">
    $<span property="gr:hasCurrencyValue" datatype="xsd:float">29.99</span>
    <span property="gr:hasCurrency" datatype="xsd:string">USD</span>
    <span property="gr:priceType" content="SRP" datatype="xsd:string"></span>
    <span property="gr:hasUnitOfMeasurement" datatype="xsd:string" content="C62"></span>
    
    <span property="gr:valueAddedTaxIncluded" datatype="xsd:boolean" content="true"></span>
  </span>
</div>

Further Semantic Web standards

Also WebID ("OpenID done right").

Practical shortcomings

  • Lack of complete stack
  • Immaturity
  • Performance problems
  • RDF itself:
    • Ordered lists
    • Units of numbers
    • "who said that"
    • graph naming

Software you can try