13. “it gives me a headache just trying to think
down to your level”
image: io9.com
14. The Semantic Web
A new form of Web content that is meaningful to computers will unleash a
revolution of new possibilities
by TIM BERNERS-LEE, JAMES HENDLER and ORA LASSILA
Scientifc American, May 2001
http://www-sop.inria.fr/acacia/cours/essi2006/Scientific%20American_%20Feature%20Article_%20The%20Semantic%20Web_%20May%202001.pdf
15. 1. Use URIs to name (identify) things.
2. Use HTTP URIs so that these things can be looked up
(interpreted, "dereferenced").
3. Provide useful information about what a name identifies when it's
looked up, using open standards such as RDF, SPARQL, etc.
4. Refer to other things using their HTTP URI-based names when
publishing data on the Web.
47. Examples
All places of Ghent
SELECT ?Thing
WHERE { ?Thing a <http://schema.org/Place> }
result
48. Examples
All places of Ghent
SELECT ?Thing
WHERE { ?Thing a <http://schema.org/Place> } LIMIT 100
Using LIMIT
result
49. Examples
All districts of Ghent
SELECT DISTINCT ?Thing
WHERE {
?Thing a <http://schema.org/Place> .
?Thing <https://stad.gent/data/internal/resourceType>
"wijken"^^<http://www.w3.org/2001/XMLSchema#string> .
} LIMIT 100
result
50. Examples
All districts of Ghent
PREFIX schema: <http://schema.org/>
PREFIX gent: <https://stad.gent/data/internal/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?Thing
WHERE {
?Thing a schema:Place .
?Thing gent:resourceType "wijken"^^xsd:string .
} LIMIT 100
Using PREFIX
result
51. Examples
All districts of Ghent
PREFIX schema: <http://schema.org/>
PREFIX gent: <https://stad.gent/data/internal/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?Thing
WHERE {
?Thing a schema:Place .
?Thing gent:resourceType "wijken"^^xsd:string .
} LIMIT 100
Using DISTINCT
result
52. Examples
All districts of Ghent
PREFIX schema: <http://schema.org/>
PREFIX gent: <http://stad.gent/data/internal/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT count(DISTINCT ?Thing) as ?aantal
WHERE {
?Thing a schema:Place .
?Thing gent:resourceType "wijken"^^xsd:string .
}
Using COUNT
result
53. Examples
All districts of Ghent
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gent: <https://stad.gent/data/internal/>
SELECT DISTINCT ?place ?name
WHERE {
?place a schema:Place .
?place schema:name ?name .
?place gent:resourceType "wijken"^^xsd:string .
} LIMIT 100
By name
result
54. Examples
All news articles for district
“Sluizeken”
SELECT DISTINCT ?a WHERE {
?a a <http://schema.org/NewsArticle>.
?a <http://schema.org/contentLocation> <https://stad.gent/id/places/wijken--2> .
}
result
55. Examples
Products for ecological
companies:
PREFIX schema: <http://schema.org/>
PREFIX dct:<http://purl.org/dc/terms/>
SELECT ?product ?titel
WHERE {
?product a <http://purl.org/vocab/cpsv#PublicService>.
?product schema:audience <http://stad.gent/data/ns/gpdc/doelgroepen/onderneming>.
?product dct:subject <http://stad.gent/data/ns/themas/natuur-milieu>.
?product dct:title ?titel
}
result
56. Examples
Most popular books among men in Ledeberg in 2010
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX service: <http://purl.org/ontology/service#>
select ?book (sample(?name) as ?naam) (COUNT(?person) as ?aantal_personen)
FROM <http://stad.gent/dekrook/uitleningen-2010>
FROM <http://stad.gent/dekrook/exemplaren>
FROM <http://stad.gent/dekrook/werken>
WHERE {
?offer a schema:Offer.
?book schema:offers ?offer.
?book schema:name ?name.
?person a schema:Person;
service:consumes ?offer;
schema:gender "Mannelijk";
schema:address "9050".
} GROUP BY ?book ORDER BY DESC(?aantal_personen) LIMIT 10
result
60. SKOS: Example
Theme list
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT ?thema
WHERE {
?thema skos:inScheme <http://stad.gent/data/ns/themas/>
}
result
61. Examples
Recent news items related to
museums SMAK en Huis van Alijn
PREFIX schema:<http://schema.org/>
SELECT ?article ?titel ?published
WHERE {
VALUES ?org {
<https://stad.gent/id/agents/96677ab3-f689-e111-a140-0050569826fc>
<https://stad.gent/id/agents/ad7ccf21-61d8-e411-87b3-005056983224>
}.
?article a schema:NewsArticle.
?article schema:datePublished ?published.
?article <http://schema.org/sourceOrganization> ?org.
?article schema:headline ?titel
} ORDER BY DESC(?published) LIMIT 5
result
62. Examples
Hoeveel nieuwsberichten zijn er gepubliceerd in januari 2017?
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT (count(?sub) as ?articles) WHERE {
?sub a <http://schema.org/NewsArticle>;
schema:datePublished ?date.
BIND(YEAR(STRDT(?date, xsd:dateTime)) as ?year)
BIND(MONTH(STRDT(?date, xsd:dateTime)) as ?month)
FILTER(?year = 2017)
FILTER(?month = 1)
}
result
63. Examples
Uitleningen in maart 2017
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT count(?sub) from <http://stad.gent/dekrook> WHERE {
?sub a <http://purl.org/ontology/dso#Loan>.
?sub <http://schema.org/startDate> ?start.
?sub <http://purl.org/ontology/service#consumes> ?book.
FILTER ( STRDT(STR(?start),xsd:dateTime) < xsd:dateTime("2017-04-01T00:00:00Z") )
FILTER ( STRDT(STR(?start),xsd:dateTime) > xsd:dateTime("2017-03-01T00:00:00Z") )
}
result
64. Examples
De tien meest uitgeleende boeken
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
SELECT ?book (COUNT(?sub) as ?uitleningen) from <http://stad.gent/dekrook> WHERE {
?sub a <http://purl.org/ontology/dso#Loan>.
?sub <http://schema.org/startDate> ?start.
?sub <http://purl.org/ontology/service#consumes> ?offer.
?book schema:offers ?offer.
} GROUP BY ?book ORDER BY DESC(?uitleningen) LIMIT 10
result
65. Examples
Boeken gepubliceerd in 2001
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?sub ?date from <http://stad.gent/dekrook> WHERE {
?sub a <http://schema.org/Book> .
?sub <http://schema.org/datePublished> ?date.
filter(?date = "2001")
} limit 40
result