Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: /programmes SPARQL examples Chris@0: Chris@0:
Chris@0:

SPARQL examples for /programmes

Chris@0: Chris@0:

Introduction

Chris@0:

This document gives a mapping from BBC /programmes URLs to Chris@0: corresponding SPARQL queries on the /programmes SPARQL end-point.

Chris@0: Chris@0:

Note: to be tested in a nice environment (and not get raw xml back), these queries can be copy/pasted Chris@0: in the SNORQL service set up at http://dbtune.org/bbc/programmes/snorql/

Chris@0: Chris@0:

Queries related to genres (/programmes/genres):

Chris@0:

Lists all items in the po:Genre scheme:

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: PREFIX skos: <http://www.w3.org/2004/02/skos/core#> 
Chris@0: CONSTRUCT {?genre a skos:Concept} 
Chris@0: WHERE {?genre skos:inScheme po:Genre}
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Describes all items in the po:Genre scheme:

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
Chris@0: CONSTRUCT {?genre ?p ?o} 
Chris@0: WHERE {?genre skos:inScheme po:Genre;?p ?o}
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Describes the genre identified by http://www.bbc.co.uk/programmes/genres/childrens:

Chris@0:
Chris@0: PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
Chris@0: CONSTRUCT {?genre ?p ?o} 
Chris@0: WHERE 
Chris@0: {?genre foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>;?p ?o}
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Lists all episodes associated to a particular genre, identified by http://www.bbc.co.uk/programmes/genres/childrens

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
Chris@0: CONSTRUCT {?episode po:genre ?genre} 
Chris@0: WHERE 
Chris@0: {?genre foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>. ?version po:genre ?genre. ?episode po:version ?version}
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Lists all episodes associated to two genres:

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
Chris@0: CONSTRUCT {?episode po:genre ?genre1; po:genre ?genre2} 
Chris@0: WHERE 
Chris@0: {
Chris@0: 	?genre1 foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>. 
Chris@0: 	?genre2 foaf:homepage <http://www.bbc.co.uk/programmes/genres/factual>. 
Chris@0: 	?version po:genre ?genre1, ?genre2. 
Chris@0: 	?episode po:version ?version
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Queries related to formats (/programmes/formats):

Chris@0:

Lists all formats

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: DESCRIBE po:format
Chris@0: 
Chris@0:

Results available by getting this URI

Chris@0: Chris@0:
Chris@0:

Lists all episodes in a particular format

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: CONSTRUCT {?episode po:format <http://dbtune.org/bbc/programmes/resource/format/18>} 
Chris@0: WHERE 
Chris@0: {?episode po:version ?version. ?version po:format <http://dbtune.org/bbc/programmes/resource/format/18>}
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0: Chris@0:

Broadcast time queries

Chris@0:

Every title of every episode broadcasted after the 22nd of November 2007, 12:35:

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: PREFIX dc: <http://purl.org/dc/elements/1.1/>
Chris@0: PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>
Chris@0: PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
Chris@0: PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
Chris@0: SELECT ?title ?start ?end WHERE {
Chris@0: ?ep dc:title ?title.
Chris@0: ?ep po:version ?v.
Chris@0: ?bc po:broadcast_of ?v.
Chris@0: ?bc event:time ?t.
Chris@0: ?t tl:start ?start.
Chris@0: ?t tl:end ?end.
Chris@0: FILTER (?start > "2007-10-22T12:35:00Z"^^xsd:dateTime)
Chris@0: }
Chris@0: 
Chris@0:

Note that results are truncated due to a LIMIT parameter on the server. The query first retrieves all Chris@0: broadcasts (this is limited to the first 2000 results) and then the results are truncated according to the Chris@0: FILTER condition

Chris@0:
Chris@0:

Every broadcast time of episodes of a particular brand (here, How I Met Your Mother)

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
Chris@0: DESCRIBE ?bct
Chris@0: WHERE
Chris@0: {
Chris@0: <http://dbtune.org/bbc/programmes/resource/brand/906> po:episode ?ep.
Chris@0: ?ep po:version ?v.
Chris@0: ?bc po:broadcast_of ?v.
Chris@0: ?bc event:time ?bct.
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0: Chris@0: Chris@0:

Recommendation queries

Chris@0:

From a seed episode, http://dbtune.org/bbc/programmes/resource/episode/1001, give me all relevant episodes (shared tags)

Chris@0:
Chris@0: PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> 
Chris@0: PREFIX po: <http://purl.org/ontology/po/> 
Chris@0: SELECT ?recommended 
Chris@0: WHERE {
Chris@0: <http://dbtune.org/bbc/programmes/resource/episode/40657> tags:tag ?seedtagging. 
Chris@0: ?seedtagging tags:associatedTag ?seedtag. 
Chris@0: ?recommended tags:tag ?tagging. 
Chris@0: ?tagging tags:associatedTag ?seedtag
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:

Same things, but with the /programmes homepage, and the name of the tag being shared:

Chris@0:
Chris@0: PREFIX foaf: <http://xmlns.com/foaf/0.1/>
Chris@0: PREFIX dc: <http://purl.org/dc/elements/1.1/>
Chris@0: PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> 
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: SELECT ?recprog ?title
Chris@0: WHERE {
Chris@0: <http://dbtune.org/bbc/programmes/resource/episode/40657> tags:tag ?seedtagging. 
Chris@0: ?seedtagging tags:associatedTag ?seedtag. 
Chris@0: ?seedtag dc:title ?title.
Chris@0: ?recommendedep tags:tag ?tagging. 
Chris@0: ?recommendedep foaf:homepage ?recprog.
Chris@0: ?tagging tags:associatedTag ?seedtag
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Give me episodes from the same genre as a particular one, with a broadcast time after the 22nd of November, 2007

Chris@0:
Chris@0: PREFIX foaf: <http://xmlns.com/foaf/0.1/>
Chris@0: PREFIX dc: <http://purl.org/dc/elements/1.1/>
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>
Chris@0: PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
Chris@0: PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
Chris@0: SELECT ?ep ?title ?start
Chris@0: WHERE {
Chris@0: <http://dbtune.org/bbc/programmes/resource/episode/40657> po:version ?seedversion.
Chris@0: ?seedversion po:genre ?genre.
Chris@0: ?version po:genre ?genre.
Chris@0: ?recprog po:version ?version.
Chris@0: ?recprog dc:title ?title.
Chris@0: ?recprog foaf:homepage ?ep.
Chris@0: ?bc po:broadcast_of ?version.
Chris@0: ?bc event:time ?t.
Chris@0: ?t tl:start ?start.
Chris@0: FILTER (?start > "2007-11-22T12:00:00Z"^^xsd:dateTime)
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0:

Pairs of different brands starring a similar actor (using DBPedia)

Chris@0:
Chris@0: select ?brand1 ?brand2 ?person 
Chris@0: where {
Chris@0: ?brand1 p:starring ?person.
Chris@0: ?brand2 p:starring ?person.
Chris@0: FILTER (?brand1 != ?brand2)
Chris@0: }
Chris@0: 
Chris@0:
Chris@0:

Other

Chris@0:

Mention all locations associated to known services

Chris@0:
Chris@0: PREFIX po: <http://purl.org/ontology/po/>
Chris@0: DESCRIBE ?geo 
Chris@0: WHERE 
Chris@0: {
Chris@0: ?service a po:Service; po:location ?geo
Chris@0: }
Chris@0: 
Chris@0:

Results available by getting this URI.

Chris@0:
Chris@0: Chris@0: