Chris@0
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
Chris@0
|
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
Chris@0
|
3 <head>
|
Chris@0
|
4 <link rel="meta" type="application/rdf+xml" title="FOAF" href="http://moustaki.org/foaf.rdf#moustaki" />
|
Chris@0
|
5 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
|
Chris@0
|
6 <meta name="author" content="Yves Raimond" />
|
Chris@0
|
7 <link href="style.css" rel="stylesheet" type="text/css" /><meta name="robots" content="all" />
|
Chris@0
|
8 <title>/programmes SPARQL examples</title>
|
Chris@0
|
9 </head>
|
Chris@0
|
10 <body><div class="page">
|
Chris@0
|
11 <h1>SPARQL examples for /programmes</h1>
|
Chris@0
|
12
|
Chris@0
|
13 <h2>Introduction</h2>
|
Chris@0
|
14 <p>This document gives a mapping from <a href="http://bbc.co.uk/programmes/">BBC /programmes</a> URLs to
|
Chris@0
|
15 corresponding SPARQL queries on the <a href=http://dbtune.org/bbc/programmes/">/programmes SPARQL end-point</a>.</p>
|
Chris@0
|
16
|
Chris@0
|
17 <p><b>Note: to be tested in a nice environment (and not get raw xml back), these queries can be copy/pasted
|
Chris@0
|
18 in the SNORQL service set up at <a href="http://dbtune.org/bbc/programmes/snorql/">http://dbtune.org/bbc/programmes/snorql/</a></b></p>
|
Chris@0
|
19
|
Chris@0
|
20 <h3>Queries related to genres (/programmes/genres):</h3>
|
Chris@0
|
21 <p><i>Lists</i> all items in the <b>po:Genre</b> scheme:</p>
|
Chris@0
|
22 <pre>
|
Chris@0
|
23 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
24 PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
Chris@0
|
25 CONSTRUCT {?genre a skos:Concept}
|
Chris@0
|
26 WHERE {?genre skos:inScheme po:Genre}
|
Chris@0
|
27 </pre>
|
Chris@0
|
28 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20PREFIX%20skos%3A%20%3Chttp%3A//www.w3.org/2004/02/skos/core%23%3E%20construct%20%7B%3Fgenre%20a%20skos%3AConcept%7D%20where%20%7B%3Fgenre%20skos%3AinScheme%20po%3AGenre%7D">getting this URI</a>.</p>
|
Chris@0
|
29 <hr/>
|
Chris@0
|
30 <p><i>Describes</i> all items in the <b>po:Genre</b> scheme:</p>
|
Chris@0
|
31 <pre>
|
Chris@0
|
32 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
33 PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
Chris@0
|
34 CONSTRUCT {?genre ?p ?o}
|
Chris@0
|
35 WHERE {?genre skos:inScheme po:Genre;?p ?o}
|
Chris@0
|
36 </pre>
|
Chris@0
|
37 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20PREFIX%20skos%3A%20%3Chttp%3A//www.w3.org/2004/02/skos/core%23%3E%20construct%20%7B%3Fgenre%20%3Fb%20%3Fc%7D%20where%20%7B%3Fgenre%20skos%3AinScheme%20po%3AGenre%3B%3Fb%20%3Fc%7D">getting this URI</a>.</p>
|
Chris@0
|
38 <hr/>
|
Chris@0
|
39 <p><i>Describes</i> the genre identified by <i>http://www.bbc.co.uk/programmes/genres/childrens</i>:</p>
|
Chris@0
|
40 <pre>
|
Chris@0
|
41 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
Chris@0
|
42 CONSTRUCT {?genre ?p ?o}
|
Chris@0
|
43 WHERE
|
Chris@0
|
44 {?genre foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>;?p ?o}
|
Chris@0
|
45 </pre>
|
Chris@0
|
46 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%20CONSTRUCT%20%7B%3Fgenre%20%3Fp%20%3Fo%7D%20WHERE%20%7B%3Fgenre%20foaf%3Ahomepage%20%3Chttp%3A//www.bbc.co.uk/programmes/genres/childrens%3E%3B%3Fp%20%3Fo%7D">getting this URI</a>.</p>
|
Chris@0
|
47 <hr/>
|
Chris@0
|
48 <p><i>Lists</i> all episodes associated to a particular genre, identified by <i>http://www.bbc.co.uk/programmes/genres/childrens</i></p>
|
Chris@0
|
49 <pre>
|
Chris@0
|
50 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
51 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
Chris@0
|
52 CONSTRUCT {?episode po:genre ?genre}
|
Chris@0
|
53 WHERE
|
Chris@0
|
54 {?genre foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>. ?version po:genre ?genre. ?episode po:version ?version}
|
Chris@0
|
55 </pre>
|
Chris@0
|
56 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20PREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%20CONSTRUCT%20%7B%3Fepisode%20po%3Agenre%20%3Fgenre%7D%20WHERE%20%7B%3Fgenre%20foaf%3Ahomepage%20%3Chttp%3A//www.bbc.co.uk/programmes/genres/childrens%3E.%20%3Fversion%20po%3Agenre%20%3Fgenre.%20%3Fepisode%20po%3Aversion%20%3Fversion%7D">getting this URI</a>.</p>
|
Chris@0
|
57 <hr/>
|
Chris@0
|
58 <p><i>Lists</i> all episodes associated to two genres:</p>
|
Chris@0
|
59 <pre>
|
Chris@0
|
60 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
61 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
Chris@0
|
62 CONSTRUCT {?episode po:genre ?genre1; po:genre ?genre2}
|
Chris@0
|
63 WHERE
|
Chris@0
|
64 {
|
Chris@0
|
65 ?genre1 foaf:homepage <http://www.bbc.co.uk/programmes/genres/childrens>.
|
Chris@0
|
66 ?genre2 foaf:homepage <http://www.bbc.co.uk/programmes/genres/factual>.
|
Chris@0
|
67 ?version po:genre ?genre1, ?genre2.
|
Chris@0
|
68 ?episode po:version ?version
|
Chris@0
|
69 }
|
Chris@0
|
70 </pre>
|
Chris@0
|
71 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20PREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%20CONSTRUCT%20%7B%3Fepisode%20po%3Agenre%20%3Fgenre1%3B%20po%3Agenre%20%3Fgenre2%7D%20WHERE%20%7B%3Fgenre1%20foaf%3Ahomepage%20%3Chttp%3A//www.bbc.co.uk/programmes/genres/childrens%3E.%20%3Fgenre2%20foaf%3Ahomepage%20%3Chttp%3A//www.bbc.co.uk/programmes/genres/factual%3E.%20%3Fversion%20po%3Agenre%20%3Fgenre1%2C%20%3Fgenre2.%20%3Fepisode%20po%3Aversion%20%3Fversion%7D">getting this URI</a>.</p>
|
Chris@0
|
72 <hr/>
|
Chris@0
|
73 <h3>Queries related to formats (/programmes/formats):</h3>
|
Chris@0
|
74 <p><i>Lists</i> all formats</p>
|
Chris@0
|
75 <pre>
|
Chris@0
|
76 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
77 DESCRIBE po:format
|
Chris@0
|
78 </pre>
|
Chris@0
|
79 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20DESCRIBE%20po%3Aformat">getting this URI</a></p>
|
Chris@0
|
80
|
Chris@0
|
81 <hr/>
|
Chris@0
|
82 <p><i>Lists</i> all episodes in a particular format</p>
|
Chris@0
|
83 <pre>
|
Chris@0
|
84 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
85 CONSTRUCT {?episode po:format <http://dbtune.org/bbc/programmes/resource/format/18>}
|
Chris@0
|
86 WHERE
|
Chris@0
|
87 {?episode po:version ?version. ?version po:format <http://dbtune.org/bbc/programmes/resource/format/18>}
|
Chris@0
|
88 </pre>
|
Chris@0
|
89 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20CONSTRUCT%20%7B%3Fepisode%20po%3Aformat%20%3Chttp%3A//dbtune.org/bbc/programmes/resource/format/18%3E%7D%20WHERE%20%7B%3Fepisode%20po%3Aversion%20%3Fversion.%20%3Fversion%20po%3Aformat%20%3Chttp%3A//dbtune.org/bbc/programmes/resource/format/18%3E%7D">getting this URI</a>.</p>
|
Chris@0
|
90 <hr/>
|
Chris@0
|
91
|
Chris@0
|
92 <h3>Broadcast time queries</h3>
|
Chris@0
|
93 <p>Every title of every episode broadcasted after the 22nd of November 2007, 12:35:</p>
|
Chris@0
|
94 <pre>
|
Chris@0
|
95 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
96 PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
Chris@0
|
97 PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>
|
Chris@0
|
98 PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
|
Chris@0
|
99 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
Chris@0
|
100 SELECT ?title ?start ?end WHERE {
|
Chris@0
|
101 ?ep dc:title ?title.
|
Chris@0
|
102 ?ep po:version ?v.
|
Chris@0
|
103 ?bc po:broadcast_of ?v.
|
Chris@0
|
104 ?bc event:time ?t.
|
Chris@0
|
105 ?t tl:start ?start.
|
Chris@0
|
106 ?t tl:end ?end.
|
Chris@0
|
107 FILTER (?start > "2007-10-22T12:35:00Z"^^xsd:dateTime)
|
Chris@0
|
108 }
|
Chris@0
|
109 </pre>
|
Chris@0
|
110 <p><b>Note that results are truncated due to a LIMIT parameter on the server.</b> The query first retrieves all
|
Chris@0
|
111 broadcasts (this is limited to the first 2000 results) <b>and then</b> the results are truncated according to the
|
Chris@0
|
112 FILTER condition</p>
|
Chris@0
|
113 <hr/>
|
Chris@0
|
114 <p>Every broadcast time of episodes of a particular brand (here, <i>How I Met Your Mother</i>)</p>
|
Chris@0
|
115 <pre>
|
Chris@0
|
116 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
117 PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
|
Chris@0
|
118 DESCRIBE ?bct
|
Chris@0
|
119 WHERE
|
Chris@0
|
120 {
|
Chris@0
|
121 <http://dbtune.org/bbc/programmes/resource/brand/906> po:episode ?ep.
|
Chris@0
|
122 ?ep po:version ?v.
|
Chris@0
|
123 ?bc po:broadcast_of ?v.
|
Chris@0
|
124 ?bc event:time ?bct.
|
Chris@0
|
125 }
|
Chris@0
|
126 </pre>
|
Chris@0
|
127 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20PREFIX%20event%3A%20%3Chttp%3A//purl.org/NET/c4dm/event.owl%23%3E%20DESCRIBE%20%3Fbct%20WHERE%20%7B%3Chttp%3A//dbtune.org/bbc/programmes/resource/brand/906%3E%20po%3Aepisode%20%3Fep.%20%3Fep%20po%3Aversion%20%3Fv.%20%3Fbc%20po%3Abroadcast_of%20%3Fv.%20%3Fbc%20event%3Atime%20%3Fbct.%7D%0A">getting this URI</a>.</p>
|
Chris@0
|
128
|
Chris@0
|
129
|
Chris@0
|
130 <h3>Recommendation queries</h3>
|
Chris@0
|
131 <p>From a seed episode, <i>http://dbtune.org/bbc/programmes/resource/episode/1001</i>, give me all relevant episodes (shared tags)</p>
|
Chris@0
|
132 <pre>
|
Chris@0
|
133 PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>
|
Chris@0
|
134 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
135 SELECT ?recommended
|
Chris@0
|
136 WHERE {
|
Chris@0
|
137 <http://dbtune.org/bbc/programmes/resource/episode/40657> tags:tag ?seedtagging.
|
Chris@0
|
138 ?seedtagging tags:associatedTag ?seedtag.
|
Chris@0
|
139 ?recommended tags:tag ?tagging.
|
Chris@0
|
140 ?tagging tags:associatedTag ?seedtag
|
Chris@0
|
141 }
|
Chris@0
|
142 </pre>
|
Chris@0
|
143 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20tags%3A%20%3Chttp%3A//www.holygoat.co.uk/owl/redwood/0.1/tags/%3E%20PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20SELECT%20%3Frecommended%20WHERE%20%7B%3Chttp%3A//dbtune.org/bbc/programmes/resource/episode/40657%3E%20tags%3Atag%20%3Fseedtagging.%20%3Fseedtagging%20tags%3AassociatedTag%20%3Fseedtag.%20%3Frecommended%20tags%3Atag%20%3Ftagging.%20%3Ftagging%20tags%3AassociatedTag%20%3Fseedtag%7D">getting this URI</a>.</p>
|
Chris@0
|
144 <p>Same things, but with the /programmes homepage, and the name of the tag being shared:</p>
|
Chris@0
|
145 <pre>
|
Chris@0
|
146 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
Chris@0
|
147 PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
Chris@0
|
148 PREFIX tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>
|
Chris@0
|
149 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
150 SELECT ?recprog ?title
|
Chris@0
|
151 WHERE {
|
Chris@0
|
152 <http://dbtune.org/bbc/programmes/resource/episode/40657> tags:tag ?seedtagging.
|
Chris@0
|
153 ?seedtagging tags:associatedTag ?seedtag.
|
Chris@0
|
154 ?seedtag dc:title ?title.
|
Chris@0
|
155 ?recommendedep tags:tag ?tagging.
|
Chris@0
|
156 ?recommendedep foaf:homepage ?recprog.
|
Chris@0
|
157 ?tagging tags:associatedTag ?seedtag
|
Chris@0
|
158 }
|
Chris@0
|
159 </pre>
|
Chris@0
|
160 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%20PREFIX%20dc%3A%20%3Chttp%3A//purl.org/dc/elements/1.1/%3E%20PREFIX%20tags%3A%20%3Chttp%3A//www.holygoat.co.uk/owl/redwood/0.1/tags/%3E%20PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20SELECT%20%3Frecprog%20%3Ftitle%20WHERE%20%7B%3Chttp%3A//dbtune.org/bbc/programmes/resource/episode/40657%3E%20tags%3Atag%20%3Fseedtagging.%20%3Fseedtagging%20tags%3AassociatedTag%20%3Fseedtag.%3Fseedtag%20dc%3Atitle%20%3Ftitle.%3Frecommendedep%20tags%3Atag%20%3Ftagging.%20%3Frecommendedep%20foaf%3Ahomepage%20%3Frecprog.%3Ftagging%20tags%3AassociatedTag%20%3Fseedtag%7D">getting this URI</a>.</p>
|
Chris@0
|
161 <hr/>
|
Chris@0
|
162 <p>Give me episodes from the same genre as a particular one, with a broadcast time after the 22nd of November, 2007</p>
|
Chris@0
|
163 <pre>
|
Chris@0
|
164 PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
Chris@0
|
165 PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
Chris@0
|
166 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
167 PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>
|
Chris@0
|
168 PREFIX event: <http://purl.org/NET/c4dm/event.owl#>
|
Chris@0
|
169 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
Chris@0
|
170 SELECT ?ep ?title ?start
|
Chris@0
|
171 WHERE {
|
Chris@0
|
172 <http://dbtune.org/bbc/programmes/resource/episode/40657> po:version ?seedversion.
|
Chris@0
|
173 ?seedversion po:genre ?genre.
|
Chris@0
|
174 ?version po:genre ?genre.
|
Chris@0
|
175 ?recprog po:version ?version.
|
Chris@0
|
176 ?recprog dc:title ?title.
|
Chris@0
|
177 ?recprog foaf:homepage ?ep.
|
Chris@0
|
178 ?bc po:broadcast_of ?version.
|
Chris@0
|
179 ?bc event:time ?t.
|
Chris@0
|
180 ?t tl:start ?start.
|
Chris@0
|
181 FILTER (?start > "2007-11-22T12:00:00Z"^^xsd:dateTime)
|
Chris@0
|
182 }
|
Chris@0
|
183 </pre>
|
Chris@0
|
184 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%0APREFIX%20dc%3A%20%3Chttp%3A//purl.org/dc/elements/1.1/%3E%0APREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%0APREFIX%20tl%3A%20%3Chttp%3A//purl.org/NET/c4dm/timeline.owl%23%3E%0APREFIX%20event%3A%20%3Chttp%3A//purl.org/NET/c4dm/event.owl%23%3E%0APREFIX%20xsd%3A%20%3Chttp%3A//www.w3.org/2001/XMLSchema%23%3E%0ASELECT%20%3Fep%20%3Ftitle%20%3Fstart%0AWHERE%20%7B%0A%3Chttp%3A//dbtune.org/bbc/programmes/resource/episode/40657%3E%20po%3Aversion%20%3Fseedversion.%0A%3Fseedversion%20po%3Agenre%20%3Fgenre.%0A%3Fversion%20po%3Agenre%20%3Fgenre.%0A%3Frecprog%20po%3Aversion%20%3Fversion.%0A%3Frecprog%20dc%3Atitle%20%3Ftitle.%0A%3Frecprog%20foaf%3Ahomepage%20%3Fep.%0A%3Fbc%20po%3Abroadcast_of%20%3Fversion.%0A%3Fbc%20event%3Atime%20%3Ft.%0A%3Ft%20tl%3Astart%20%3Fstart.%0AFILTER%20%28%3Fstart%20%3E%20%222007-11-22T12%3A00%3A00Z%22%5E%5Exsd%3AdateTime%29%0A%7D">getting this URI</a>.</p>
|
Chris@0
|
185 <hr/>
|
Chris@0
|
186 <p>Pairs of different brands starring a similar actor (using DBPedia)</p>
|
Chris@0
|
187 <pre>
|
Chris@0
|
188 select ?brand1 ?brand2 ?person
|
Chris@0
|
189 where {
|
Chris@0
|
190 ?brand1 p:starring ?person.
|
Chris@0
|
191 ?brand2 p:starring ?person.
|
Chris@0
|
192 FILTER (?brand1 != ?brand2)
|
Chris@0
|
193 }
|
Chris@0
|
194 </pre>
|
Chris@0
|
195 <hr/>
|
Chris@0
|
196 <h3>Other</h3>
|
Chris@0
|
197 <p>Mention all locations associated to known services</p>
|
Chris@0
|
198 <pre>
|
Chris@0
|
199 PREFIX po: <http://purl.org/ontology/po/>
|
Chris@0
|
200 DESCRIBE ?geo
|
Chris@0
|
201 WHERE
|
Chris@0
|
202 {
|
Chris@0
|
203 ?service a po:Service; po:location ?geo
|
Chris@0
|
204 }
|
Chris@0
|
205 </pre>
|
Chris@0
|
206 <p>Results available by <a href="http://dbtune.org/bbc/programmes/sparql?query=PREFIX%20po%3A%20%3Chttp%3A//purl.org/ontology/po/%3E%20DESCRIBE%20%3Fgeo%20WHERE%20%7B%3Fservice%20a%20po%3AService%3Bpo%3Alocation%20%3Fgeo%7D%0A">getting this URI</a>.</p>
|
Chris@0
|
207 <hr/>
|
Chris@0
|
208 </body>
|
Chris@0
|
209 </html>
|