To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / onto / doc / sparql_mapping.html @ 0:1e44d666ced1

History | View | Annotate | Download (12.4 KB)

1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3
<head>
4
 <link rel="meta" type="application/rdf+xml" title="FOAF" href="http://moustaki.org/foaf.rdf#moustaki" />
5
 <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
 <meta name="author" content="Yves Raimond" />
7
 <link href="style.css" rel="stylesheet" type="text/css" /><meta name="robots" content="all" />
8
 <title>/programmes SPARQL examples</title>
9
</head>
10
<body><div class="page">
11
<h1>SPARQL examples for /programmes</h1>
12

    
13
<h2>Introduction</h2>
14
<p>This document gives a mapping from <a href="http://bbc.co.uk/programmes/">BBC /programmes</a> URLs to 
15
corresponding SPARQL queries on the <a href=http://dbtune.org/bbc/programmes/">/programmes SPARQL end-point</a>.</p>
16

    
17
<p><b>Note: to be tested in a nice environment (and not get raw xml back), these queries can be copy/pasted
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>
19

    
20
<h3>Queries related to genres (/programmes/genres):</h3>
21
<p><i>Lists</i> all items in the <b>po:Genre</b> scheme:</p>
22
<pre>
23
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
24
PREFIX skos: &lt;http://www.w3.org/2004/02/skos/core#&gt; 
25
CONSTRUCT {?genre a skos:Concept} 
26
WHERE {?genre skos:inScheme po:Genre}
27
</pre>
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>
29
<hr/>
30
<p><i>Describes</i> all items in the <b>po:Genre</b> scheme:</p>
31
<pre>
32
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
33
PREFIX skos: &lt;http://www.w3.org/2004/02/skos/core#&gt;
34
CONSTRUCT {?genre ?p ?o} 
35
WHERE {?genre skos:inScheme po:Genre;?p ?o}
36
</pre>
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>
38
<hr/>
39
<p><i>Describes</i> the genre identified by <i>http://www.bbc.co.uk/programmes/genres/childrens</i>:</p>
40
<pre>
41
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; 
42
CONSTRUCT {?genre ?p ?o} 
43
WHERE 
44
{?genre foaf:homepage &lt;http://www.bbc.co.uk/programmes/genres/childrens&gt;;?p ?o}
45
</pre>
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>
47
<hr/>
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>
49
<pre>
50
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
51
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; 
52
CONSTRUCT {?episode po:genre ?genre} 
53
WHERE 
54
{?genre foaf:homepage &lt;http://www.bbc.co.uk/programmes/genres/childrens&gt;. ?version po:genre ?genre. ?episode po:version ?version}
55
</pre>
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>
57
<hr/>
58
<p><i>Lists</i> all episodes associated to two genres:</p>
59
<pre>
60
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
61
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; 
62
CONSTRUCT {?episode po:genre ?genre1; po:genre ?genre2} 
63
WHERE 
64
{
65
        ?genre1 foaf:homepage &lt;http://www.bbc.co.uk/programmes/genres/childrens&gt;. 
66
        ?genre2 foaf:homepage &lt;http://www.bbc.co.uk/programmes/genres/factual&gt;. 
67
        ?version po:genre ?genre1, ?genre2. 
68
        ?episode po:version ?version
69
}
70
</pre>
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>
72
<hr/>
73
<h3>Queries related to formats (/programmes/formats):</h3>
74
<p><i>Lists</i> all formats</p>
75
<pre>
76
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
77
DESCRIBE po:format
78
</pre>
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>
80

    
81
<hr/>
82
<p><i>Lists</i> all episodes in a particular format</p>
83
<pre>
84
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
85
CONSTRUCT {?episode po:format &lt;http://dbtune.org/bbc/programmes/resource/format/18&gt;} 
86
WHERE 
87
{?episode po:version ?version. ?version po:format &lt;http://dbtune.org/bbc/programmes/resource/format/18&gt;}
88
</pre>
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>
90
<hr/>
91

    
92
<h3>Broadcast time queries</h3>
93
<p>Every title of every episode broadcasted after the 22nd of November 2007, 12:35:</p>
94
<pre>
95
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
96
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
97
PREFIX tl: &lt;http://purl.org/NET/c4dm/timeline.owl#&gt;
98
PREFIX event: &lt;http://purl.org/NET/c4dm/event.owl#&gt;
99
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
100
SELECT ?title ?start ?end WHERE {
101
?ep dc:title ?title.
102
?ep po:version ?v.
103
?bc po:broadcast_of ?v.
104
?bc event:time ?t.
105
?t tl:start ?start.
106
?t tl:end ?end.
107
FILTER (?start &gt; "2007-10-22T12:35:00Z"^^xsd:dateTime)
108
}
109
</pre>
110
<p><b>Note that results are truncated due to a LIMIT parameter on the server.</b> The query first retrieves all
111
broadcasts (this is limited to the first 2000 results) <b>and then</b> the results are truncated according to the 
112
FILTER condition</p>
113
<hr/>
114
<p>Every broadcast time of episodes of a particular brand (here, <i>How I Met Your Mother</i>)</p>
115
<pre>
116
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
117
PREFIX event: &lt;http://purl.org/NET/c4dm/event.owl#&gt;
118
DESCRIBE ?bct
119
WHERE
120
{
121
&lt;http://dbtune.org/bbc/programmes/resource/brand/906&gt; po:episode ?ep.
122
?ep po:version ?v.
123
?bc po:broadcast_of ?v.
124
?bc event:time ?bct.
125
}
126
</pre>
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>
128

    
129

    
130
<h3>Recommendation queries</h3>
131
<p>From a seed episode, <i>http://dbtune.org/bbc/programmes/resource/episode/1001</i>, give me all relevant episodes (shared tags)</p>
132
<pre>
133
PREFIX tags: &lt;http://www.holygoat.co.uk/owl/redwood/0.1/tags/&gt; 
134
PREFIX po: &lt;http://purl.org/ontology/po/&gt; 
135
SELECT ?recommended 
136
WHERE {
137
&lt;http://dbtune.org/bbc/programmes/resource/episode/40657&gt; tags:tag ?seedtagging. 
138
?seedtagging tags:associatedTag ?seedtag. 
139
?recommended tags:tag ?tagging. 
140
?tagging tags:associatedTag ?seedtag
141
}
142
</pre>
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>
144
<p>Same things, but with the /programmes homepage, and the name of the tag being shared:</p>
145
<pre>
146
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
147
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
148
PREFIX tags: &lt;http://www.holygoat.co.uk/owl/redwood/0.1/tags/&gt; 
149
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
150
SELECT ?recprog ?title
151
WHERE {
152
&lt;http://dbtune.org/bbc/programmes/resource/episode/40657&gt; tags:tag ?seedtagging. 
153
?seedtagging tags:associatedTag ?seedtag. 
154
?seedtag dc:title ?title.
155
?recommendedep tags:tag ?tagging. 
156
?recommendedep foaf:homepage ?recprog.
157
?tagging tags:associatedTag ?seedtag
158
}
159
</pre>
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>
161
<hr/>
162
<p>Give me episodes from the same genre as a particular one, with a broadcast time after the 22nd of November, 2007</p>
163
<pre>
164
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
165
PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
166
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
167
PREFIX tl: &lt;http://purl.org/NET/c4dm/timeline.owl#&gt;
168
PREFIX event: &lt;http://purl.org/NET/c4dm/event.owl#&gt;
169
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
170
SELECT ?ep ?title ?start
171
WHERE {
172
&lt;http://dbtune.org/bbc/programmes/resource/episode/40657&gt; po:version ?seedversion.
173
?seedversion po:genre ?genre.
174
?version po:genre ?genre.
175
?recprog po:version ?version.
176
?recprog dc:title ?title.
177
?recprog foaf:homepage ?ep.
178
?bc po:broadcast_of ?version.
179
?bc event:time ?t.
180
?t tl:start ?start.
181
FILTER (?start &gt; "2007-11-22T12:00:00Z"^^xsd:dateTime)
182
}
183
</pre>
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>
185
<hr/>
186
<p>Pairs of different brands starring a similar actor (using DBPedia)</p>
187
<pre>
188
select ?brand1 ?brand2 ?person 
189
where {
190
?brand1 p:starring ?person.
191
?brand2 p:starring ?person.
192
FILTER (?brand1 != ?brand2)
193
}
194
</pre>
195
<hr/>
196
<h3>Other</h3>
197
<p>Mention all locations associated to known services</p>
198
<pre>
199
PREFIX po: &lt;http://purl.org/ontology/po/&gt;
200
DESCRIBE ?geo 
201
WHERE 
202
{
203
?service a po:Service; po:location ?geo
204
}
205
</pre>
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>
207
<hr/>
208
</body>
209
</html>