Chris@0
|
1 :- module(jamendo_match,[]).
|
Chris@0
|
2
|
Chris@0
|
3 :- consult(library('semweb/rdf_db')).
|
Chris@0
|
4
|
Chris@0
|
5 :- use_module(match).
|
Chris@0
|
6
|
Chris@0
|
7 :- consult(jamendo_ns).
|
Chris@0
|
8
|
Chris@0
|
9
|
Chris@0
|
10 /**
|
Chris@0
|
11 * Class mappings
|
Chris@0
|
12 */
|
Chris@0
|
13 match:
|
Chris@0
|
14 (jamendo:artist(Id))
|
Chris@0
|
15 eq
|
Chris@0
|
16 [
|
Chris@0
|
17 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),rdf:type,mo:'MusicArtist')
|
Chris@0
|
18 ].
|
Chris@0
|
19
|
Chris@0
|
20 match:
|
Chris@0
|
21 (jamendo:album(Id))
|
Chris@0
|
22 eq
|
Chris@0
|
23 [
|
Chris@0
|
24 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),rdf:type,mo:'Record')
|
Chris@0
|
25 ].
|
Chris@0
|
26
|
Chris@0
|
27
|
Chris@0
|
28 match:
|
Chris@0
|
29 (jamendo:track(Id))
|
Chris@0
|
30 eq
|
Chris@0
|
31 [
|
Chris@0
|
32 rdf(pattern(['http://dbtune.org/jamendo/resource/track/',Id]),rdf:type,mo:'Track')
|
Chris@0
|
33 , rdf(pattern(['http://dbtune.org/jamendo/resource/signal/',Id]),mo:publishedAs,pattern(['http://dbtune.org/jamendo/resource/track/',Id]))
|
Chris@0
|
34 , rdf(pattern(['http://dbtune.org/jamendo/resource/signal/',Id]),rdf:type,mo:'Signal')
|
Chris@0
|
35 , rdf(pattern(['http://dbtune.org/jamendo/resource/signal/',Id]),mo:signalTime,pattern(['http://dbtune.org/jamendo/resource/interval/',Id]))
|
Chris@0
|
36 , rdf(pattern(['http://dbtune.org/jamendo/resource/interval/',Id]),rdf:type,time:'Interval')
|
Chris@0
|
37 , rdf(pattern(['http://dbtune.org/jamendo/resource/interval/',Id]),tl:onTimeLine,pattern(['http://dbtune.org/jamendo/resource/timeline/',Id]))
|
Chris@0
|
38 , rdf(pattern(['http://dbtune.org/jamendo/resource/performance/',Id]),mo:recordedAs,pattern(['http://dbtune.org/jamendo/resource/signal/',Id]))
|
Chris@0
|
39 ].
|
Chris@0
|
40
|
Chris@0
|
41 /**
|
Chris@0
|
42 * Property mappings
|
Chris@0
|
43 */
|
Chris@0
|
44
|
Chris@0
|
45 /**
|
Chris@0
|
46 * Artists
|
Chris@0
|
47 */
|
Chris@0
|
48 match:
|
Chris@0
|
49 (jamendo:artist_dispname(Id,Name))
|
Chris@0
|
50 eq
|
Chris@0
|
51 [
|
Chris@0
|
52 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),foaf:name,literal(type('http://www.w3.org/2001/XMLSchema#string',Name)))
|
Chris@0
|
53 ].
|
Chris@0
|
54
|
Chris@0
|
55 match:
|
Chris@0
|
56 (jamendo:artist_description(Id,Desc))
|
Chris@0
|
57 eq
|
Chris@0
|
58 [
|
Chris@0
|
59 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),mo:biography,literal(type('http://www.w3.org/2001/XMLSchema#string',Desc)))
|
Chris@0
|
60 ].
|
Chris@0
|
61
|
Chris@0
|
62 %make use of tabled equivalence here
|
Chris@0
|
63 match:
|
Chris@0
|
64 (jamendo:artist_geo(Id,Geo),jamendo_match:geonames(Geo,URI))
|
Chris@0
|
65 eq
|
Chris@0
|
66 [
|
Chris@0
|
67 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),foaf:based_near,URI)
|
Chris@0
|
68 ].
|
Chris@0
|
69
|
Chris@0
|
70 match:
|
Chris@0
|
71 (jamendo:artist_homepage(Id,HomePage))
|
Chris@0
|
72 eq
|
Chris@0
|
73 [
|
Chris@0
|
74 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),foaf:homepage,HomePage)
|
Chris@0
|
75 ].
|
Chris@0
|
76
|
Chris@0
|
77 match:
|
Chris@0
|
78 (jamendo:artist_image(Id,Image))
|
Chris@0
|
79 eq
|
Chris@0
|
80 [
|
Chris@0
|
81 rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',Id]),foaf:img,Image)
|
Chris@0
|
82 ].
|
Chris@0
|
83
|
Chris@0
|
84 /**
|
Chris@0
|
85 * Albums
|
Chris@0
|
86 */
|
Chris@0
|
87 match:
|
Chris@0
|
88 (jamendo:album_name(Id,Name))
|
Chris@0
|
89 eq
|
Chris@0
|
90 [
|
Chris@0
|
91 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),dc:title,literal(type('http://www.w3.org/2001/XMLSchema#string',Name)))
|
Chris@0
|
92 ].
|
Chris@0
|
93
|
Chris@0
|
94 match:
|
Chris@0
|
95 (jamendo:album_description(Id,Desc))
|
Chris@0
|
96 eq
|
Chris@0
|
97 [
|
Chris@0
|
98 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),dc:description,literal(type('http://www.w3.org/2001/XMLSchema#string',Desc)))
|
Chris@0
|
99 ].
|
Chris@0
|
100
|
Chris@0
|
101 match:
|
Chris@0
|
102 (jamendo:album_artist(Id,ArtistId))
|
Chris@0
|
103 eq
|
Chris@0
|
104 [
|
Chris@0
|
105 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),foaf:maker,pattern(['http://dbtune.org/jamendo/resource/artist/',ArtistId]))
|
Chris@0
|
106 , rdf(pattern(['http://dbtune.org/jamendo/resource/artist/',ArtistId]),foaf:made,pattern(['http://dbtune.org/jamendo/resource/record/',Id]))
|
Chris@0
|
107 ].
|
Chris@0
|
108
|
Chris@0
|
109 match:
|
Chris@0
|
110 (jamendo:album_releasedate(Id,Date))
|
Chris@0
|
111 eq
|
Chris@0
|
112 [
|
Chris@0
|
113 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),dc:date,literal(Date))
|
Chris@0
|
114 ].
|
Chris@0
|
115
|
Chris@0
|
116 match:
|
Chris@0
|
117 (jamendo:album_cover(Id,_,_,Cover))
|
Chris@0
|
118 eq
|
Chris@0
|
119 [
|
Chris@0
|
120 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),mo:image,Cover)
|
Chris@0
|
121 ].
|
Chris@0
|
122 match:
|
Chris@0
|
123 (jamendo:album_p2p(Id,ogg3,ed2k,Link))
|
Chris@0
|
124 eq
|
Chris@0
|
125 [
|
Chris@0
|
126 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),mo:availableAs,pattern(['http://dbtune.org/jamendo/resource/item/',Id]))
|
Chris@0
|
127 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/ogg3/',Id]),rdf:type,mo:'Ed2kItem')
|
Chris@0
|
128 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/ogg3/',Id]),dc:format,literal(ogg3))
|
Chris@0
|
129 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/ogg3/',Id]),mo:link,Link)
|
Chris@0
|
130 ].
|
Chris@0
|
131 match:
|
Chris@0
|
132 (jamendo:album_p2p(Id,mp32,ed2k,Link))
|
Chris@0
|
133 eq
|
Chris@0
|
134 [
|
Chris@0
|
135 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),mo:availableAs,pattern(['http://dbtune.org/jamendo/resource/item/ed2k/mp32/',Id]))
|
Chris@0
|
136 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/mp32/',Id]),rdf:type,mo:'Ed2kItem')
|
Chris@0
|
137 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/mp32/',Id]),dc:format,literal(mp32))
|
Chris@0
|
138 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/ed2k/mp32/',Id]),mo:link,Link)
|
Chris@0
|
139 ].
|
Chris@0
|
140 match:
|
Chris@0
|
141 (jamendo:album_p2p(Id,ogg3,bittorrent,Link))
|
Chris@0
|
142 eq
|
Chris@0
|
143 [
|
Chris@0
|
144 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),mo:availableAs,pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/ogg3/',Id]))
|
Chris@0
|
145 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/ogg3/',Id]),rdf:type,mo:'BittorrentItem')
|
Chris@0
|
146 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/ogg3/',Id]),dc:format,literal(ogg3))
|
Chris@0
|
147 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/ogg3/',Id]),mo:link,Link)
|
Chris@0
|
148 ].
|
Chris@0
|
149 match:
|
Chris@0
|
150 (jamendo:album_p2p(Id,mp32,bittorrent,Link))
|
Chris@0
|
151 eq
|
Chris@0
|
152 [
|
Chris@0
|
153 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),mo:availableAs,pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/mp32/',Id]))
|
Chris@0
|
154 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/mp32/',Id]),rdf:type,mo:'BittorrentItem')
|
Chris@0
|
155 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/mp32/',Id]),dc:format,literal(mp32))
|
Chris@0
|
156 , rdf(pattern(['http://dbtune.org/jamendo/resource/item/bittorrent/mp32/',Id]),mo:link,Link)
|
Chris@0
|
157 ].
|
Chris@0
|
158
|
Chris@0
|
159 match:
|
Chris@0
|
160 (jamendo:album_tag(_,Tag))
|
Chris@0
|
161 eq
|
Chris@0
|
162 [
|
Chris@0
|
163 rdf(pattern(['http://dbtune.org/jamendo/resource/tag/',Tag]),tags:tagName,literal(type('http://www.w3.org/2001/XMLSchema#string',Tag)))
|
Chris@0
|
164 , rdf(pattern(['http://dbtune.org/jamendo/resource/tag/',Tag]),rdf:type,tags:'Tag')
|
Chris@0
|
165 ].
|
Chris@0
|
166 match:
|
Chris@0
|
167 (jamendo:album_tag(Id,Tag))
|
Chris@0
|
168 eq
|
Chris@0
|
169 [
|
Chris@0
|
170 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',Id]),tags:taggedWithTag,pattern(['http://dbtune.org/jamendo/resource/tag/',Tag]))
|
Chris@0
|
171 ].
|
Chris@0
|
172
|
Chris@0
|
173 /**
|
Chris@0
|
174 * Tracks
|
Chris@0
|
175 */
|
Chris@0
|
176 match:
|
Chris@0
|
177 (jamendo:track_album(Id,AlbumId))
|
Chris@0
|
178 eq
|
Chris@0
|
179 [
|
Chris@0
|
180 rdf(pattern(['http://dbtune.org/jamendo/resource/record/',AlbumId]),mo:hasTrack,pattern(['http://dbtune.org/jamendo/resource/track/',Id]))
|
Chris@0
|
181 ].
|
Chris@0
|
182
|
Chris@0
|
183 match:
|
Chris@0
|
184 (jamendo:track_no(Id,No))
|
Chris@0
|
185 eq
|
Chris@0
|
186 [
|
Chris@0
|
187 rdf(pattern(['http://dbtune.org/jamendo/resource/track/',Id]),mo:trackNum,literal(type('http://www.w3.org/2001/XMLSchema#int',No)))
|
Chris@0
|
188 ].
|
Chris@0
|
189
|
Chris@0
|
190 match:
|
Chris@0
|
191 (jamendo:track_name(Id,Name))
|
Chris@0
|
192 eq
|
Chris@0
|
193 [
|
Chris@0
|
194 rdf(pattern(['http://dbtune.org/jamendo/resource/track/',Id]),dc:title,literal(type('http://www.w3.org/2001/XMLSchema#string',Name)))
|
Chris@0
|
195 ].
|
Chris@0
|
196
|
Chris@0
|
197 match:
|
Chris@0
|
198 (jamendo:track_licenseurl(Id,License))
|
Chris@0
|
199 eq
|
Chris@0
|
200 [
|
Chris@0
|
201 rdf(pattern(['http://dbtune.org/jamendo/resource/track/',Id]),mo:license,License)
|
Chris@0
|
202 , rdf(License,rdf:type,foaf:'Document')
|
Chris@0
|
203 ].
|
Chris@0
|
204 match:
|
Chris@0
|
205 (jamendo:track_lyrics(Id,Lyrics))
|
Chris@0
|
206 eq
|
Chris@0
|
207 [
|
Chris@0
|
208 rdf(pattern(['http://dbtune.org/jamendo/resource/performance/',Id]),event:hasFactor,pattern(['http://dbtune.org/jamendo/resource/lyrics/',Id]))
|
Chris@0
|
209 , rdf(pattern(['http://dbtune.org/jamendo/resource/lyrics/',Id]),rdf:type,mo:'Lyrics')
|
Chris@0
|
210 , rdf(pattern(['http://dbtune.org/jamendo/resource/lyrics/',Id]),mo:lyricsText,literal(type('http://www.w3.org/2001/XMLSchema#string',Lyrics)))
|
Chris@0
|
211 ].
|
Chris@0
|
212
|
Chris@0
|
213
|
Chris@0
|
214
|
Chris@0
|
215 /**
|
Chris@0
|
216 * Geo mapping
|
Chris@0
|
217 */
|
Chris@0
|
218 :- use_module(library('http/http_open')).
|
Chris@0
|
219 geonames(JamendoLiteral,URI) :-
|
Chris@0
|
220 clean_literal(JamendoLiteral,Query),
|
Chris@0
|
221 concat_atom(['http://ws.geonames.org/search?q=',Query,'&fclass=A','&type=rdf','&maxRows=1'],Url),
|
Chris@0
|
222 http_open:http_open(Url,Stream,[]),
|
Chris@0
|
223 load_rdf(Stream,Triples),
|
Chris@0
|
224 close(Stream),
|
Chris@0
|
225 member(rdf(URI,'http://www.w3.org/1999/02/22-rdf-syntax-ns#type','http://www.geonames.org/ontology#Feature'),Triples).
|
Chris@0
|
226 clean_literal(Literal,Cleaned) :-
|
Chris@0
|
227 atom_chars(Literal,Chars),
|
Chris@0
|
228 delete(Chars,'(',T1),
|
Chris@0
|
229 delete(T1,')',T2),
|
Chris@0
|
230 atom_chars(T3,T2),
|
Chris@0
|
231 www_form_encode(T3,Cleaned).
|
Chris@0
|
232
|