Linked Data Examples

Sparql

Our sparql endpoint can be used to query our dataset. You can easily test different queries. Below are some examples of queries that can be done.

The first query will list all Nobel Laureates in 1901:

PREFIX nobel: <http://data.nobelprize.org/terms/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?name ?prizeName WHERE {
?person rdf:type nobel:Laureate;
rdfs:label ?name;
nobel:nobelPrize ?prize.
?prize rdfs:label ?prizeName;
nobel:year ?year.
FILTER (lang(?prizeName) = 'en' && ?year = 1901) }

Result:

“name”,”prizeName”
“Wilhelm Conrad Röntgen”,”The Nobel Prize in Physics 1901″
“Sully Prudhomme”,”The Nobel Prize in Literature 1901″
“Jean Henry Dunant”,”The Nobel Peace Prize 1901″
“Frédéric Passy”,”The Nobel Peace Prize 1901″
“Emil Adolf von Behring”,”The Nobel Prize in Physiology or Medicine 1901″
“Jacobus Henricus van ‘t Hoff”,”The Nobel Prize in Chemistry 1901″


The query below will list all female Nobel Laureates in Physics:

PREFIX nobel: <http://data.nobelprize.org/terms/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?name ?prizeName WHERE {
?person rdf:type nobel:Laureate;
rdfs:label ?name;
foaf:gender ?gender;
nobel:nobelPrize ?prize.
?prize rdfs:label ?prizeName;
nobel:category ?category.
FILTER (lang(?prizeName) = 'en' && ?gender = 'female' && ?category = nobel:Physics ) }

Result:

“name”,”prizeName”
“Donna Strickland”,”The Nobel Prize in Physics 2018″
“Andrea Ghez”,”The Nobel Prize in Physics 2020″
“Marie Curie, née Sklodowska”,”The Nobel Prize in Physics 1903″
“Maria Goeppert Mayer”,”The Nobel Prize in Physics 1963″


Since our dataset is linked to other datasets, it’s possible to query several datasets at the same time. Below is an example that combines the Nobelprize dataset with DBPedia. It will list the all Nobel Prize Laureates in the Nobelprize dataset that are born in countries smaller than a certain area according to DBPedia.

PREFIX dbpo: <http://dbpedia.org/ontology/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX nobel: <http://data.nobelprize.org/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX owl: <http://www.w3.org/2002/07/owl#> 
SELECT DISTINCT ?label ?country 
WHERE { 
  ?laur rdf:type nobel:Laureate . 
  ?laur rdfs:label ?label . 
  ?laur dbpo:birthPlace ?country . 
  ?country rdf:type dbpo:Country . 
  ?country owl:sameAs ?dbp . 
  SERVICE <http://dbpedia.org/sparql> { 
    ?dbp dbpo:areaTotal ?area . 
    FILTER (?area < 10000000000) 
  } 
}

The result:

label country
“Derek Walcott” <http://data.nobelprize.org/resource/country/Saint_Lucia> [http]
“Jules A. Hoffmann” <http://data.nobelprize.org/resource/country/Luxembourg> [http]
“Sir Vidiadhar Surajprasad Naipaul” <http://data.nobelprize.org/resource/country/Trinidad> [http]
“Christopher A. Pissarides” <http://data.nobelprize.org/resource/country/Cyprus> [http]
“Gabriel Lippmann” <http://data.nobelprize.org/resource/country/Luxembourg> [http]

Note that in order for this to work, the dbpedia spaql endpoint has to be responsive, else an error message will be displayed.

 

Performing a sparql query from php

<?php
$query = "
PREFIX nobel: <http://data.nobelprize.org/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?label
     WHERE {
     ?laur rdf:type nobel:Laureate .
     ?laur rdfs:label ?label .
     ?laur foaf:gender 'female' .
     ?laur nobel:laureateAward ?award .
     ?award nobel:category <http://data.nobelprize.org/resource/category/Physics> .
 }";
$url = 'http://data.nobelprize.org/sparql?query='.urlencode($query).'&format=json';
     
# Fetch the data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
$string = curl_exec($ch);
curl_close($ch);
$result = json_decode($string, true);
var_dump($result);
?>

 

 

Fetching an RDF file

 
<?php
# URL of the RDF file I want to fetch
$rdfurl = 'http://data.nobelprize.org/resource/laureate/1';
# Base URL of the linked data cache
# See http://entrystore.org/ldcache/ for more information
$url = 'http://data.nobelprize.org/ldc/';
# Add the url of the RDF file
$url = $url.'?url='.$rdfurl;
# Ask for json format from the linked data cache
$url = $url.'&format=application/rdf+json';
# Fetch the data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
$string = curl_exec($ch);
curl_close($ch);
$result = json_decode($string, true);
var_dump($result);

?>

 

To cite this section
MLA style: Linked Data Examples. NobelPrize.org. Nobel Prize Outreach AB 2024. Sat. 21 Dec 2024. <https://www.nobelprize.org/organization/linked-data-examples/>