SlideShare una empresa de Scribd logo
1 de 100
Descargar para leer sin conexión
Contesto e intro
                           Christian Morbidoni
                          morbidoni@spaziodati.eu




                         smart data now.
giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
Open Information vs Open Data          smart data now.




                         Data



                  Data          Data




                                       2

giovedì 29 marzo 12
I dati hanno meno valore
                           quando sono isolati




                      smart data now.
giovedì 29 marzo 12
Web of Documents                                 smart data now.




                                    Hyperlinks


                  For humans



                 For machines
                                X




                                                 4

giovedì 29 marzo 12
Web of Data                                                                                       smart data now.




                                                                                     Hyperlinks


                      For humans


                                               related-to author-of same-as located-in
                                                same as     agrees    cites   explains
                  For machines
                                   works-for
                                      cites                                         Semantic Links

                                       RDF Data       RDF Data     RDF Data      RDF Data




                                                                                                  5

giovedì 29 marzo 12
Buzzword: Global Data Space       smart data now.




                                                    6

giovedì 29 marzo 12
Buzzword: Global Data Space       smart data now.




             Institutions




                                                          6

giovedì 29 marzo 12
Buzzword: Global Data Space                   smart data now.




                                                          Companies
             Institutions




                                                                      6

giovedì 29 marzo 12
Buzzword: Global Data Space                   smart data now.




                                                          Companies
             Institutions




                                                               Geo-spatial
                                                                services




                                                                      6

giovedì 29 marzo 12
Buzzword: Global Data Space                   smart data now.




                                                           Companies
             Institutions




                                                                Geo-spatial
                                                                 services




                 Libraries




                                                                       6

giovedì 29 marzo 12
Buzzword: Global Data Space                   smart data now.




                                                           Companies
             Institutions




                                                                Geo-spatial
                                                                 services




                 Libraries




                               Citizens




                                                                       6

giovedì 29 marzo 12
Buzzword: Global Data Space                   smart data now.




                                                           Companies
             Institutions




                                                                Geo-spatial
                                                                 services




                 Libraries




                               Citizens




                                                                       6

giovedì 29 marzo 12
Pubblicare Linked Data
                             sul Web
                             Christian Morbidoni
                            morbidoni@spaziodati.eu




                           smart data now.
giovedì 29 marzo 12
Che cos’è Linked Data                                                     smart data now.




    • Una serie di “best practices” per pubblicare dati
      strutturati e interconnessi sul Web
    • 4 Principi base:
          • Use URIs as names for things.
          • Use HTTP URIs, so that people can look up those names.
          • When someone looks up a URI, provide useful information,
            using the standards (RDF, SPARQL).
          • Include links to other URIs, so that they can discover more
            things.


    • L’idea è usare la stessa infrastruttura del Web (of
      documents) per costruire il Web of Data


                                                                          8

giovedì 29 marzo 12
Dereferenciable URLs                                                          smart data now.




    • Best practice: evitare l’uso di URN e “non HTTP” URLs
          • LD si basa su un unico protocollo (HTTP) per la risoluzione delle risorse
    • I dati “parlano” di entità del mondo reale, non solo di risorse web
          • Information resource: un documento che “descrive” o “rappresenta” una
            risorsa
          • Non-information resource: una entità del mondo reale, non-digitale
    • Esempio:
          • Mario Monti è una real-world resource (non-information resource)
          • http://it.wikipedia.org/wiki/Mario_Monti è uno dei possibili documenti che
            descrivono la risorsa (information resource)


                                                                              9

giovedì 29 marzo 12
Dereferenciable URLs                                                                      smart data now.




    • Documenti e real-world resources devono avere URL diverse
          • Non devono essere confuse tra loro
          • Più rappresentazioni digitali della stessa real-world resources devono essere possibili
                 • HTML per gli umani
                 • RDF per i software “semantici”
                 • Plain XML, JSON, TXT, etc. per i software “non semantici” ?

    • Content negotiation
          • RFC 2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html
          • Meccanismo standard HTTP per fornire diverse rappresentazioni della stessa risorsa in
            risposta a diverse richieste
    • Due strategie possibili (http://www.w3.org/TR/cooluris/)
          • 303 redirect
          • Hash URLs

                                                                                         10

giovedì 29 marzo 12
303 redirect + content negotiation smart data now.




                                  11

giovedì 29 marzo 12
303 redirect + content negotiation                                                                               smart data now.




                      GET /id/alice HTTP/1.1
                      Host: example.com
                      Accept: text/html;q=0.5, application/rdf+xml


                                                    1
                                                                                   2



                                                            HTTP/1.1 303 See Other
                                                            Location: http://example.com/data/alice


                                               Client                                                  Server



                                                        GET /data/alice HTTP/1.1
     HTTP/1.1 200 OK
                                                        Host: example.com
     Content-Type: application/rdf+xml
                                                        Accept: text/html;q=0.5, application/rdf+xml
     <http://www.example.com/id/alice>
         a foaf:Person;
         foaf:name "Alice";
                                                                                       3
         foaf:mbox <mailto:alice@example.com>;
         ...                                        4




                                                                                                                12

giovedì 29 marzo 12
303 redirect to generic doc        smart data now.




                                  13

giovedì 29 marzo 12
303 redirect to generic doc                     smart data now.




                           Variane da usare solo nel
                           caso i due documenti siano
                           equivalenti dal punto di vista
                           del contenuto. (http://
                           www.w3.org/TR/cooluris)
                           Scarsa utilità pratica (?)




                                               13

giovedì 29 marzo 12
Alternative (?):
    “plain” content negotiation
                                                                                        smart data now.



                                    GET /id/alice HTTP/1.1
                                    Host: example.com
                                    Accept: text/html;q=0.5, application/rdf+xml


                                                                 1




                                                        Client                     Server


            HTTP/1.1 200 OK
            Content-Location: http://example.com/data/alice
            Content-Type: application/rdf+xml
                                                                 2
            <http://www.example.com/id/alice>
                a foaf:Person;
                foaf:name "Alice";
                foaf:mbox <mailto:alice@example.com>;
                ...



    • Blog post e discussione (2010): http://blog.iandavis.com/2010/11/07/a-guide-to-
      publishing-linked-data-without-redirects/
    • Non possibile se le URI provengono da diversi host
    • 303 redirect è lo standard “de facto”, ma questo approccio è condiviso da molti
    • C’è una lunga discussione in corso su questo argomento...it’s up to you :-)
                                                                                   14

giovedì 29 marzo 12
Hash URLs                                                                 smart data now.




    • L’URL fragment (#...) è ignorato dal browser, che richiede l’intero documento
    • La URL http://example.com/about#alice non è direttamente dereferenziabile e
      può essere utilizzata per indicare la non-information resource

                                                                         15

giovedì 29 marzo 12
Hash URLs                                                                                 smart data now.




                  Client requests URL: http://example.com/about#alice



                                          GET /about HTTP/1.1
                                          Host: example.com
                                          Accept: text/html;q=0.5, application/rdf+xml


                                                                        1




                       Client skips unwanted info...         Client                       Server


              HTTP/1.1 200 OK
              Content-Type: application/rdf+xml

              <http://www.example.com/about#alice>                    2
                  a foaf:Person;
                  foaf:name "Alice";
                  foaf:mbox <mailto:alice@example.com>;
                  ...
              <http://www.example.com/about#bob>
                  a foaf:Person;
                  foaf:name "Bob";
                  foaf:mbox <mailto:bob@example.com>;
                  ...




                                                                                         16

giovedì 29 marzo 12
Pros e Cons                                                                                                    smart data now.




    • Hash URL
          • Contro: Richiede il dowload dell’intero documento (che potenzialmente descrive N risorse)
          • Pro: Non richiede redirects
    • 303 redirect
          • Contro: richiede più passaggi e una opportuna configurazione del web server
          • Pro: E’ più flessibile. Permette di scaricare una descrizione alla volta, o più descrizioni assieme. Permette di
            cambiare la policy in seguito.

    • Best practice:
          • 303 redirect per risorse in un (potenzialmente) largo dataset
          • Hash URLs per i vocabolari/ontologie
          • Se possibile mettere a disposizione anche uno SPARQL endpoint


    • Soluzione ibrida ()
          • http://example.com/id/alice#this > Non-Information Resource
          • http://example.com/id/alice > Information Resource
                                                                                                              17

giovedì 29 marzo 12
Links                                                                                        http://dbpedia.org
                                                                                                                         smart data now.




                          http://dati.piemonte.it

                      …..
                      <http://dati.piemonte.it/id/Torino>
                                                                                                   http://geonames.org
                         skos:exactMatch <http://dbpedia.org/resource/Turin> .
                      …..
                      <http://dati.piemonte.it/id/Torino>
                         owl:sameAs <http://sws.geonames.org/3165524> .
                      ….
                      <http://dati.piemonte.it/id/Mostra-123>
                         dc:subject <http://rdf.freebase.com/ns/en.impressionism> .
                      ….
                      <http://dati.piemonte.it/id/Torino>
                         rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> .
                      ….


                                                                                           http://freebase.com




                                               http://sw-portal.deri.org




giovedì 29 marzo 12
Links                                                                                            http://dbpedia.org
                                                                                                                             smart data now.




                              http://dati.piemonte.it

                          …..
                          <http://dati.piemonte.it/id/Torino>
                                                                                                       http://geonames.org
                             skos:exactMatch <http://dbpedia.org/resource/Turin> .

         Identity Links   …..
                          <http://dati.piemonte.it/id/Torino>
                             owl:sameAs <http://sws.geonames.org/3165524> .
                          ….
                          <http://dati.piemonte.it/id/Mostra-123>
                             dc:subject <http://rdf.freebase.com/ns/en.impressionism> .
                          ….
                          <http://dati.piemonte.it/id/Torino>
                             rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> .
                          ….


                                                                                               http://freebase.com




                                                   http://sw-portal.deri.org




giovedì 29 marzo 12
Links                                                                                            http://dbpedia.org
                                                                                                                             smart data now.




                              http://dati.piemonte.it

                          …..
                          <http://dati.piemonte.it/id/Torino>
                                                                                                       http://geonames.org
                             skos:exactMatch <http://dbpedia.org/resource/Turin> .

         Identity Links   …..
                          <http://dati.piemonte.it/id/Torino>
                             owl:sameAs <http://sws.geonames.org/3165524> .
                          ….
                          <http://dati.piemonte.it/id/Mostra-123>
Relationship Links        ….
                             dc:subject <http://rdf.freebase.com/ns/en.impressionism> .

                          <http://dati.piemonte.it/id/Torino>
                             rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> .
                          ….


                                                                                               http://freebase.com




                                                   http://sw-portal.deri.org




giovedì 29 marzo 12
Links                                                                                            http://dbpedia.org
                                                                                                                             smart data now.




                              http://dati.piemonte.it

                          …..
                          <http://dati.piemonte.it/id/Torino>
                                                                                                       http://geonames.org
                             skos:exactMatch <http://dbpedia.org/resource/Turin> .

         Identity Links   …..
                          <http://dati.piemonte.it/id/Torino>
                             owl:sameAs <http://sws.geonames.org/3165524> .
                          ….
                          <http://dati.piemonte.it/id/Mostra-123>
Relationship Links        ….
                             dc:subject <http://rdf.freebase.com/ns/en.impressionism> .

                          <http://dati.piemonte.it/id/Torino>
  Vocabulary Links        ….
                             rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> .



                                                                                               http://freebase.com




                                                   http://sw-portal.deri.org




giovedì 29 marzo 12
Descrivere un dataset                                                            smart data now.




    • Così come in RDF si descrivono le risorse (es. le città, le
      persone), è importante anche descrivere i dataset stessi
          • Fornisce informazioni importanti agli utenti dei dati
          • Consente ai motori di ricerca di indicizzare e scoprire più facilmente i dati


    • Standard de facto
          • VoID (Vocabulary of Interlinked Datasets)




                                                                                19

giovedì 29 marzo 12
VoID: example                                                                                      smart data now.


              @prefix   : <http://rdfs.org/ns/void#> .
              @prefix   dcterms: <http://purl.org/dc/terms/> .
              @prefix   foaf: <http://xmlns.com/foaf/0.1/> .
              @prefix   rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

            <#DS1>     a :Dataset;
                 dcterms:description "Geonames dataset";
                 dcterms:title "Geonames";
                 :exampleResource <http://sws.geonames.org/3172483/about.rdf>;
                 foaf:homepage <http://geonames.org> .

            <#myDS-DS1>     a :Linkset;
                 :linkPredicate <http://www.w3.org/2000/01/rdf-schema#seeAlso>;
                 :target <#DS1>,
                        <http://linkedopendata.it/datasets/grrp> .

            <http://linkedopendata.it/grrp>     a :Dataset;
                 dcterms:description "Accommodations in Piemonte. GoodRelations compliant.";
                 dcterms:license <http://creativecommons.org/licenses/by/2.0/>;
                 dcterms:publisher <http://linkedopendata.it>;
                 dcterms:source <dati.piemonte.it>;
                 dcterms:subject <http://dbpedia.org/resource/Piedmont>;
                 dcterms:title "Strutture ricettive Piemonte - GoodRelations";
                 :dataDump <http://dump.linkedopendata.it/grrp>;
                 :exampleResource <http://data.linkedopendata.it/grrp/resource/AFFITTACAMERE_ARCOBALENO_2>;
                 :sparqlEndpoint <http://sparql.linkedopendata.it/grrp>;
                 :subset <#myDS-DS1>;
                 :vocabulary <http://purl.org/goodrelations/v1#>,
                        <http://purl.org/net7/vocab/gracc/v1#>,
                        <http://www.w3.org/2006/vcard/ns#>;
                 foaf:homepage <http://linkedopendata.it/grrp> .


                                                                                                  20

giovedì 29 marzo 12
Discovery of VoID descriptions                                                                                              smart data now.




    • Come rendere “trovabile” la descrizione VoID di un dataset?
          • Back links
                 • Consentono di risalire alla descrizione del dataset a partire dai dati stessi (descrizione RDF delle
                   risorse)
                 • es. <http://dbpedia.org/data/Berlin> dcterms:isPartOf :DBpedia .
                 • La tripla deve essere inclusa nella descrizione RDF di ogni risorsa del dataset
          • Sitemap
                 • Sitemap è il modo standard per esporre le risorse ai web crawler
                 • Semantic Sitemap è una estensione per descrivere dataset linked
                 • Esiste un overlap tra VoID e Semantic Sitemaps, ma possono essere usati efficacemente assieme
                 • Workflow:
                      • Il client raggiunge il file robots.txt posizionato nella root (/) del dominio
                      • Il client cerca la riga che iniza per 'Sitemap :', che è seguita dalla URL del file sitemap.xml
                      • Se il file sitemap.xml sua l’estensione Semantic Sitemap, contiene l’elemento <sc:dataset> che a sua volta contiene
                        l’elemento <sc:datasetURI> come figlio. il suo valore è l’URL del dataset
                      • L’URL del dataset viene dereferenziata ottendendo la descrizione VoID del datset

                                                                                                                           21

giovedì 29 marzo 12
Semantic Sitemap: example                                                 smart data now.




     <?xml version="1.0" encoding="UTF-8"?>
      <urlset
        xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:sc="http://sw.deri.org/2007/07/sitemapextension/scschema.xsd">

       <sc:dataset>
         <sc:datasetLabel>Big Lynx People Data Set</sc:datasetLabel>
         <sc:datasetURI>http://biglynx.co.uk/datasets/people</sc:datasetURI>
         <sc:linkedDataPrefix>http://biglynx.co.uk/people/</sc:linkedDataPrefix>
         <sc:sampleURI>http://biglynx.co.uk/people/dave-smith</sc:sampleURI>
         <sc:sampleURI>http://biglynx.co.uk/people/matt-briggs</sc:sampleURI>
         <sc:sparqlEndpointLocation>http://biglynx.co.uk/sparql</
   sc:sparqlEndpointLocation>
         <sc:dataDumpLocation>http://biglynx.co.uk/dumps/people.rdf.gz</
   sc:dataDumpLocation>
         <changefreq>monthly</changefreq>
       </sc:dataset>
     </urlset>




                                                                         22

giovedì 29 marzo 12
License                                                                       smart data now.




    • Creative Commons definisce un vocabolario RDF per descrivere
      le licenze   ESEMPIO:
                            <http://creativecommons.org/licenses/by-sa/3.0/>
                              rdf:type cc:License ;
                              dc:title "Attribution-Share Alike 3.0 Unported" ;
                              dc:creator <http://creativecommons.org/> ;
                              cc:permits
                                cc:Distribution ,
                                cc:DerivativeWorks ,
                                cc:Reproduction ;
                                cc:requires
                                cc:ShareAlike ,
                                cc:Attribution ,
                                cc:Notice ;

    • E’ possibile specificare la licenza per ogni descrizione RDF
      aggiungendo una singola tripla
          • es. <http://example.org/id/alice> cc:license <http://creativecommons.org/
            licenses/by-sa/3.0/> .
                                                                             23

giovedì 29 marzo 12
Pattern architetturali                                                                smart data now.




                                      from: http://linkeddatabook.com/editions/1.0

    Criteri: 1) Tipologia di dati di partenza 2)Mole di dati 3)Frequanza di update dei dati

                                                                                     24

giovedì 29 marzo 12
File RDF statici                                                                    smart data now.




    • Best practice: usare Hash URLs
          • File: http://example.org/porjects/myproject.rdf
          • Entità progetto: http://example.org/porjects/myproject.rdf#project


    • Configurare il web server per servire il giusto MIME type, application/
      rdf+xml


    • Rendere l’RDF facilmente trovabile includendo un link nella pagina
      HTML corrispondente
          • <link rel="alternate" type="application/rdf+xml" href="project.rdf">


    • Alternativa: includere RDFa nelle pagine HTML
                                                                                   25

giovedì 29 marzo 12
Servire LD da un DB relazionale                        smart data now.




          • Esistono tool ad-hoc per questo compito
                • D2RQ è uno dei più usati

                                                      26

giovedì 29 marzo 12
Servire LD da un triplestore                                                               smart data now.




    • Non tutti i triple store hanno supporto buil-in per Linked Data


    • In questi casi occorre usare un layer aggiuntivo


    • Tool più utilizzati:
          • Pubby, http://www4.wiwiss.fu-berlin.de/pubby/
          • Linked Data API (http://code.google.com/p/linked-data-api/wiki/
            Specification) implementation
                 • ELDA, http://elda.googlecode.com/hg/deliver-elda/src/main/docs/index.html
                 • PUELIA, http://code.google.com/p/puelia-php/



                                                                                         27

giovedì 29 marzo 12
Resource Description
                           Framework
                      (e database relazionali)
                            Christian Morbidoni
                           morbidoni@spaziodati.eu




                          smart data now.
giovedì 29 marzo 12
Dati distribuiti                                                                       smart data now.




    • Il primo requirement di RDF è quello di supportare la descrizione di dati distribuiti sul
      Web
    • Supponendo di voler rappresentare i seguenti dati in forma tabulare...
      Come distribuirli sul Web?
             ID          Title                  Author                Medium   Year

             1           As you like it         Shakespeare           Play     1599

             2           Hamlet                 Shakespeare           Play     1604

             3           Othello                Shakespeare           Play     1603

             4           Sonnet 18              Shakespeare           Poem     1609

             5           Astrophil and Stella   Sir Phillip Sidney    Poem     1590

             6           Edward II              Christopher Marlowe   Play     1592

             7           Hero and Leander       Christopher Marlowe   Poem     1593

             8           Greensleeves           Henry VII Rex         Song     1525



                                                                                      29

giovedì 29 marzo 12
Dati distribuiti                                                                                              smart data now.



    • Un primo approccio potrebbe essere distribuire i dati riga per riga

                                                 ID           Title            Author        Medium      Year
                                                 1            As you like it   Shakespeare   Play        1599

                                      server 1
         ID           Title      Author      Medium         Year
         2            Hamlet     Shakespeare Play           1604
         3            Othello    Shakespeare Play           1603
                                                                               server 2
                                 ID      Title                     Author              Medium         Year
                                 6       Edward II                 Christopher Marlowe Play           1592
                                 7       Hero and Leander          Christopher Marlowe Poem           1593
                      server 3
    • Ogni serve mantiene un certo numero di risorse
          • Flessibilità: facile inserire una nuova risorsa
          • Rigidità: aggiungere un campo alla tabella richiede coordinazione tra tutti i server
          • I server devono essere coordinati in modo che i campi corrispondano
    • Requirement: serve un identificatore globale per ogni campo
                                                                                                             30

giovedì 29 marzo 12
Dati distribuiti                                                                                            smart data now.

    • Un secondo approccio: colonna per colonna

                                                     Author
                                                     Shakespeare
                                                     Shakespeare
                           server 1                  Shakespeare                                server 3
                      Title                          Shakespeare                           Medium   Year
                      As you like it                                                       Play     1599
                                                     Sir Phillip Sidney
                      Hamlet                                                               Play     1604
                                                     Christopher Marlowe
                                                                                           Play     1603
                      Othello                        Christopher Marlowe
                                                                                           Poem     1609
                      Sonnet 18                      Henry VII Rex
                                                                                           Poem     1590
                      Astrophil and Stella
                                                                                           Play     1592
                      Edward II
                                                                                           Poem     1593
                      Hero and Leander
                                                                                           Song     1525
                      Greensleeves
                                             server 2
    • Ogni server è responsabile per un “tipo” di dati
          • Flessibilità: è facile estendere il modello del DB (aggiungere campi)
          • Rigidità: inserire una nuova risorsa richiede la collaborazione di tutti i server

    • Requirement: serve un identificatore globale per ogni risorsa
                                                                                                           31

giovedì 29 marzo 12
Dati distribuiti                                                                                         smart data now.




    • Una combinazione dei due: cella per cella                                                 Title
                                                                                          1     As you like it
                                   Author
                         2         Shakespeare                                                Medium
             server 1                                                   server 3
                                                                                      4       Poem
                        Title
                3       Othello
                                                                       Year
                                                             2         1604
                                                server 2
    • Pro: Combina la flessibilità dei due approcci
          • ogni server può liberamente aggiungere risorse, campi e relativi valori
    • Requirement:
          • Servono identificatori globali sia per le risorse che per i “campi”
    • RDF si basa su questo approccio

                                                                                                        32
giovedì 29 marzo 12
Triple                                                           smart data now.




    • In questo modello l’unità atomica di dati è formata da tre valori:
          • identificatore della riga
          • nome del campo
          • valore corrispondente.


    • In RDF si chiama Tripla o Statement, ed è composto a:
          • Soggetto - una risorsa
          • Predicato - un tipo di relazione o proprietà
          • Oggetto - un valore o una risorsa




                                                                33

giovedì 29 marzo 12
Triple e tabelle                                                                         smart data now.




    • Dati tabellari:         ID       Title          Author      Medium      Year
                              1        As you like it Shakespeare Play        1599
                              2        Hamlet         Shakespeare Play        1604


    • Una tripla può essere vista come una tabella con tre campi.
             Subject                 Predicate                       Object
             1                       has title                       “As you like it”
             1                       has author                      Shakespere
             2                       has medium                      Play
             2                       has author                      Shakespere
    • oppure:

             Subject                 Predicate                       Object
             Shakespere              wrote                           As you like it
             As you like it          has medium                      Play
             Shakespere              wrote                           Hamlet
             Amlet                   year                            1604
                                                                                        34

giovedì 29 marzo 12
Triple e grafi                                                                   smart data now.




    • Un tripla può essere rappresentata anche così:

                              Shakespere       wrote                  Hamlet




    • Quando più triple si riferiscono alla stessa risorsa possono essere visualizzate
      come un grafo etichettato e direzionato (directed labeled graph):


                                           As you like it   has medium         Play
                                  wrote
                 Shakespere
                                  wrote
                                              Hamlet           year            1604




                                                                               35

giovedì 29 marzo 12
Graph merging                                                                                               smart data now.




    • Ogni pezzo di informazione sul Semantic Web è un grafo
    • Unire e aggregare informazioni è semplice ....
                                                      Hamlet           year               1604
                                           wrote
                      Shakespere
                                           wrote
                                                      Macbeth
                                                                       set in
                                                                                           Scotland
                                                                        part of

                                                        UK




                                            Macbeth       has medium                    Play

                                   wrote

                      Shakespere           lived in    Stratford it           is in              England
                                                                              part of
                                                           UK




                                                                                                           36

giovedì 29 marzo 12
Graph merging                                                                                         smart data now.




    • Unico requisito: un modo inequivocabile per stabilire quando due
      nodi in grafi diversi sono equivalenti
                                                       Hamlet            year             1604
                                      wrote
                  Shakespere
                                      wrote
                                                      Macbeth
                                                                         set in
                                                                                          Scotland
                      lived in                        has medium
                                                                                          part of


                                                          Play                            UK
                       Stratford it

                                              is in                             part of


                                                                   England




                                                                                                     37

giovedì 29 marzo 12
URI come identificatori globali                                     smart data now.




    • Un generalizzazione dell’approccio già usato sul Web
          • Le URL sono tipi particolari di URI


    • Due risorse sono uguali se hanno la stessa URI


    • Un Uniform Resource Identifier identifica una risorsa che può far
      parte di un grafo RDF
          • Non-unique Name Assumption: non è Unique è Uniform!
          • Una risorsa può avere più URI



                                                                  38

giovedì 29 marzo 12
URI: sintassi                                                                    smart data now.




    • Sintassi dipendente dallo schema

                               <scheme>:<scheme-specific-part>
    • Sintassi generica (usata da diversi schemi ma non obbligatoria)

                           <scheme>://<authority><path>?<query>
    • Schema (obbligatorio)
          • Determina la “semantica” dell’URI
          • Può indicare un meccanismo di risoluzione (http, ftp, etc.)

    • Authority
          • Indica una autorità per il naming (es. web domain)

    • Path
          • Identifica la risorsa all’interno dell’authority (es. a/b/c)

    • Query
          • Stringa interpretabile dalla risorsa stessa (es. ?user=christian)

                                                                                39

giovedì 29 marzo 12
URL e URN                                                                                     smart data now.




    • Tipi di URI:
          • Uniform Resource Locators (URLs)
                 • Specificano un protocollo per risolvere la risorsa

          • Uniform Resource Names (URNs)
                 • Sono dei nomi ma non hanno una rappresentazione digitale vera e propria

    • URL e risorse:
          • Una pagina Web: http://myHomePage.it/me.htm (URL)
          • Un libro: urn:isbn:1234-123443-1234343 (URN)
          • Un oggetto digitale: urn:doi:10.1000/182 (URN)
          • Una persona: mailto:christian.morbidoni@gmail.com (URL)


    • Generalizzazione: Internationalized Resource Identifier (IRI)
      Wikipedia: “is a generalization of the Uniform Resource Identifier (URI), which is in turn a
      generalization of the Uniform Resource Locator (URL). While URIs are limited to a subset of the
      ASCII character set, IRIs may contain characters from the Universal Character Set (Unicode/ISO
      10646), including Chinese or Japanese kanji, Korean, Cyrillic characters, and so forth.”


                                                                                             40

giovedì 29 marzo 12
Esempio di N-Triples                                                smart data now.




         <http://www.artchive.com/crucifixion.jpg>
         <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
         <http://www.icom.com/schema.rdf#Sculpture> .


         <http://www.ibiblio.org/wm/paint/auth/pippo/>
         <http://www.icom.com/schema.rdf#first_name> "Pippo"@en .


         <http://www.ibiblio.org/wm/paint/auth/pippo/>
         <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
         <http://www.icom.com/schema.rdf#Sculptor> .


         <http://www.ibiblio.org/wm/paint/auth/rodin/>
         <http://www.icom.com/schema.rdf#creates>
         <http://www.artchive.com/crucifixion.jpg> .


                                                                   41

giovedì 29 marzo 12
Turtle (superset di N-Triples)                                                            smart data now.




         # See slides for RDF talk
         #
         # http://www.w3.org/2000/Talks/0906-xmlweb-tbl/slide6-0.html
         #


         @prefix p: <http://www.example.org/personal_details#> .
         @prefix m: <http://www.example.org/meeting_organization#> .


         <http://www.example.org/people#fred>
         !            p:GivenName !    "Fred";
         !            p:hasEmail ! !   <mailto:fred@example.com>;
         !            m:attending !!   <http://meetings.example.com/cal#m1> .


         <http://meetings.example.com/cal#m1>
         !            m:homePage !     !         <http://meetings.example.com/m1/hp> .


                                                                                         42

giovedì 29 marzo 12
Stesso esempio in RDF/XML                                                       smart data now.




         <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:m="http://www.example.org/meeting_organization#"
             xmlns="http://www.example.org/people#"
             xmlns:p="http://www.example.org/personal_details#">


             <rdf:Description about="http://meetings.example.com/cal#m1">
                <m:homePage resource="http://meetings.example.com/m1/hp"/>
             </rdf:Description>


             <rdf:Description about="http://www.example.org/people#fred">
                <m:attending resource="http://meetings.example.com/cal#m1"/>
                <p:GivenName>Fred</p:GivenName>
                <p:hasEmail resource="mailto:fred@example.com"/>
             </rdf:Description>
         </rdf:RDF>
                                                                               43

giovedì 29 marzo 12
RDF/JSON                                                                                     smart data now.


    {
          "http://example.org/about" : {
              "http://purl.org/dc/elements/1.1/creator" :
             [ { "value" : "Anna Wilder", "type" : "literal" } ],
              "http://purl.org/dc/elements/1.1/title"  :
             [ { "value" : "Anna's Homepage", "type" : "literal", "lang" : "en" } ] ,
              "http://xmlns.com/foaf/0.1/maker"         :
             [ { "value" : "_:person", "type" : "bnode" } ]
          } ,
     
          "_:person" : {
              "http://xmlns.com/foaf/0.1/homepage"      :
             [ { "value" : "http://example.org/about", "type" : "uri" } ] ,
              "http://xmlns.com/foaf/0.1/made"          :
             [ { "value" : "http://example.org/about", "type" : "uri" } ] ,
              "http://xmlns.com/foaf/0.1/name"          :
             [ { "value" : "Anna Wilder", "type" : "literal" } ] ,
              "http://xmlns.com/foaf/0.1/firstName"     :
             [ { "value" : "Anna", "type" : "literal" } ] ,
              "http://xmlns.com/foaf/0.1/surname"       :
             [ { "value" : "Wilder", "type" : "literal" } ] ,
              "http://xmlns.com/foaf/0.1/depiction"     :
             [ { "value" : "http://example.org/pic.jpg", "type" : "uri" } ] ,
              "http://xmlns.com/foaf/0.1/nick"          : [
                                                            { "type" : "literal", "value" : "wildling"} ,
                                                            { "type" : "literal", "value" : "wilda" }
                                                          ] ,
              "http://xmlns.com/foaf/0.1/mbox_sha1sum"  :
             [ { "value" : "69e31bbcf58d432950127593e292a55975bc66fd", "type" : "literal" } ]
          }
    }
                                                                                            44

giovedì 29 marzo 12
RDFa: embedding RDF into web pages                                                                  smart data now.



                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
                          "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
                      <html xmlns="http://www.w3.org/1999/xhtml"
                          xmlns:foaf="http://xmlns.com/foaf/0.1/"
                          xmlns:dc="http://purl.org/dc/elements/1.1/"
                          version="XHTML+RDFa 1.0" xml:lang="en">
                        <head>
                          <title>John's Home Page</title>
                          <base href="http://example.org/john-d/" />
                          <meta property="dc:creator" content="Jonathan Doe" />
                          <link rel="foaf:primaryTopic" href="http://example.org/john-d/#me" />
                        </head>
                        <body about="http://example.org/john-d/#me">
                          <h1>John's Home Page</h1>
                          <p>My name is <span property="foaf:nick">John D</span> and I like
                            <a href="http://www.neubauten.org/" rel="foaf:interest"
                               xml:lang="de">Einstürzende Neubauten</a>.
                          </p>
                          <p>
                            My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite
                            book is the inspiring <span about="urn:ISBN:0752820907"><cite
                            property="dc:title">Weaving the Web</cite> by
                            <span property="dc:creator">Tim Berners-Lee</span></span>
                           </span>
                          </p>
                        </body>
                      </html>



                                                                                                   45

giovedì 29 marzo 12
Named Graphs                                                   smart data now.




    • L’idea alla base delle specifiche (http://www.w3.org/1999/02/22-
      rdf-syntax-ns#) è semplice:
          • Un set di triple RDF è un grafo
          • Ogni grafo è identificato esso stesso da una URI
    • Ampio supporto in SPARQL e nei triple-store


    • Da triple a quadruple (quad-store)
          • Soggetto - Predicato - Oggetto - Provenienza




                                                              46

giovedì 29 marzo 12
TriG                                                                                  smart data now.



    • Specifiche: http://www4.wiwiss.fu-berlin.de/bizer/TriG/#example
    • Esempio:        # TriG Example Document 1
                      # This document encodes three graphs.
                      @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
                      @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
                      @prefix swp: <http://www.w3.org/2004/03/trix/swp-1/> .
                      @prefix dc: <http://purl.org/dc/elements/1.1/> .
                      @prefix ex: <http://www.example.org/vocabulary#> .
                      @prefix : <http://www.example.org/exampleDocument#> .
                      :G1 { :Monica ex:name "Monica Murphy" .
                            :Monica ex:homepage <http://www.monicamurphy.org> .
                            :Monica ex:email <mailto:monica@monicamurphy.org> .
                            :Monica ex:hasSkill ex:Management }

                      :G2 { :Monica rdf:type ex:Person .
                            :Monica ex:hasSkill ex:Programming }

                      :G3 { :G1 swp:assertedBy _:w1 .
                            _:w1 swp:authority :Chris .
                            _:w1 dc:date "2003-10-02"^^xsd:date .
                            :G2 swp:quotedBy _:w2 .
                            :G3 swp:assertedBy _:w2 .
                            _:w2 dc:date "2003-09-03"^^xsd:date .
                            _:w2 swp:authority :Chris .
                            :Chris rdf:type ex:Person .
                            :Chris ex:email <mailto:chris@bizer.de> }



                                                                                     47

giovedì 29 marzo 12
RDF and tabular data: assignment                                                                         smart data now.

                                                              Products
        ID            Model             Division               Product Line     Manufacture Location   Available

        1             zx-3              Manufactoring support Paper machine     Sacramento             23

        2             zx-3P             Manufactoring support Paper machine     Sacramento             4

        3             B-1430            Control Engineering    Active sensor    Hong Kong              100

        4             DBB-12            Safety                 Safety Valve     Cleveland              34



    • Assignment: esprimere i dati in forma di RDF
            • Osservazioni:
                 • Ogni riga identifica una risorsa diversa: servono identificatori per le risorse
                 • Ogni colonna esprime una proprietà di una risorsa: servono identificatori per le proprietà
                 • Il nome della tabella esprime una categoria di oggetti: i prodotti
                 • Namespace: possiamo scegliere un namespace unico per il DB:
                   http://manufactoringX.com/products/ (prefisso mfx:)
                 • Consiglio: usare la sintassi N3

                                                                                                       48

giovedì 29 marzo 12
RDB to RDF mapping                                                                                smart data now.




    • Specifiche W3C:
          • Direct Mapping: http://www.w3.org/TR/rdb-direct-mapping/
                 • Definisce un metodo “standard” per mappare tabelle relazionali in triple RDF
                      • La struttura dell’RDF riflette esattamente quella del DB
                      • Il vocabolario RDF riflette esattamente le tabelle del DB

          • Mapping language: R2RML: http://www.w3.org/TR/r2rml/
                 • Un linguaggio per specificare un mapping “custom” da un particolare DB
                      • Consente di scegliere un vocabolario RDF qualsiasi
                      • Produce un RDF più “usabile”



    • Tools:
          • D2RQ, http://d2rq.org/ - open-source
          • Triplify, http://triplify.org - open-source
          • Virtuoso, http://virtuoso.openlinksw.com/ - open-source + commercial
          • .....
                                                                                                 49

giovedì 29 marzo 12
Direct Mapping: example        smart data now.




                              50

giovedì 29 marzo 12
R2RML: example         smart data now.




                      51

giovedì 29 marzo 12
R2RML: example             smart data now.




                      ?


                          51

giovedì 29 marzo 12
R2RML: example         smart data now.




                      52

giovedì 29 marzo 12
D2RQ everview                         smart data now.



                      Architecture




                                     53

giovedì 29 marzo 12
D2RQ: example mapping        smart data now.




                            54

giovedì 29 marzo 12
RDF Schema
                      (...alcune osservazioni)
                             Christian Morbidoni
                            morbidoni@spaziodati.eu




                          smart data now.
giovedì 29 marzo 12
RDFS Vocabulary        smart data now.




                      56

giovedì 29 marzo 12
RDF, RDFS, Vocabulary        smart data now.




                            57

giovedì 29 marzo 12
RDFS Entailments        smart data now.




                       58

giovedì 29 marzo 12
Inference and data integration                                                                                            smart data now.




    • L’inferenza gioca un ruolo importante nell’integrazione tra grafi
    • In alcuni casi le URI non bastano...
    • Esempio: come unire in modo consistente i seguenti grafi?
                               Graph 1                                                    Graph 2

                                   ex1:Car                                              ex2:Motorcicle


                        rdf:type                 rdf:type                          rdf:type               rdf:type

                                      rdf:type                                                 rdf:type
                                                                                                                     ex2:Shadow
              ex1:FiatPunto                                 ex1:Fiat500   ex2:RX


                                      ex1:FiatBravo
                                                                                                ex2:Monster




                                                                                                                         59

giovedì 29 marzo 12
Inference and data integration                                                                                                                smart data now.




    • Utilizzando semplicemente rdfs:subClassOf possiamo creare un
      modello di integrazione
                                                                         Integration model

                                                                             myns:Veicle



                              Graph 1              rdfs:SubClassOf                         rdfs:SubClassOf     Graph 2

                                  ex1:Car                                                                    ex2:Motorcicle


                       rdf:type                 rdf:type                                                rdf:type               rdf:type

                                     rdf:type                                                                       rdf:type
                                                                                                                                          ex2:Shadow
             ex1:FiatPunto                                 ex1:Fiat500                         ex2:RX


                                     ex1:FiatBravo
                                                                                                                     ex2:Monster




                                                                                                                                             60

giovedì 29 marzo 12
Inference and data integration                                                                                                          smart data now.




    • Il modello integrato presenta gli individui in modo omogeneo:
                                                                 Integrated model

                                                                           myns:Veicle
                                                rdf:type                                                rdf:type
                      ex1:FiatPunto                                                                                       ex2:Shadow
                                                     rdf:type                                       rdf:type


                                                                rdf:type                 rdf:type
                                ex1:FiatBravo                                                                      ex2:Monster




                                                  ex1:Fiat500                                        ex2:RX




    • L’inferenza può sembrare molto banale ...
    • .. ma spesso semplici connessioni logiche sono in grado di rendere le
      applicazioni sensibilmente più smart
          • “A little semantics goes a long way” :-)
                                                                                                                                       61

giovedì 29 marzo 12
Type propagation
    (rdfs:subClassOf)                                                                     smart data now.




    • Se RDF modella triple e grafi ...
    • RDF Schema modella insiemi (sets)
          • Un insieme è definito come una risorsa di tipo rdfs:Class
          • Il costrutto per indicare un sotto-set è rdfs:subClassOf
                 • E’ anche il più abusato (come extends in Java :-) )


    • Pattern: type propagation
                                :AllStartPlayer rdf:type rdfs:Class
                                :MajorLeaguePlayer rdf:type rdfs:Class

                                :AllStartPlayer rdfs:subClassOf :MajorLeaguePlayer

                                :Keneda rdf:type :AllStartPlayer .


                                INFERRED TRIPLES:

                                :Keneda rdf:type :MajorLeaguePlayer
                                                                                     62

giovedì 29 marzo 12
Relationship propagation
    (rdfs:subPropertyOf)                                                                   smart data now.




    • In alcuni casi è utili parlare non solo delle classi (insiemi di istanze) ma anche
      delle proprietà (relazioni) che intercorrono tra le risorse
    • rdfs:subPropertyOf
                                            :freeLancesTo rdfs:subPropertyOf :contractsTo .
          • funzionamento analogo           :indirectlyContractsTo
                                            rdfs:subPropertyOf :contractsTo .
            a rdfs:subClassOf               :isEmployedBy rdfs:subPropertyOf :worksFor .
                                            :contractsTo rdfs:subPropertyOf :worksFor .
          • IF ?p rdfs:subPropertyOf ?q
                                            :Goldman :isEmployedBy :TheFirm .
            AND ?x ?p ?y                    :Spence :freeLancesTo :TheFirm .
            THEN ?x ?q ?y                   :Long :indirectlyContractsTo :TheFirm .

                                            INFERRED TRIPLES:

                                            :Goldman :worksFor :theFirm
                                            :Spencer :contractsTo :theFirm
                                            :Long :contractsTo :theFirm
    • Nota: Non ha un analogo
                                            SECOND STEP:
      nei lingugaggi di
                                            :Spence :worksFor :theFirm
      programmazione                        :Long :worksFor :theFirm




                                                                                      63

giovedì 29 marzo 12
rdfs:domain e rdfs:range                                                             smart data now.




    • Un altro modo di parlare di una proprietà è quello di indicare come essa dovrebbe
      essere usata nel contesto
          • Ovvero: quali tipi di risorse unisce
    • I concetti di dominio (domain) e codominio (range) vengono presi dalla matematica
    • Regole di inferenza:
                                                   :contractsTo
          • IF ?p rdfs:range ?a                          a       owl:ObjectProperty ;
            AND ?x ?p ?y                                 rdfs:domain :Person ;
            THEN ?y rdf:type ?a                    :Spencer :contractsTo :theFirm
          • IF ?p rdfs:domain ?a
                                                   INFERRED TRIPLE:
            AND ?x ?p ?y
                                                   :Spencer rdf:type Person
            THEN ?x rdf:type ?a


    • Nota: doamin e range non possono generare dati invalidi o inconsistenze
    • L’approccio è quello di rendere sempre consistente il grafo applicando le regole di
      inferenza

                                                                                    64

giovedì 29 marzo 12
Pattern
    rdfs:domain, rdfs:range + rdfs:subClassOf                                         smart data now.




                                            :ITEmployee
                                                             :Daniel :developed :Talia


                                                             Inferred triples:
                                           rdfs:subClassOf

                                                             :Daniel rdf:type :Developer
                                                             :Daniel rdf:type :ITEmployee
               :developed    rdfs:domain     :Developer




    • I pratica possiamo definire un’altra regola di inferenza:
          • IF ?p rdfs:domain ?a
            AND ?a rdfs:subClassOf ?b
            THEN ?p rdfs:domain ?b
    • L’inferenza agisce in modo “inaspettato”: dal semplice uso di una proprietà
      posso dedurre la sua appartenenza a una gerarchia di classi ...


                                                                                 65

giovedì 29 marzo 12
domain e range: errori comuni                                                    smart data now.




    • L’utilizzo e il significato di rdfs:domain e rdfs:range in RDFS crea
      spesso confusione
          • Soprattutto a chi è abituato a pensare “Object Oriented”
            (e chi non lo è ?!)
    • Una comune associazione tra OOP e RDFS:
          • rdfs:Class >> OOP Class
          • rdfs:domain A >> dichiarazione di una variabile nella classe A
          • Visione rafforzata da alcuni tool per la visualizzazione di RDF (es. Protege)
    • Ma non è proprio così ....



                                                                                66

giovedì 29 marzo 12
OOP vs. Semantic Web                                                                   smart data now.




                                OOP                      Semantic Web
                      Class A
                                                  :foo     rdfs:domain      :ClassA
                      public static Object Foo;



                                                                         rdfs:subClassOf


                      Class B extends A

                      Foo;                        :foo     rdfs:domain      :ClassB




    • In OOP l’inheritance consente alle sottoclassi di ereditarele variabili
    • ! In RDFS le super-classi ricevono associazioni con le risorse dalle sottoclassi !




                                                                                      67

giovedì 29 marzo 12
Consistency check?                                                       smart data now.




    • ! In RDFS non esiste il concetto di consistency/validity check !


    • AAA
          • Anybody can say Anything about Anything


    • Open World Assumption
          • Non posso dedurre nuova conoscenza dalla mancanza di informazioni


    • Es. se in un dataset RDF non esiste la tripla “:Pluto rdf:type :Dog”
          • Non posso dedurre NOT(:Pluto rdf:type :Dog)

                                                                        68

giovedì 29 marzo 12
Consistency check?                                        smart data now.




                      :Christian rdf:type :Person .
                      :hasPrice rdfs:domain :Product .
                      :Christian :hasPrice “49.99 €” .




                                                         69

giovedì 29 marzo 12
Consistency check?                                                   smart data now.




                              :Christian rdf:type :Person .
                              :hasPrice rdfs:domain :Product .
                              :Christian :hasPrice “49.99 €” .



                      ! I dati sono validi per un reasoner RDFS !




                                                                    69

giovedì 29 marzo 12
Consistency check?                                                   smart data now.




                              :Christian rdf:type :Person .
                              :hasPrice rdfs:domain :Product .
                              :Christian :hasPrice “49.99 €” .



                      ! I dati sono validi per un reasoner RDFS !



                                ! Un reasoner deduce ...


                                :Christian rdf:type :Product .




                                                                    69

giovedì 29 marzo 12
Interrogare dati RDF:
                            SPARQL
                            Christian Morbidoni
                           morbidoni@spaziodati.eu




                           smart data now.
giovedì 29 marzo 12
Querying RDF                                                                       smart data now.




    • SPARQL
           • Specifiche: http://www.w3.org/TR/rdf-sparql-query/
           • RDF Query language standard W3C
           • Basato sul predecessore RDQL
           • Tutorial:
             http://www.cambridgesemantics.com/2008/09/sparql-by-example
           • SQL-like syntax
       Esempio:
       ! PREFIX dc: <http://purl.org/dc/elements/1.1/>
       !     !        SELECT ?title
       !     !        WHERE
       !     !        !     { <http://example.org/book/book1> dc:title ?title }

    • SeRQL
           • Precedente RDF Query Language sviluppato da Aduna (Sesame)
           • Funzionalità equiparabili a SPARQL
                                                                                  71

giovedì 29 marzo 12
SPARQL tutorial                                                         smart data now.




    • Alcuni esempi di query nelle seguenti slides....



    • Tuttavia esiste un ottimo tutorial online a cui fare riferimento:
          • http://www.cambridgesemantics.com/2008/09/sparql-by-example/




                                                                       72

giovedì 29 marzo 12
SPARQL                                                       smart data now.




    • PREFIX
          • Dichiarazione dei namespace
    • SELECT
          • Identifica le variabile di ritorno della query
    • FROM
          • Il nome del grafo su cui eseguire la query
          • SPARQL supporta i Named Graphs
    • WHERE
          • “Query Pattern”



                                                            73

giovedì 29 marzo 12
RDF example            smart data now.




                      74

giovedì 29 marzo 12
SPARQL query example (1)        smart data now.




                               75

giovedì 29 marzo 12
SPARQL query example (2)        smart data now.




                               76

giovedì 29 marzo 12
SPARQL query example (3)        smart data now.




                               77

giovedì 29 marzo 12
SPARQL query example (4)        smart data now.




                               78

giovedì 29 marzo 12
SPARQL query example (5)        smart data now.




                               79

giovedì 29 marzo 12
SPARQL query example (6)        smart data now.




                               80

giovedì 29 marzo 12
Biblio e Links                                                                                                                                                         smart data now.




    •    RDF Primer, http://www.w3.org/TR/rdf-primer/

    •    RDFa Primer, http://www.w3.org/TR/xhtml-rdfa-primer/

    •    RDF/JSON specification, http://docs.api.talis.com/platform-api/output-types/rdf-json

    •    Tom Heath, Christian Bizer, Linked Data: Evolving the Web into a Global Data Space, http://linkeddatabook.com

    •    Tim Berners Lee, Linked Data design issues, http://www.w3.org/DesignIssues/LinkedData.html

    •    Dereferencing HTTP URIs, http://www.w3.org/2001/tag/doc/httpRange-14/2007-05-31/HttpRange-14

    •    Leo Sauermann and Richard Cyganiak. Cool uris for the semantic web, http://www.w3.org/TR/cooluris/

    •    Dean Allemang, Jim Handler, Semantic Web for the Working Ontologiest, http://workingontologist.org/

    •    A Direct Mapping of Relational Data to RDF, http://www.w3.org/TR/rdb-direct-mapping/

    •    R2RML: RDB to RDF Mapping Language, http://www.w3.org/TR/r2rml/

    •    D2RQ, http://d2rq.org/

    •    A Comparison of RDB-to-RDF Mapping Languages, http://www.ifi.uzh.ch/pax/uploads/pdf/publication/1830/paper.pdf

    •    SPARQL 1.0, http://www.w3.org/TR/rdf-sparql-query/

    •    SPARQL 1.1, http://www.w3.org/TR/sparql11-query/

    •    SPARQL by examples (Tutorial), http://www.cambridgesemantics.com/2008/09/sparql-by-example

    •    RFC 2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html

    •    Harry Halpin, Patrick J. Haye, When owl:sameAs isn’t the Same: An Analysis of Identity Links on the Semantic Web, http://events.linkeddata.org/ldow2010/papers/
         ldow2010_paper09.pdf

    •    HTML/ChangeProposal25, http://www.w3.org/wiki/HTML/ChangeProposal25

    •    Semantic Sitemap specs, http://sw.deri.org/2007/07/sitemapextension/

    •    Guide to VoID (Vocabulary of Interlinked Datasets), http://vocab.deri.ie/void/guide


                                                                                                                                                                    81

giovedì 29 marzo 12

Más contenido relacionado

Más de SpazioDati

Dandelion API e Atoka: due strumenti utili al Data Journalism
Dandelion API e Atoka: due strumenti utili al Data JournalismDandelion API e Atoka: due strumenti utili al Data Journalism
Dandelion API e Atoka: due strumenti utili al Data JournalismSpazioDati
 
Data Curation @ SpazioDati - NEXA Lunch Seminar
Data Curation @ SpazioDati - NEXA Lunch SeminarData Curation @ SpazioDati - NEXA Lunch Seminar
Data Curation @ SpazioDati - NEXA Lunch SeminarSpazioDati
 
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meeting
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meetingSpazioDati presents Dandelion dataTXT - SenTaClAus project - final meeting
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meetingSpazioDati
 
SpazioDati presents dataTXT - SenTaClAus project - final meeting
SpazioDati presents dataTXT - SenTaClAus project - final meetingSpazioDati presents dataTXT - SenTaClAus project - final meeting
SpazioDati presents dataTXT - SenTaClAus project - final meetingSpazioDati
 
Opening “Big Data Challenge” data: some insights on our role in the story
Opening “Big Data Challenge” data: some insights on our role in the storyOpening “Big Data Challenge” data: some insights on our role in the story
Opening “Big Data Challenge” data: some insights on our role in the storySpazioDati
 
News Fact-checking: One Practical Application of Linked Statistics
News Fact-checking: One Practical Application of Linked StatisticsNews Fact-checking: One Practical Application of Linked Statistics
News Fact-checking: One Practical Application of Linked StatisticsSpazioDati
 
ISWC 2014 - Dandelion: from raw data to dataGEMs for developers
ISWC 2014 - Dandelion: from raw data to dataGEMs for developersISWC 2014 - Dandelion: from raw data to dataGEMs for developers
ISWC 2014 - Dandelion: from raw data to dataGEMs for developersSpazioDati
 
SpazioDati presents dataTXT - SenTaClAus project - 2nd open day
SpazioDati presents dataTXT - SenTaClAus project - 2nd open daySpazioDati presents dataTXT - SenTaClAus project - 2nd open day
SpazioDati presents dataTXT - SenTaClAus project - 2nd open daySpazioDati
 
Text analytics for Google Spreadsheets using Text Mining add-on
Text analytics for Google Spreadsheets using Text Mining add-on Text analytics for Google Spreadsheets using Text Mining add-on
Text analytics for Google Spreadsheets using Text Mining add-on SpazioDati
 
Find the specific Wikipedia page you’re looking for, using Wikisearch API
Find the specific Wikipedia page you’re looking for, using Wikisearch APIFind the specific Wikipedia page you’re looking for, using Wikisearch API
Find the specific Wikipedia page you’re looking for, using Wikisearch APISpazioDati
 
Using entity extraction extension with OpenRefine and Dandelion API
Using entity extraction extension with OpenRefine and Dandelion APIUsing entity extraction extension with OpenRefine and Dandelion API
Using entity extraction extension with OpenRefine and Dandelion APISpazioDati
 
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENT
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENTDandelion API and mobile payment: food for thoughts for H-ACK PAYMENT
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENTSpazioDati
 
Cerved Group scommette sull'analisi semantica made in Italy
Cerved Group scommette sull'analisi semantica made in ItalyCerved Group scommette sull'analisi semantica made in Italy
Cerved Group scommette sull'analisi semantica made in ItalySpazioDati
 
LinkedStat: making ISTAT data more valuable
LinkedStat: making ISTAT data more valuableLinkedStat: making ISTAT data more valuable
LinkedStat: making ISTAT data more valuableSpazioDati
 
Smart Open Data Kickoff - Madrid - Linked
Smart Open Data Kickoff - Madrid - Linked Smart Open Data Kickoff - Madrid - Linked
Smart Open Data Kickoff - Madrid - Linked SpazioDati
 
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013SpazioDati
 
Introducing JSONpedia
Introducing JSONpediaIntroducing JSONpedia
Introducing JSONpediaSpazioDati
 

Más de SpazioDati (17)

Dandelion API e Atoka: due strumenti utili al Data Journalism
Dandelion API e Atoka: due strumenti utili al Data JournalismDandelion API e Atoka: due strumenti utili al Data Journalism
Dandelion API e Atoka: due strumenti utili al Data Journalism
 
Data Curation @ SpazioDati - NEXA Lunch Seminar
Data Curation @ SpazioDati - NEXA Lunch SeminarData Curation @ SpazioDati - NEXA Lunch Seminar
Data Curation @ SpazioDati - NEXA Lunch Seminar
 
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meeting
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meetingSpazioDati presents Dandelion dataTXT - SenTaClAus project - final meeting
SpazioDati presents Dandelion dataTXT - SenTaClAus project - final meeting
 
SpazioDati presents dataTXT - SenTaClAus project - final meeting
SpazioDati presents dataTXT - SenTaClAus project - final meetingSpazioDati presents dataTXT - SenTaClAus project - final meeting
SpazioDati presents dataTXT - SenTaClAus project - final meeting
 
Opening “Big Data Challenge” data: some insights on our role in the story
Opening “Big Data Challenge” data: some insights on our role in the storyOpening “Big Data Challenge” data: some insights on our role in the story
Opening “Big Data Challenge” data: some insights on our role in the story
 
News Fact-checking: One Practical Application of Linked Statistics
News Fact-checking: One Practical Application of Linked StatisticsNews Fact-checking: One Practical Application of Linked Statistics
News Fact-checking: One Practical Application of Linked Statistics
 
ISWC 2014 - Dandelion: from raw data to dataGEMs for developers
ISWC 2014 - Dandelion: from raw data to dataGEMs for developersISWC 2014 - Dandelion: from raw data to dataGEMs for developers
ISWC 2014 - Dandelion: from raw data to dataGEMs for developers
 
SpazioDati presents dataTXT - SenTaClAus project - 2nd open day
SpazioDati presents dataTXT - SenTaClAus project - 2nd open daySpazioDati presents dataTXT - SenTaClAus project - 2nd open day
SpazioDati presents dataTXT - SenTaClAus project - 2nd open day
 
Text analytics for Google Spreadsheets using Text Mining add-on
Text analytics for Google Spreadsheets using Text Mining add-on Text analytics for Google Spreadsheets using Text Mining add-on
Text analytics for Google Spreadsheets using Text Mining add-on
 
Find the specific Wikipedia page you’re looking for, using Wikisearch API
Find the specific Wikipedia page you’re looking for, using Wikisearch APIFind the specific Wikipedia page you’re looking for, using Wikisearch API
Find the specific Wikipedia page you’re looking for, using Wikisearch API
 
Using entity extraction extension with OpenRefine and Dandelion API
Using entity extraction extension with OpenRefine and Dandelion APIUsing entity extraction extension with OpenRefine and Dandelion API
Using entity extraction extension with OpenRefine and Dandelion API
 
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENT
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENTDandelion API and mobile payment: food for thoughts for H-ACK PAYMENT
Dandelion API and mobile payment: food for thoughts for H-ACK PAYMENT
 
Cerved Group scommette sull'analisi semantica made in Italy
Cerved Group scommette sull'analisi semantica made in ItalyCerved Group scommette sull'analisi semantica made in Italy
Cerved Group scommette sull'analisi semantica made in Italy
 
LinkedStat: making ISTAT data more valuable
LinkedStat: making ISTAT data more valuableLinkedStat: making ISTAT data more valuable
LinkedStat: making ISTAT data more valuable
 
Smart Open Data Kickoff - Madrid - Linked
Smart Open Data Kickoff - Madrid - Linked Smart Open Data Kickoff - Madrid - Linked
Smart Open Data Kickoff - Madrid - Linked
 
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013
Linked STAT per l'evento datalab con ISTAT alla Smart City Exhibition 2013
 
Introducing JSONpedia
Introducing JSONpediaIntroducing JSONpedia
Introducing JSONpedia
 

Pubblicare Linked Open Data, lezione 1

  • 1. Contesto e intro Christian Morbidoni morbidoni@spaziodati.eu smart data now. giovedì 29 marzo 12
  • 2. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 3. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 4. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 5. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 6. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 7. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 8. Open Information vs Open Data smart data now. Data Data Data 2 giovedì 29 marzo 12
  • 9. I dati hanno meno valore quando sono isolati smart data now. giovedì 29 marzo 12
  • 10. Web of Documents smart data now. Hyperlinks For humans For machines X 4 giovedì 29 marzo 12
  • 11. Web of Data smart data now. Hyperlinks For humans related-to author-of same-as located-in same as agrees cites explains For machines works-for cites Semantic Links RDF Data RDF Data RDF Data RDF Data 5 giovedì 29 marzo 12
  • 12. Buzzword: Global Data Space smart data now. 6 giovedì 29 marzo 12
  • 13. Buzzword: Global Data Space smart data now. Institutions 6 giovedì 29 marzo 12
  • 14. Buzzword: Global Data Space smart data now. Companies Institutions 6 giovedì 29 marzo 12
  • 15. Buzzword: Global Data Space smart data now. Companies Institutions Geo-spatial services 6 giovedì 29 marzo 12
  • 16. Buzzword: Global Data Space smart data now. Companies Institutions Geo-spatial services Libraries 6 giovedì 29 marzo 12
  • 17. Buzzword: Global Data Space smart data now. Companies Institutions Geo-spatial services Libraries Citizens 6 giovedì 29 marzo 12
  • 18. Buzzword: Global Data Space smart data now. Companies Institutions Geo-spatial services Libraries Citizens 6 giovedì 29 marzo 12
  • 19. Pubblicare Linked Data sul Web Christian Morbidoni morbidoni@spaziodati.eu smart data now. giovedì 29 marzo 12
  • 20. Che cos’è Linked Data smart data now. • Una serie di “best practices” per pubblicare dati strutturati e interconnessi sul Web • 4 Principi base: • Use URIs as names for things. • Use HTTP URIs, so that people can look up those names. • When someone looks up a URI, provide useful information, using the standards (RDF, SPARQL). • Include links to other URIs, so that they can discover more things. • L’idea è usare la stessa infrastruttura del Web (of documents) per costruire il Web of Data 8 giovedì 29 marzo 12
  • 21. Dereferenciable URLs smart data now. • Best practice: evitare l’uso di URN e “non HTTP” URLs • LD si basa su un unico protocollo (HTTP) per la risoluzione delle risorse • I dati “parlano” di entità del mondo reale, non solo di risorse web • Information resource: un documento che “descrive” o “rappresenta” una risorsa • Non-information resource: una entità del mondo reale, non-digitale • Esempio: • Mario Monti è una real-world resource (non-information resource) • http://it.wikipedia.org/wiki/Mario_Monti è uno dei possibili documenti che descrivono la risorsa (information resource) 9 giovedì 29 marzo 12
  • 22. Dereferenciable URLs smart data now. • Documenti e real-world resources devono avere URL diverse • Non devono essere confuse tra loro • Più rappresentazioni digitali della stessa real-world resources devono essere possibili • HTML per gli umani • RDF per i software “semantici” • Plain XML, JSON, TXT, etc. per i software “non semantici” ? • Content negotiation • RFC 2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html • Meccanismo standard HTTP per fornire diverse rappresentazioni della stessa risorsa in risposta a diverse richieste • Due strategie possibili (http://www.w3.org/TR/cooluris/) • 303 redirect • Hash URLs 10 giovedì 29 marzo 12
  • 23. 303 redirect + content negotiation smart data now. 11 giovedì 29 marzo 12
  • 24. 303 redirect + content negotiation smart data now. GET /id/alice HTTP/1.1 Host: example.com Accept: text/html;q=0.5, application/rdf+xml 1 2 HTTP/1.1 303 See Other Location: http://example.com/data/alice Client Server GET /data/alice HTTP/1.1 HTTP/1.1 200 OK Host: example.com Content-Type: application/rdf+xml Accept: text/html;q=0.5, application/rdf+xml <http://www.example.com/id/alice> a foaf:Person; foaf:name "Alice"; 3 foaf:mbox <mailto:alice@example.com>; ... 4 12 giovedì 29 marzo 12
  • 25. 303 redirect to generic doc smart data now. 13 giovedì 29 marzo 12
  • 26. 303 redirect to generic doc smart data now. Variane da usare solo nel caso i due documenti siano equivalenti dal punto di vista del contenuto. (http:// www.w3.org/TR/cooluris) Scarsa utilità pratica (?) 13 giovedì 29 marzo 12
  • 27. Alternative (?): “plain” content negotiation smart data now. GET /id/alice HTTP/1.1 Host: example.com Accept: text/html;q=0.5, application/rdf+xml 1 Client Server HTTP/1.1 200 OK Content-Location: http://example.com/data/alice Content-Type: application/rdf+xml 2 <http://www.example.com/id/alice> a foaf:Person; foaf:name "Alice"; foaf:mbox <mailto:alice@example.com>; ... • Blog post e discussione (2010): http://blog.iandavis.com/2010/11/07/a-guide-to- publishing-linked-data-without-redirects/ • Non possibile se le URI provengono da diversi host • 303 redirect è lo standard “de facto”, ma questo approccio è condiviso da molti • C’è una lunga discussione in corso su questo argomento...it’s up to you :-) 14 giovedì 29 marzo 12
  • 28. Hash URLs smart data now. • L’URL fragment (#...) è ignorato dal browser, che richiede l’intero documento • La URL http://example.com/about#alice non è direttamente dereferenziabile e può essere utilizzata per indicare la non-information resource 15 giovedì 29 marzo 12
  • 29. Hash URLs smart data now. Client requests URL: http://example.com/about#alice GET /about HTTP/1.1 Host: example.com Accept: text/html;q=0.5, application/rdf+xml 1 Client skips unwanted info... Client Server HTTP/1.1 200 OK Content-Type: application/rdf+xml <http://www.example.com/about#alice> 2 a foaf:Person; foaf:name "Alice"; foaf:mbox <mailto:alice@example.com>; ... <http://www.example.com/about#bob> a foaf:Person; foaf:name "Bob"; foaf:mbox <mailto:bob@example.com>; ... 16 giovedì 29 marzo 12
  • 30. Pros e Cons smart data now. • Hash URL • Contro: Richiede il dowload dell’intero documento (che potenzialmente descrive N risorse) • Pro: Non richiede redirects • 303 redirect • Contro: richiede più passaggi e una opportuna configurazione del web server • Pro: E’ più flessibile. Permette di scaricare una descrizione alla volta, o più descrizioni assieme. Permette di cambiare la policy in seguito. • Best practice: • 303 redirect per risorse in un (potenzialmente) largo dataset • Hash URLs per i vocabolari/ontologie • Se possibile mettere a disposizione anche uno SPARQL endpoint • Soluzione ibrida () • http://example.com/id/alice#this > Non-Information Resource • http://example.com/id/alice > Information Resource 17 giovedì 29 marzo 12
  • 31. Links http://dbpedia.org smart data now. http://dati.piemonte.it ….. <http://dati.piemonte.it/id/Torino> http://geonames.org skos:exactMatch <http://dbpedia.org/resource/Turin> . ….. <http://dati.piemonte.it/id/Torino> owl:sameAs <http://sws.geonames.org/3165524> . …. <http://dati.piemonte.it/id/Mostra-123> dc:subject <http://rdf.freebase.com/ns/en.impressionism> . …. <http://dati.piemonte.it/id/Torino> rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> . …. http://freebase.com http://sw-portal.deri.org giovedì 29 marzo 12
  • 32. Links http://dbpedia.org smart data now. http://dati.piemonte.it ….. <http://dati.piemonte.it/id/Torino> http://geonames.org skos:exactMatch <http://dbpedia.org/resource/Turin> . Identity Links ….. <http://dati.piemonte.it/id/Torino> owl:sameAs <http://sws.geonames.org/3165524> . …. <http://dati.piemonte.it/id/Mostra-123> dc:subject <http://rdf.freebase.com/ns/en.impressionism> . …. <http://dati.piemonte.it/id/Torino> rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> . …. http://freebase.com http://sw-portal.deri.org giovedì 29 marzo 12
  • 33. Links http://dbpedia.org smart data now. http://dati.piemonte.it ….. <http://dati.piemonte.it/id/Torino> http://geonames.org skos:exactMatch <http://dbpedia.org/resource/Turin> . Identity Links ….. <http://dati.piemonte.it/id/Torino> owl:sameAs <http://sws.geonames.org/3165524> . …. <http://dati.piemonte.it/id/Mostra-123> Relationship Links …. dc:subject <http://rdf.freebase.com/ns/en.impressionism> . <http://dati.piemonte.it/id/Torino> rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> . …. http://freebase.com http://sw-portal.deri.org giovedì 29 marzo 12
  • 34. Links http://dbpedia.org smart data now. http://dati.piemonte.it ….. <http://dati.piemonte.it/id/Torino> http://geonames.org skos:exactMatch <http://dbpedia.org/resource/Turin> . Identity Links ….. <http://dati.piemonte.it/id/Torino> owl:sameAs <http://sws.geonames.org/3165524> . …. <http://dati.piemonte.it/id/Mostra-123> Relationship Links …. dc:subject <http://rdf.freebase.com/ns/en.impressionism> . <http://dati.piemonte.it/id/Torino> Vocabulary Links …. rdf:type <http://sw-portal.deri.org/ontologies/swportal#City> . http://freebase.com http://sw-portal.deri.org giovedì 29 marzo 12
  • 35. Descrivere un dataset smart data now. • Così come in RDF si descrivono le risorse (es. le città, le persone), è importante anche descrivere i dataset stessi • Fornisce informazioni importanti agli utenti dei dati • Consente ai motori di ricerca di indicizzare e scoprire più facilmente i dati • Standard de facto • VoID (Vocabulary of Interlinked Datasets) 19 giovedì 29 marzo 12
  • 36. VoID: example smart data now. @prefix : <http://rdfs.org/ns/void#> . @prefix dcterms: <http://purl.org/dc/terms/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . <#DS1> a :Dataset; dcterms:description "Geonames dataset"; dcterms:title "Geonames"; :exampleResource <http://sws.geonames.org/3172483/about.rdf>; foaf:homepage <http://geonames.org> . <#myDS-DS1> a :Linkset; :linkPredicate <http://www.w3.org/2000/01/rdf-schema#seeAlso>; :target <#DS1>, <http://linkedopendata.it/datasets/grrp> . <http://linkedopendata.it/grrp> a :Dataset; dcterms:description "Accommodations in Piemonte. GoodRelations compliant."; dcterms:license <http://creativecommons.org/licenses/by/2.0/>; dcterms:publisher <http://linkedopendata.it>; dcterms:source <dati.piemonte.it>; dcterms:subject <http://dbpedia.org/resource/Piedmont>; dcterms:title "Strutture ricettive Piemonte - GoodRelations"; :dataDump <http://dump.linkedopendata.it/grrp>; :exampleResource <http://data.linkedopendata.it/grrp/resource/AFFITTACAMERE_ARCOBALENO_2>; :sparqlEndpoint <http://sparql.linkedopendata.it/grrp>; :subset <#myDS-DS1>; :vocabulary <http://purl.org/goodrelations/v1#>, <http://purl.org/net7/vocab/gracc/v1#>, <http://www.w3.org/2006/vcard/ns#>; foaf:homepage <http://linkedopendata.it/grrp> . 20 giovedì 29 marzo 12
  • 37. Discovery of VoID descriptions smart data now. • Come rendere “trovabile” la descrizione VoID di un dataset? • Back links • Consentono di risalire alla descrizione del dataset a partire dai dati stessi (descrizione RDF delle risorse) • es. <http://dbpedia.org/data/Berlin> dcterms:isPartOf :DBpedia . • La tripla deve essere inclusa nella descrizione RDF di ogni risorsa del dataset • Sitemap • Sitemap è il modo standard per esporre le risorse ai web crawler • Semantic Sitemap è una estensione per descrivere dataset linked • Esiste un overlap tra VoID e Semantic Sitemaps, ma possono essere usati efficacemente assieme • Workflow: • Il client raggiunge il file robots.txt posizionato nella root (/) del dominio • Il client cerca la riga che iniza per 'Sitemap :', che è seguita dalla URL del file sitemap.xml • Se il file sitemap.xml sua l’estensione Semantic Sitemap, contiene l’elemento <sc:dataset> che a sua volta contiene l’elemento <sc:datasetURI> come figlio. il suo valore è l’URL del dataset • L’URL del dataset viene dereferenziata ottendendo la descrizione VoID del datset 21 giovedì 29 marzo 12
  • 38. Semantic Sitemap: example smart data now. <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:sc="http://sw.deri.org/2007/07/sitemapextension/scschema.xsd"> <sc:dataset> <sc:datasetLabel>Big Lynx People Data Set</sc:datasetLabel> <sc:datasetURI>http://biglynx.co.uk/datasets/people</sc:datasetURI> <sc:linkedDataPrefix>http://biglynx.co.uk/people/</sc:linkedDataPrefix> <sc:sampleURI>http://biglynx.co.uk/people/dave-smith</sc:sampleURI> <sc:sampleURI>http://biglynx.co.uk/people/matt-briggs</sc:sampleURI> <sc:sparqlEndpointLocation>http://biglynx.co.uk/sparql</ sc:sparqlEndpointLocation> <sc:dataDumpLocation>http://biglynx.co.uk/dumps/people.rdf.gz</ sc:dataDumpLocation> <changefreq>monthly</changefreq> </sc:dataset> </urlset> 22 giovedì 29 marzo 12
  • 39. License smart data now. • Creative Commons definisce un vocabolario RDF per descrivere le licenze ESEMPIO: <http://creativecommons.org/licenses/by-sa/3.0/> rdf:type cc:License ; dc:title "Attribution-Share Alike 3.0 Unported" ; dc:creator <http://creativecommons.org/> ; cc:permits cc:Distribution , cc:DerivativeWorks , cc:Reproduction ; cc:requires cc:ShareAlike , cc:Attribution , cc:Notice ; • E’ possibile specificare la licenza per ogni descrizione RDF aggiungendo una singola tripla • es. <http://example.org/id/alice> cc:license <http://creativecommons.org/ licenses/by-sa/3.0/> . 23 giovedì 29 marzo 12
  • 40. Pattern architetturali smart data now. from: http://linkeddatabook.com/editions/1.0 Criteri: 1) Tipologia di dati di partenza 2)Mole di dati 3)Frequanza di update dei dati 24 giovedì 29 marzo 12
  • 41. File RDF statici smart data now. • Best practice: usare Hash URLs • File: http://example.org/porjects/myproject.rdf • Entità progetto: http://example.org/porjects/myproject.rdf#project • Configurare il web server per servire il giusto MIME type, application/ rdf+xml • Rendere l’RDF facilmente trovabile includendo un link nella pagina HTML corrispondente • <link rel="alternate" type="application/rdf+xml" href="project.rdf"> • Alternativa: includere RDFa nelle pagine HTML 25 giovedì 29 marzo 12
  • 42. Servire LD da un DB relazionale smart data now. • Esistono tool ad-hoc per questo compito • D2RQ è uno dei più usati 26 giovedì 29 marzo 12
  • 43. Servire LD da un triplestore smart data now. • Non tutti i triple store hanno supporto buil-in per Linked Data • In questi casi occorre usare un layer aggiuntivo • Tool più utilizzati: • Pubby, http://www4.wiwiss.fu-berlin.de/pubby/ • Linked Data API (http://code.google.com/p/linked-data-api/wiki/ Specification) implementation • ELDA, http://elda.googlecode.com/hg/deliver-elda/src/main/docs/index.html • PUELIA, http://code.google.com/p/puelia-php/ 27 giovedì 29 marzo 12
  • 44. Resource Description Framework (e database relazionali) Christian Morbidoni morbidoni@spaziodati.eu smart data now. giovedì 29 marzo 12
  • 45. Dati distribuiti smart data now. • Il primo requirement di RDF è quello di supportare la descrizione di dati distribuiti sul Web • Supponendo di voler rappresentare i seguenti dati in forma tabulare... Come distribuirli sul Web? ID Title Author Medium Year 1 As you like it Shakespeare Play 1599 2 Hamlet Shakespeare Play 1604 3 Othello Shakespeare Play 1603 4 Sonnet 18 Shakespeare Poem 1609 5 Astrophil and Stella Sir Phillip Sidney Poem 1590 6 Edward II Christopher Marlowe Play 1592 7 Hero and Leander Christopher Marlowe Poem 1593 8 Greensleeves Henry VII Rex Song 1525 29 giovedì 29 marzo 12
  • 46. Dati distribuiti smart data now. • Un primo approccio potrebbe essere distribuire i dati riga per riga ID Title Author Medium Year 1 As you like it Shakespeare Play 1599 server 1 ID Title Author Medium Year 2 Hamlet Shakespeare Play 1604 3 Othello Shakespeare Play 1603 server 2 ID Title Author Medium Year 6 Edward II Christopher Marlowe Play 1592 7 Hero and Leander Christopher Marlowe Poem 1593 server 3 • Ogni serve mantiene un certo numero di risorse • Flessibilità: facile inserire una nuova risorsa • Rigidità: aggiungere un campo alla tabella richiede coordinazione tra tutti i server • I server devono essere coordinati in modo che i campi corrispondano • Requirement: serve un identificatore globale per ogni campo 30 giovedì 29 marzo 12
  • 47. Dati distribuiti smart data now. • Un secondo approccio: colonna per colonna Author Shakespeare Shakespeare server 1 Shakespeare server 3 Title Shakespeare Medium Year As you like it Play 1599 Sir Phillip Sidney Hamlet Play 1604 Christopher Marlowe Play 1603 Othello Christopher Marlowe Poem 1609 Sonnet 18 Henry VII Rex Poem 1590 Astrophil and Stella Play 1592 Edward II Poem 1593 Hero and Leander Song 1525 Greensleeves server 2 • Ogni server è responsabile per un “tipo” di dati • Flessibilità: è facile estendere il modello del DB (aggiungere campi) • Rigidità: inserire una nuova risorsa richiede la collaborazione di tutti i server • Requirement: serve un identificatore globale per ogni risorsa 31 giovedì 29 marzo 12
  • 48. Dati distribuiti smart data now. • Una combinazione dei due: cella per cella Title 1 As you like it Author 2 Shakespeare Medium server 1 server 3 4 Poem Title 3 Othello Year 2 1604 server 2 • Pro: Combina la flessibilità dei due approcci • ogni server può liberamente aggiungere risorse, campi e relativi valori • Requirement: • Servono identificatori globali sia per le risorse che per i “campi” • RDF si basa su questo approccio 32 giovedì 29 marzo 12
  • 49. Triple smart data now. • In questo modello l’unità atomica di dati è formata da tre valori: • identificatore della riga • nome del campo • valore corrispondente. • In RDF si chiama Tripla o Statement, ed è composto a: • Soggetto - una risorsa • Predicato - un tipo di relazione o proprietà • Oggetto - un valore o una risorsa 33 giovedì 29 marzo 12
  • 50. Triple e tabelle smart data now. • Dati tabellari: ID Title Author Medium Year 1 As you like it Shakespeare Play 1599 2 Hamlet Shakespeare Play 1604 • Una tripla può essere vista come una tabella con tre campi. Subject Predicate Object 1 has title “As you like it” 1 has author Shakespere 2 has medium Play 2 has author Shakespere • oppure: Subject Predicate Object Shakespere wrote As you like it As you like it has medium Play Shakespere wrote Hamlet Amlet year 1604 34 giovedì 29 marzo 12
  • 51. Triple e grafi smart data now. • Un tripla può essere rappresentata anche così: Shakespere wrote Hamlet • Quando più triple si riferiscono alla stessa risorsa possono essere visualizzate come un grafo etichettato e direzionato (directed labeled graph): As you like it has medium Play wrote Shakespere wrote Hamlet year 1604 35 giovedì 29 marzo 12
  • 52. Graph merging smart data now. • Ogni pezzo di informazione sul Semantic Web è un grafo • Unire e aggregare informazioni è semplice .... Hamlet year 1604 wrote Shakespere wrote Macbeth set in Scotland part of UK Macbeth has medium Play wrote Shakespere lived in Stratford it is in England part of UK 36 giovedì 29 marzo 12
  • 53. Graph merging smart data now. • Unico requisito: un modo inequivocabile per stabilire quando due nodi in grafi diversi sono equivalenti Hamlet year 1604 wrote Shakespere wrote Macbeth set in Scotland lived in has medium part of Play UK Stratford it is in part of England 37 giovedì 29 marzo 12
  • 54. URI come identificatori globali smart data now. • Un generalizzazione dell’approccio già usato sul Web • Le URL sono tipi particolari di URI • Due risorse sono uguali se hanno la stessa URI • Un Uniform Resource Identifier identifica una risorsa che può far parte di un grafo RDF • Non-unique Name Assumption: non è Unique è Uniform! • Una risorsa può avere più URI 38 giovedì 29 marzo 12
  • 55. URI: sintassi smart data now. • Sintassi dipendente dallo schema <scheme>:<scheme-specific-part> • Sintassi generica (usata da diversi schemi ma non obbligatoria) <scheme>://<authority><path>?<query> • Schema (obbligatorio) • Determina la “semantica” dell’URI • Può indicare un meccanismo di risoluzione (http, ftp, etc.) • Authority • Indica una autorità per il naming (es. web domain) • Path • Identifica la risorsa all’interno dell’authority (es. a/b/c) • Query • Stringa interpretabile dalla risorsa stessa (es. ?user=christian) 39 giovedì 29 marzo 12
  • 56. URL e URN smart data now. • Tipi di URI: • Uniform Resource Locators (URLs) • Specificano un protocollo per risolvere la risorsa • Uniform Resource Names (URNs) • Sono dei nomi ma non hanno una rappresentazione digitale vera e propria • URL e risorse: • Una pagina Web: http://myHomePage.it/me.htm (URL) • Un libro: urn:isbn:1234-123443-1234343 (URN) • Un oggetto digitale: urn:doi:10.1000/182 (URN) • Una persona: mailto:christian.morbidoni@gmail.com (URL) • Generalizzazione: Internationalized Resource Identifier (IRI) Wikipedia: “is a generalization of the Uniform Resource Identifier (URI), which is in turn a generalization of the Uniform Resource Locator (URL). While URIs are limited to a subset of the ASCII character set, IRIs may contain characters from the Universal Character Set (Unicode/ISO 10646), including Chinese or Japanese kanji, Korean, Cyrillic characters, and so forth.” 40 giovedì 29 marzo 12
  • 57. Esempio di N-Triples smart data now. <http://www.artchive.com/crucifixion.jpg> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.icom.com/schema.rdf#Sculpture> . <http://www.ibiblio.org/wm/paint/auth/pippo/> <http://www.icom.com/schema.rdf#first_name> "Pippo"@en . <http://www.ibiblio.org/wm/paint/auth/pippo/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.icom.com/schema.rdf#Sculptor> . <http://www.ibiblio.org/wm/paint/auth/rodin/> <http://www.icom.com/schema.rdf#creates> <http://www.artchive.com/crucifixion.jpg> . 41 giovedì 29 marzo 12
  • 58. Turtle (superset di N-Triples) smart data now. # See slides for RDF talk # # http://www.w3.org/2000/Talks/0906-xmlweb-tbl/slide6-0.html # @prefix p: <http://www.example.org/personal_details#> . @prefix m: <http://www.example.org/meeting_organization#> . <http://www.example.org/people#fred> ! p:GivenName ! "Fred"; ! p:hasEmail ! ! <mailto:fred@example.com>; ! m:attending !! <http://meetings.example.com/cal#m1> . <http://meetings.example.com/cal#m1> ! m:homePage ! ! <http://meetings.example.com/m1/hp> . 42 giovedì 29 marzo 12
  • 59. Stesso esempio in RDF/XML smart data now. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:m="http://www.example.org/meeting_organization#" xmlns="http://www.example.org/people#" xmlns:p="http://www.example.org/personal_details#"> <rdf:Description about="http://meetings.example.com/cal#m1"> <m:homePage resource="http://meetings.example.com/m1/hp"/> </rdf:Description> <rdf:Description about="http://www.example.org/people#fred"> <m:attending resource="http://meetings.example.com/cal#m1"/> <p:GivenName>Fred</p:GivenName> <p:hasEmail resource="mailto:fred@example.com"/> </rdf:Description> </rdf:RDF> 43 giovedì 29 marzo 12
  • 60. RDF/JSON smart data now. { "http://example.org/about" : { "http://purl.org/dc/elements/1.1/creator" : [ { "value" : "Anna Wilder", "type" : "literal" } ], "http://purl.org/dc/elements/1.1/title"  : [ { "value" : "Anna's Homepage", "type" : "literal", "lang" : "en" } ] , "http://xmlns.com/foaf/0.1/maker"  : [ { "value" : "_:person", "type" : "bnode" } ] } ,   "_:person" : { "http://xmlns.com/foaf/0.1/homepage"  : [ { "value" : "http://example.org/about", "type" : "uri" } ] , "http://xmlns.com/foaf/0.1/made"  : [ { "value" : "http://example.org/about", "type" : "uri" } ] , "http://xmlns.com/foaf/0.1/name"  : [ { "value" : "Anna Wilder", "type" : "literal" } ] , "http://xmlns.com/foaf/0.1/firstName"  : [ { "value" : "Anna", "type" : "literal" } ] , "http://xmlns.com/foaf/0.1/surname"  : [ { "value" : "Wilder", "type" : "literal" } ] , "http://xmlns.com/foaf/0.1/depiction"  : [ { "value" : "http://example.org/pic.jpg", "type" : "uri" } ] , "http://xmlns.com/foaf/0.1/nick"  : [ { "type" : "literal", "value" : "wildling"} , { "type" : "literal", "value" : "wilda" } ] , "http://xmlns.com/foaf/0.1/mbox_sha1sum"  : [ { "value" : "69e31bbcf58d432950127593e292a55975bc66fd", "type" : "literal" } ] } } 44 giovedì 29 marzo 12
  • 61. RDFa: embedding RDF into web pages smart data now. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>John's Home Page</title> <base href="http://example.org/john-d/" /> <meta property="dc:creator" content="Jonathan Doe" /> <link rel="foaf:primaryTopic" href="http://example.org/john-d/#me" /> </head> <body about="http://example.org/john-d/#me"> <h1>John's Home Page</h1> <p>My name is <span property="foaf:nick">John D</span> and I like <a href="http://www.neubauten.org/" rel="foaf:interest" xml:lang="de">Einstürzende Neubauten</a>. </p> <p> My <span rel="foaf:interest" resource="urn:ISBN:0752820907">favorite book is the inspiring <span about="urn:ISBN:0752820907"><cite property="dc:title">Weaving the Web</cite> by <span property="dc:creator">Tim Berners-Lee</span></span> </span> </p> </body> </html> 45 giovedì 29 marzo 12
  • 62. Named Graphs smart data now. • L’idea alla base delle specifiche (http://www.w3.org/1999/02/22- rdf-syntax-ns#) è semplice: • Un set di triple RDF è un grafo • Ogni grafo è identificato esso stesso da una URI • Ampio supporto in SPARQL e nei triple-store • Da triple a quadruple (quad-store) • Soggetto - Predicato - Oggetto - Provenienza 46 giovedì 29 marzo 12
  • 63. TriG smart data now. • Specifiche: http://www4.wiwiss.fu-berlin.de/bizer/TriG/#example • Esempio: # TriG Example Document 1 # This document encodes three graphs. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix swp: <http://www.w3.org/2004/03/trix/swp-1/> . @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix ex: <http://www.example.org/vocabulary#> . @prefix : <http://www.example.org/exampleDocument#> . :G1 { :Monica ex:name "Monica Murphy" . :Monica ex:homepage <http://www.monicamurphy.org> . :Monica ex:email <mailto:monica@monicamurphy.org> . :Monica ex:hasSkill ex:Management } :G2 { :Monica rdf:type ex:Person . :Monica ex:hasSkill ex:Programming } :G3 { :G1 swp:assertedBy _:w1 . _:w1 swp:authority :Chris . _:w1 dc:date "2003-10-02"^^xsd:date . :G2 swp:quotedBy _:w2 . :G3 swp:assertedBy _:w2 . _:w2 dc:date "2003-09-03"^^xsd:date . _:w2 swp:authority :Chris . :Chris rdf:type ex:Person . :Chris ex:email <mailto:chris@bizer.de> } 47 giovedì 29 marzo 12
  • 64. RDF and tabular data: assignment smart data now. Products ID Model Division Product Line Manufacture Location Available 1 zx-3 Manufactoring support Paper machine Sacramento 23 2 zx-3P Manufactoring support Paper machine Sacramento 4 3 B-1430 Control Engineering Active sensor Hong Kong 100 4 DBB-12 Safety Safety Valve Cleveland 34 • Assignment: esprimere i dati in forma di RDF • Osservazioni: • Ogni riga identifica una risorsa diversa: servono identificatori per le risorse • Ogni colonna esprime una proprietà di una risorsa: servono identificatori per le proprietà • Il nome della tabella esprime una categoria di oggetti: i prodotti • Namespace: possiamo scegliere un namespace unico per il DB: http://manufactoringX.com/products/ (prefisso mfx:) • Consiglio: usare la sintassi N3 48 giovedì 29 marzo 12
  • 65. RDB to RDF mapping smart data now. • Specifiche W3C: • Direct Mapping: http://www.w3.org/TR/rdb-direct-mapping/ • Definisce un metodo “standard” per mappare tabelle relazionali in triple RDF • La struttura dell’RDF riflette esattamente quella del DB • Il vocabolario RDF riflette esattamente le tabelle del DB • Mapping language: R2RML: http://www.w3.org/TR/r2rml/ • Un linguaggio per specificare un mapping “custom” da un particolare DB • Consente di scegliere un vocabolario RDF qualsiasi • Produce un RDF più “usabile” • Tools: • D2RQ, http://d2rq.org/ - open-source • Triplify, http://triplify.org - open-source • Virtuoso, http://virtuoso.openlinksw.com/ - open-source + commercial • ..... 49 giovedì 29 marzo 12
  • 66. Direct Mapping: example smart data now. 50 giovedì 29 marzo 12
  • 67. R2RML: example smart data now. 51 giovedì 29 marzo 12
  • 68. R2RML: example smart data now. ? 51 giovedì 29 marzo 12
  • 69. R2RML: example smart data now. 52 giovedì 29 marzo 12
  • 70. D2RQ everview smart data now. Architecture 53 giovedì 29 marzo 12
  • 71. D2RQ: example mapping smart data now. 54 giovedì 29 marzo 12
  • 72. RDF Schema (...alcune osservazioni) Christian Morbidoni morbidoni@spaziodati.eu smart data now. giovedì 29 marzo 12
  • 73. RDFS Vocabulary smart data now. 56 giovedì 29 marzo 12
  • 74. RDF, RDFS, Vocabulary smart data now. 57 giovedì 29 marzo 12
  • 75. RDFS Entailments smart data now. 58 giovedì 29 marzo 12
  • 76. Inference and data integration smart data now. • L’inferenza gioca un ruolo importante nell’integrazione tra grafi • In alcuni casi le URI non bastano... • Esempio: come unire in modo consistente i seguenti grafi? Graph 1 Graph 2 ex1:Car ex2:Motorcicle rdf:type rdf:type rdf:type rdf:type rdf:type rdf:type ex2:Shadow ex1:FiatPunto ex1:Fiat500 ex2:RX ex1:FiatBravo ex2:Monster 59 giovedì 29 marzo 12
  • 77. Inference and data integration smart data now. • Utilizzando semplicemente rdfs:subClassOf possiamo creare un modello di integrazione Integration model myns:Veicle Graph 1 rdfs:SubClassOf rdfs:SubClassOf Graph 2 ex1:Car ex2:Motorcicle rdf:type rdf:type rdf:type rdf:type rdf:type rdf:type ex2:Shadow ex1:FiatPunto ex1:Fiat500 ex2:RX ex1:FiatBravo ex2:Monster 60 giovedì 29 marzo 12
  • 78. Inference and data integration smart data now. • Il modello integrato presenta gli individui in modo omogeneo: Integrated model myns:Veicle rdf:type rdf:type ex1:FiatPunto ex2:Shadow rdf:type rdf:type rdf:type rdf:type ex1:FiatBravo ex2:Monster ex1:Fiat500 ex2:RX • L’inferenza può sembrare molto banale ... • .. ma spesso semplici connessioni logiche sono in grado di rendere le applicazioni sensibilmente più smart • “A little semantics goes a long way” :-) 61 giovedì 29 marzo 12
  • 79. Type propagation (rdfs:subClassOf) smart data now. • Se RDF modella triple e grafi ... • RDF Schema modella insiemi (sets) • Un insieme è definito come una risorsa di tipo rdfs:Class • Il costrutto per indicare un sotto-set è rdfs:subClassOf • E’ anche il più abusato (come extends in Java :-) ) • Pattern: type propagation :AllStartPlayer rdf:type rdfs:Class :MajorLeaguePlayer rdf:type rdfs:Class :AllStartPlayer rdfs:subClassOf :MajorLeaguePlayer :Keneda rdf:type :AllStartPlayer . INFERRED TRIPLES: :Keneda rdf:type :MajorLeaguePlayer 62 giovedì 29 marzo 12
  • 80. Relationship propagation (rdfs:subPropertyOf) smart data now. • In alcuni casi è utili parlare non solo delle classi (insiemi di istanze) ma anche delle proprietà (relazioni) che intercorrono tra le risorse • rdfs:subPropertyOf :freeLancesTo rdfs:subPropertyOf :contractsTo . • funzionamento analogo :indirectlyContractsTo rdfs:subPropertyOf :contractsTo . a rdfs:subClassOf :isEmployedBy rdfs:subPropertyOf :worksFor . :contractsTo rdfs:subPropertyOf :worksFor . • IF ?p rdfs:subPropertyOf ?q :Goldman :isEmployedBy :TheFirm . AND ?x ?p ?y :Spence :freeLancesTo :TheFirm . THEN ?x ?q ?y :Long :indirectlyContractsTo :TheFirm . INFERRED TRIPLES: :Goldman :worksFor :theFirm :Spencer :contractsTo :theFirm :Long :contractsTo :theFirm • Nota: Non ha un analogo SECOND STEP: nei lingugaggi di :Spence :worksFor :theFirm programmazione :Long :worksFor :theFirm 63 giovedì 29 marzo 12
  • 81. rdfs:domain e rdfs:range smart data now. • Un altro modo di parlare di una proprietà è quello di indicare come essa dovrebbe essere usata nel contesto • Ovvero: quali tipi di risorse unisce • I concetti di dominio (domain) e codominio (range) vengono presi dalla matematica • Regole di inferenza: :contractsTo • IF ?p rdfs:range ?a a owl:ObjectProperty ; AND ?x ?p ?y rdfs:domain :Person ; THEN ?y rdf:type ?a :Spencer :contractsTo :theFirm • IF ?p rdfs:domain ?a INFERRED TRIPLE: AND ?x ?p ?y :Spencer rdf:type Person THEN ?x rdf:type ?a • Nota: doamin e range non possono generare dati invalidi o inconsistenze • L’approccio è quello di rendere sempre consistente il grafo applicando le regole di inferenza 64 giovedì 29 marzo 12
  • 82. Pattern rdfs:domain, rdfs:range + rdfs:subClassOf smart data now. :ITEmployee :Daniel :developed :Talia Inferred triples: rdfs:subClassOf :Daniel rdf:type :Developer :Daniel rdf:type :ITEmployee :developed rdfs:domain :Developer • I pratica possiamo definire un’altra regola di inferenza: • IF ?p rdfs:domain ?a AND ?a rdfs:subClassOf ?b THEN ?p rdfs:domain ?b • L’inferenza agisce in modo “inaspettato”: dal semplice uso di una proprietà posso dedurre la sua appartenenza a una gerarchia di classi ... 65 giovedì 29 marzo 12
  • 83. domain e range: errori comuni smart data now. • L’utilizzo e il significato di rdfs:domain e rdfs:range in RDFS crea spesso confusione • Soprattutto a chi è abituato a pensare “Object Oriented” (e chi non lo è ?!) • Una comune associazione tra OOP e RDFS: • rdfs:Class >> OOP Class • rdfs:domain A >> dichiarazione di una variabile nella classe A • Visione rafforzata da alcuni tool per la visualizzazione di RDF (es. Protege) • Ma non è proprio così .... 66 giovedì 29 marzo 12
  • 84. OOP vs. Semantic Web smart data now. OOP Semantic Web Class A :foo rdfs:domain :ClassA public static Object Foo; rdfs:subClassOf Class B extends A Foo; :foo rdfs:domain :ClassB • In OOP l’inheritance consente alle sottoclassi di ereditarele variabili • ! In RDFS le super-classi ricevono associazioni con le risorse dalle sottoclassi ! 67 giovedì 29 marzo 12
  • 85. Consistency check? smart data now. • ! In RDFS non esiste il concetto di consistency/validity check ! • AAA • Anybody can say Anything about Anything • Open World Assumption • Non posso dedurre nuova conoscenza dalla mancanza di informazioni • Es. se in un dataset RDF non esiste la tripla “:Pluto rdf:type :Dog” • Non posso dedurre NOT(:Pluto rdf:type :Dog) 68 giovedì 29 marzo 12
  • 86. Consistency check? smart data now. :Christian rdf:type :Person . :hasPrice rdfs:domain :Product . :Christian :hasPrice “49.99 €” . 69 giovedì 29 marzo 12
  • 87. Consistency check? smart data now. :Christian rdf:type :Person . :hasPrice rdfs:domain :Product . :Christian :hasPrice “49.99 €” . ! I dati sono validi per un reasoner RDFS ! 69 giovedì 29 marzo 12
  • 88. Consistency check? smart data now. :Christian rdf:type :Person . :hasPrice rdfs:domain :Product . :Christian :hasPrice “49.99 €” . ! I dati sono validi per un reasoner RDFS ! ! Un reasoner deduce ... :Christian rdf:type :Product . 69 giovedì 29 marzo 12
  • 89. Interrogare dati RDF: SPARQL Christian Morbidoni morbidoni@spaziodati.eu smart data now. giovedì 29 marzo 12
  • 90. Querying RDF smart data now. • SPARQL • Specifiche: http://www.w3.org/TR/rdf-sparql-query/ • RDF Query language standard W3C • Basato sul predecessore RDQL • Tutorial: http://www.cambridgesemantics.com/2008/09/sparql-by-example • SQL-like syntax Esempio: ! PREFIX dc: <http://purl.org/dc/elements/1.1/> ! ! SELECT ?title ! ! WHERE ! ! ! { <http://example.org/book/book1> dc:title ?title } • SeRQL • Precedente RDF Query Language sviluppato da Aduna (Sesame) • Funzionalità equiparabili a SPARQL 71 giovedì 29 marzo 12
  • 91. SPARQL tutorial smart data now. • Alcuni esempi di query nelle seguenti slides.... • Tuttavia esiste un ottimo tutorial online a cui fare riferimento: • http://www.cambridgesemantics.com/2008/09/sparql-by-example/ 72 giovedì 29 marzo 12
  • 92. SPARQL smart data now. • PREFIX • Dichiarazione dei namespace • SELECT • Identifica le variabile di ritorno della query • FROM • Il nome del grafo su cui eseguire la query • SPARQL supporta i Named Graphs • WHERE • “Query Pattern” 73 giovedì 29 marzo 12
  • 93. RDF example smart data now. 74 giovedì 29 marzo 12
  • 94. SPARQL query example (1) smart data now. 75 giovedì 29 marzo 12
  • 95. SPARQL query example (2) smart data now. 76 giovedì 29 marzo 12
  • 96. SPARQL query example (3) smart data now. 77 giovedì 29 marzo 12
  • 97. SPARQL query example (4) smart data now. 78 giovedì 29 marzo 12
  • 98. SPARQL query example (5) smart data now. 79 giovedì 29 marzo 12
  • 99. SPARQL query example (6) smart data now. 80 giovedì 29 marzo 12
  • 100. Biblio e Links smart data now. • RDF Primer, http://www.w3.org/TR/rdf-primer/ • RDFa Primer, http://www.w3.org/TR/xhtml-rdfa-primer/ • RDF/JSON specification, http://docs.api.talis.com/platform-api/output-types/rdf-json • Tom Heath, Christian Bizer, Linked Data: Evolving the Web into a Global Data Space, http://linkeddatabook.com • Tim Berners Lee, Linked Data design issues, http://www.w3.org/DesignIssues/LinkedData.html • Dereferencing HTTP URIs, http://www.w3.org/2001/tag/doc/httpRange-14/2007-05-31/HttpRange-14 • Leo Sauermann and Richard Cyganiak. Cool uris for the semantic web, http://www.w3.org/TR/cooluris/ • Dean Allemang, Jim Handler, Semantic Web for the Working Ontologiest, http://workingontologist.org/ • A Direct Mapping of Relational Data to RDF, http://www.w3.org/TR/rdb-direct-mapping/ • R2RML: RDB to RDF Mapping Language, http://www.w3.org/TR/r2rml/ • D2RQ, http://d2rq.org/ • A Comparison of RDB-to-RDF Mapping Languages, http://www.ifi.uzh.ch/pax/uploads/pdf/publication/1830/paper.pdf • SPARQL 1.0, http://www.w3.org/TR/rdf-sparql-query/ • SPARQL 1.1, http://www.w3.org/TR/sparql11-query/ • SPARQL by examples (Tutorial), http://www.cambridgesemantics.com/2008/09/sparql-by-example • RFC 2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html • Harry Halpin, Patrick J. Haye, When owl:sameAs isn’t the Same: An Analysis of Identity Links on the Semantic Web, http://events.linkeddata.org/ldow2010/papers/ ldow2010_paper09.pdf • HTML/ChangeProposal25, http://www.w3.org/wiki/HTML/ChangeProposal25 • Semantic Sitemap specs, http://sw.deri.org/2007/07/sitemapextension/ • Guide to VoID (Vocabulary of Interlinked Datasets), http://vocab.deri.ie/void/guide 81 giovedì 29 marzo 12