Interroger le Web de données

Interroger le Web de données

UDOS - 30 juin 2017

Pierre-Antoine Champin (UCBL/LIRIS)

http://champin.net/2017/udos

Web de données

Qu'est-ce que le Web?

Un espace documentaire

  • décentralisé (HTTP)
  • interconnecté (URL)
  • interopérable (HTML)

Qu'est-ce que le Web?

Un espace documentaire

  • décentralisé (HTTP 2014, HTTP 2.0)
  • interconnecté (URL, URI, IRI)
  • interopérable (HTML5, CSS, JS)

Limites

Combien de scientifiques n’ont jamais reçu de prix Nobel personnellement, mais ont “produit” au moins trois prix Nobel différents par étudiant interposé ?

Vers un Web de données

Un espace de données

  • décentralisé (HTTP)
  • interconnecté (URL)
  • interopérable (?)
_images/lod-cloud_colored.svg

Vers un Web de données

Un espace de données

  • décentralisé (HTTP)
  • interconnecté (URL)
  • interopérable (RDF)
_images/Le-bourgeois-gentilhomme.jpg

RDF

_images/data_model1.svg
_images/data_model2.svg
_images/data_model3.svg

Vocabulaire / Ontologie

  • Ensemble d’IRIs décrivant
    • les catégories du domaine (classes)
    • les propriétés (attributs, relations)
    • les objets du domain

SPARQL

Principe

Décrire les relations entre les données que l’on cherche sous forme d’un sous-graphe.

digraph exemple1 { udos [label="udos"] i [label="?i"] n [label="?n" fillcolor=lightblue] a [label="?a" fillcolor=lightblue] i -> udos [label="intervient"] i -> n [label="nom"] i -> a [label="adresse"] }

digraph exemple2 { pa [label="pa.champin"] k [label="?k"] c [label="?c"] n [label="?n" fillcolor=lightblue] pa -> k [label="connais"] c -> k [label="fondateur"] c -> n [label="siren"] }

Préfixes

PREFIX s: <http://schema.org/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
# ...

s:Event<http://schema.org/Event>

s:startDate<http://schema.org/startDate>

s:endDate<http://schema.org/endDate>

owl:sameAs<http://www.w3.org/2002/07/owl#sameAs>

...

Termes

s:Event IRI abrégé
<http://example.org/> IRI complet
"hello world" Litéral chaîne
42   3.14   1e-10 Litéraux numérique
?x Variable

Triplet

Chaque arc du graphe est représenté par un triplet :

<http://champin.net/#pa> rdf:type s:Person .

digraph triplet { s[label="http://champin.net/#pa"] o[label="s:Person"] s->o[label="rdf:type"] }

Graphe

Le graphe requête est l’union des arcs.

<http://champin.net/#pa> rdf:type s:Person .
<http://champin.net/#pa> foaf:knows ?x .
?x foaf:surname "Zigmann" .

digraph graphe { person[label="s:Person"] me[label="http://champin.net/#pa"] x[label="?x"] zigmann[label="\"Zigmann\"" shape=rect] me -> person [label="rdf:type"] me -> x [label="foaf:knows"] x -> zigmann [label="foaf:surname"] }

Factorisation (1)

Même sujet :

<http://champin.net/#pa>
    rdf:type s:Person ;
    foaf:knows ?x .

digraph factorisation1 { person[label="s:Person"] me[label="http://champin.net/#pa"] x[label="?x"] me -> person [label="rdf:type"] me -> x [label="foaf:knows"] }

Factorisation (2)

Même sujet et même prédicat :

<http://champin.net/#pa> foaf:knows ?x, ?y .

digraph factorisation2 { me[label="http://champin.net/#pa"] x[label="?x"] y[label="?y"] me -> x [label="foaf:knows"] me -> y [label="foaf:knows"] }

Sous-graphe optionnel

<http://champin.net/#pa> foaf:knows ?x.
OPTIONAL { ?x schema:address ?addr }

digraph optional { "http://champin.net/#pa" -> "?x" [label="foaf:knows"] "?x" -> "?addr" [label="schema:address",style=dotted] "?addr"[style=dotted] }

par opposition à

<http://champin.net/#pa> foaf:knows ?x.
?x schema:address ?addr .

digraph non_optional { "http://champin.net/#pa" -> "?x" [label="foaf:knows"] "?x" -> "?addr" [label="schema:address"] }

Filtres

<http://champin.net/#pa> foaf:knows ?x.
?x s:birthDate ?bd.
FILTER ( STR(?bd) > "1999-06" )

Sélection

SELECT ?p ?n {
   <http://champin.net/#pa> foaf:knows ?x .
    ?x foaf:givenName ?p ;
       foaf:suename ?n ;
       foaf:age ?a .

    FILTER (?a >= 18)
}

digraph factorisation1 { filter1 [label="?a >= 18" shape=note] me[label="http://champin.net/#pa"] x[label="?x"] p[label="?p" fillcolor=lightblue] n[label="?n" fillcolor=lightblue] a[label="?a"] me -> x [label="foaf:knows"] x -> p [label="foaf:givenName"] x -> n [label="foaf:surname"] x -> a [label="foaf:age"] }

À vous de jouer

http://champin.net/2017/udos/tuto

Pour aller plus loin

Trouver des sources de données

Yasgui, fonctions avancées

  • représentations graphiques
  • tableau croisé

Requêtes fédérées

# (... déclarations de préfixe ...)
SELECT ?s {
  [] a nobel:NobelPrize ;
     nobel:category cat:Physics ;
     nobel:year 1965 ;
     nobel:laureate ?l .
  ?l foaf:name ?name ; owl:sameAs ?iri .

  SERVICE <http://dbpedia.org/sparql> {
    ?iri dbo:doctoralStudent ?s .
  }
}

<http://yasgui.org/short/r1S4PLfE->

Linked Data Fragments

http://linkeddatafragments.org/

_images/ldf.svg

RDB 2 RDF

Choisir un vocabulaire

http://lov.okfn.org/

Merci