https://en.wikipedia.org/wiki/List_of_astronomers
https://en.wikipedia.org/wiki/Giovanni_Domenico_Cassini
https://dbpedia.org/page/Giovanni_Domenico_Cassini
Les informations qui figurent sur cette page sont extraites de Wikipedia et produites sous forme de données structurées selon le protocole RDF. En d’autres termes, si la page apparaît comme étant du texte, en réalité elle présente, et rend lisibles, les données structurées du graphe concernant cette personne.
On peut donc les interroger et les récupérer grâce à des requêtes formulées dans le langage SPARQL.
Il s’agit d’abord d’inspecter la page et relever les informations intéressantes qui sont disponibles. RDF fonctionne sur un modèle “sujet -> prédicat-> objet” qui constitue les triplets.
Le sujet de la page est le sujet de tous les triplets (dans ce cas la personne). Les prédicats sont exprimés sous forme de propriétés (_properties_ en anglais)
Exemples de propriétés:
À noter (parmi d’autres entités):
dbr: est le préfixe qui remplace http://dbpedia.org/resource/. En entier la première entrée donne http://dbpedia.org/resource/List_of_astrologers.
dbr:List_of_astrologers est donc un QName
Présentation de DBPedia dans Wikipedia: https://en.wikipedia.org/wiki/DBpedia
Documentation:
Modifier Wikipedia et voir les résultats en temps réel
SPARQLIS permet de construire des requêtes SPARQL grâce à une interface graphique
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?thing_1 ?birthDate
WHERE { ?thing_1 dbo:occupation dbr:Astronomer .
OPTIONAL {
?thing_1 dbo:birthYear ?birthDate .
}
}
Cette requête liste 160 astronomes (3 décembre 2022), le maximum des effectifs avec cette approche
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT (COUNT(*) as ?effectif)
WHERE { ?thing_1 dbo:occupation dbr:Astronomer .
}
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT DISTINCT ?thing_1 ?intYear
WHERE { ?thing_1 dbo:occupation dbr:Astronomer .
?thing_1 dbo:birthYear ?birthYear .
BIND(xsd:integer(str(?birthYear)) AS ?intYear)
FILTER ( (?intYear >= 1371
### La clause de filtre ci-dessous est commentée, i.e. non active. Décommenter pour l'activer
# && ?intYear < 1771
) ) }
ORDER BY ?intYear
Leur effectif (3 décembre 2022): 23 / 124
La requête ci-dessous ne change rien, en espace de noms dbr seulement 13 astronomes
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT (COUNT(*) as ?effectif)
WHERE {
{SELECT DISTINCT ?thing_1
WHERE {
{ ?thing_1 dbo:occupation dbr:Astronomer }
UNION
{?thing_1 dbp:occupation dbr:Astronomer}
}
}
?thing_1 dbo:birthYear ?birthYear .
BIND(xsd:integer(str(?birthYear)) AS ?intYear)
FILTER ( (?intYear >= 1371
# && ?intYear < 1771
) ) }
ORDER BY ?intYear
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?p ?o1
WHERE {
dbr:List_of_astronomers ?p ?o1.
?o1 a dbo:Person.
}
LIMIT 10
Effectifs au 3 décembre 2022 : 762
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT (COUNT(*) as ?eff)
WHERE {
dbr:List_of_astronomers ?p ?o1.
?o1 a dbo:Person.
}
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?p1 (COUNT(*) as ?eff)
WHERE {
dbr:List_of_astronomers ?p ?o1.
?o1 a dbo:Person;
?p1 ?o2.
}
GROUP BY ?p1
ORDER BY DESC(?eff)
Noter ces propriétés:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT (COUNT(*) as ?eff)
WHERE {
dbr:List_of_astronomers ?p ?o1.
?o1 a dbo:Person;
dbp:birthDate ?birthDate.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
) )
}
Documentation: Property path syntax
| Alternative entre propriétés ( | ): |
Effectif: 56
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?o1 ?birthDate ?birthYear
WHERE {
dbr:List_of_astronomers ?p ?o1.
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
) )
}
ORDER BY ?birthYear
Astonomes et astrologues et mathématiciens:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?o1 ?birthDate ?birthYear
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
) )
}
ORDER BY ?birthYear
Effectif : 292 / 5138 mathématiciens, astrologues, astronomes
Définition de la population: cette requêtes définit la population — cette requête sera la base de toutes les autres
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT (COUNT(*) as ?effectif)
WHERE {
SELECT DISTINCT ?o1 ?birthDate ?birthYear
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
) )
}
}
Avec les labels des noms (en anglais), même effectif:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT (COUNT(*) as ?effectif)
WHERE {
SELECT DISTINCT ?o1 ?birthDate ?birthYear ?label
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
UNION
{?o1 ?p dbr:Physicist.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate;
rdfs:label ?label.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
)
&& LANG(?label) = 'en')
}
}
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?p1 (COUNT(*) as ?eff)
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
UNION
{?o1 ?p dbr:Physicist.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate;
?p1 ?o2.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371 ))
}
GROUP BY ?p1
ORDER BY DESC(?eff)
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?p1 (COUNT(*) as ?eff)
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
UNION
{?o1 ?p dbr:Physicist.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate.
?o2 ?p1 ?o1.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371 ))
}
GROUP BY ?p1
ORDER BY DESC(?eff)
Cette requête produit une liste de personnes.
Si on veut importer les données dans une base de données SQLite, suivre les instructions indiquées sur ces pages:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?o1 (str(?label) as ?name) ?birthYear
WHERE {
SELECT DISTINCT ?o1 ?birthDate ?birthYear ?label
WHERE {
{
{dbr:List_of_astronomers ?p ?o1.}
UNION
{dbr:List_of_astrologers ?p ?o1.}
UNION
{?o1 ?p dbr:Astrologer.}
UNION
{?o1 ?p dbr:Astronomer.}
UNION
{?o1 ?p dbr:Mathematician.}
UNION
{?o1 ?p dbr:Physicist.}
}
?o1 a dbo:Person;
dbp:birthDate | dbo:birthDate ?birthDate;
rdfs:label ?label.
BIND(xsd:integer(SUBSTR(STR(?birthDate), 1, 4)) AS ?birthYear)
FILTER ( (?birthYear >= 1371
# && ?birthYear < 1771
)
&& LANG(?label) = 'en')
}
}
ORDER BY ?birthYear