Commit de10106bde0ae0c14b2a7e51baac49abc7dcd823

Authored by Barry Norton
1 parent 664e85fe0f
Exists in master

Finished annotations and added composition credit

Showing 6 changed files with 123 additions and 71 deletions

mappings/artist.ttl View file @ de10106
... ... @@ -37,29 +37,19 @@
37 37 [rr:predicate ov:sortLabel ;
38 38 rr:objectMap [rr:column "sort_name"]] .
39 39  
  40 +lb:artist_altLabel a rr:TriplesMap ;
  41 + rr:logicalTable [rr:sqlQuery
  42 + """SELECT artist.gid, artist_alias.name
  43 + FROM artist
  44 + INNER JOIN artist_alias ON artist.id = artist_alias.artist"""] ;
  45 + rr:subjectMap [rr:template lb:sm_artist] ;
  46 + rr:predicateObjectMap
  47 + [rr:predicate skos:altLabel ;
  48 + rr:objectMap [rr:column "name"]] .
  49 +
40 50 # [rr:objectMap [rr:parentTriplesMap lb:ArtistActivity] ;
41 51 # rr:predicate mo:activity] ;
42 52  
43   -#lb:artist_name a rr:TriplesMap ;
44   -# rr:logicalTable [rr:sqlQuery
45   -# """SELECT artist.gid, artist_name.name
46   -# FROM artist
47   -# INNER JOIN artist_name ON artist.name = artist_name.id"""] ;
48   -# rr:subjectMap lb:sm_artist ;
49   -# rr:predicateObjectMap
50   -# [rr:predicate foaf:name ;
51   -# rr:objectMap [rr:column "name"]]
52   -
53   -#lb:artist_sort_name a rr:TriplesMap ;
54   -# rr:logicalTable [rr:sqlQuery
55   -# """SELECT artist.gid, artist_name.name
56   -# FROM artist
57   -# INNER JOIN artist_name ON artist.sort_name = artist_name.id"""] ;
58   -# rr:subjectMap lb:sm_artist ;
59   -# rr:predicateObjectMap
60   -# [rr:predicate ov:sortLabel ;
61   -# rr:objectMap [rr:column "name"]] .
62   -
63 53 lb:artist_type_person a rr:TriplesMap ;
64 54 rr:logicalTable [rr:sqlQuery
65 55 """SELECT *
... ... @@ -219,18 +209,6 @@
219 209 rr:predicate rdfs:seeAlso ;
220 210 rr:objectMap [rr:column "url" ; rr:termType rr:IRI]] .
221 211  
222   -#lb:artist_altLabel a rr:TriplesMap ;
223   -# rr:logicalTable [rr:sqlQuery
224   -# """SELECT artist.gid, artist_name.name
225   -# FROM artist
226   -# INNER JOIN artist_alias ON artist.id = artist_alias.artist
227   -# INNER JOIN musicbrainz.artist_name
228   -# ON artist_alias.name = artist_name.id"""] ;
229   -# rr:subjectMap [rr:template lb:sm_artist] ;
230   -# rr:predicateObjectMap
231   -# [rr:predicate skos:altLabel ;
232   -# rr:objectMap [rr:column "name"]] .
233   -
234 212 lb:artist_recording a rr:TriplesMap ;
235 213 rr:logicalTable [rr:sqlQuery
236 214 """SELECT artist.gid, recording.gid AS recording_gid
... ... @@ -244,4 +222,16 @@
244 222 rr:predicateObjectMap
245 223 [rr:predicate foaf:made ;
246 224 rr:objectMap [rr:template "http://musicbrainz.org/recording/{gid}#_"]] .
  225 +
  226 +lb:artist_annotation a rr:TriplesMap ;
  227 + rr:logicalTable [rr:sqlQuery
  228 + """SELECT gid, text
  229 + FROM annotation
  230 + INNER JOIN artist_annotation
  231 + ON annotation.id = artist_annotation.annotation
  232 + INNER JOIN artist ON artist_annotation.artist = artist.id"""] ;
  233 + rr:subjectMap lb:sm_artist ;
  234 + rr:predicateObjectMap
  235 + [rr:predicate rdfs:comment ;
  236 + rr:objectMap [rr:column "text"]] .
mappings/medium.ttl View file @ de10106
... ... @@ -20,43 +20,31 @@
20 20 @prefix time: <http://www.w3.org/2006/time#> .
21 21 @prefix tl: <http://purl.org/NET/c4dm/timeline.owl#> .
22 22  
23   -# MB medium, tracklist => mo:Record
  23 +# MB medium => mo:Record
24 24  
25 25 lb:sm_medium rr:template "http://musicbrainz.org/record/{id}#_" .
26 26  
27 27 lb:Medium a rr:TriplesMap ;
28 28 rr:logicalTable [rr:tableName "medium"] ;
29 29 rr:subjectMap [rr:class mo:Record ;
30   - rr:template "http://musicbrainz.org/record/{id}#_"] .
31   -
32   -lb:medium_name a rr:TriplesMap ;
33   - rr:logicalTable [rr:tableName "medium"] ;
34   - rr:subjectMap lb:sm_medium ;
  30 + rr:template "http://musicbrainz.org/record/{id}#_"] ;
35 31 rr:predicateObjectMap
36 32 [rr:predicate dc:title ;
37   - rr:objectMap [rr:column "name" ; rr:datatype xsd:string]] .
  33 + rr:objectMap [rr:column "name" ; rr:datatype xsd:string]] ,
  34 + [rr:predicate mo:track_count ;
  35 + rr:objectMap [rr:column "track_count" ; rr:datatype xsd:int]] .
38 36  
  37 +
39 38 lb:medium_track a rr:TriplesMap ;
40 39 rr:logicalTable [rr:sqlQuery
41 40 """SELECT medium.id, track.id AS track_id
42 41 FROM medium
43   - INNER JOIN tracklist ON medium.tracklist = tracklist.id
44   - INNER JOIN track ON track.tracklist = tracklist.id"""] ;
  42 + INNER JOIN track ON track.medium = medium.id"""] ;
45 43 rr:subjectMap lb:sm_medium ;
46 44 rr:predicateObjectMap [
47 45 rr:predicate mo:track ;
48 46 rr:objectMap [rr:template "http://musicbrainz.org/track/{track_id}#_" ;
49 47 rr:termType rr:IRI]] .
50   -
51   -lb:medium_track_count a rr:TriplesMap ;
52   - rr:logicalTable [rr:sqlQuery
53   - """SELECT medium.id, tracklist.track_count
54   - FROM medium
55   - INNER JOIN tracklist ON medium.tracklist = tracklist.id"""];
56   - rr:subjectMap lb:sm_medium ;
57   - rr:predicateObjectMap
58   - [rr:predicate mo:track_count ;
59   - rr:objectMap [rr:column "track_count" ; rr:datatype xsd:int]] .
60 48  
61 49 lb:medium_format a rr:TriplesMap ;
62 50 rr:logicalTable [rr:sqlQuery
mappings/recording.ttl View file @ de10106
1   -<file:///home/kurtjx/srcs/d2r-server-0.7/mapping.n3#Recording_5>
2   - a <http://www.w3.org/ns/r2rml#TriplesMap> ;
3   - <http://www.w3.org/ns/r2rml#logicalTable>
4   - [ <http://www.w3.org/ns/r2rml#sqlQuery>
5   - "SELECT * FROM musicbrainz.recording WHERE musicbrainz.recording.length IS NOT NULL "
6   - ] ;
7   - <http://www.w3.org/ns/r2rml#predicateObjectMap>
8   - [ <http://www.w3.org/ns/r2rml#objectMap>
9   - [ <http://www.w3.org/ns/r2rml#column>
10   - "length" ;
11   - <http://www.w3.org/ns/r2rml#datatype>
12   - <http://www.w3.org/2001/XMLSchema#float>
13   - ] ;
14   - <http://www.w3.org/ns/r2rml#predicate>
15   - <http://purl.org/ontology/mo/duration>
16   - ] ;
17   - <http://www.w3.org/ns/r2rml#subjectMap>
18   - [ <http://www.w3.org/ns/r2rml#template>
19   - "http://musicbrainz.org/recording/{gid}#_"
20   - ] .
  1 +@prefix rr: <http://www.w3.org/ns/r2rml#> .
  2 +
  3 +@prefix lb: <https://github.com/LinkedBrainz/r2rml/v0.1#> .
  4 +@prefix ngs: <http://musicbrainz.org/NGS> .
  5 +
  6 +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  7 +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
  8 +@prefix owl: <http://www.w3.org/2002/07/owl#> .
  9 +@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
  10 +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
  11 +@prefix dc: <http://purl.org/dc/elements/1.1/> .
  12 +@prefix mo: <http://purl.org/ontology/mo/> .
  13 +@prefix foaf: <http://xmlns.com/foaf/0.1/> .
  14 +@prefix ov: <http://open.vocab.org/terms/> .
  15 +@prefix dct: <http://purl.org/dc/terms/> .
  16 +@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
  17 +@prefix event: <http://purl.org/NET/c4dm/event.owl#> .
  18 +@prefix is: <http://purl.org/ontology/is/core#> .
  19 +@prefix isi: <http://purl.org/ontology/is/inst/> .
  20 +@prefix time: <http://www.w3.org/2006/time#> .
  21 +@prefix tl: <http://purl.org/NET/c4dm/timeline.owl#> .
  22 +
  23 +# MB recording => mo:Signal
  24 +
  25 +lb:sm_recording rr:template "http://musicbrainz.org/recording/{gid}#_" .
  26 +
  27 +lb:Recording a rr:TriplesMap ;
  28 + rr:logicalTable [rr:tableName "recording"] ;
  29 + rr:subjectMap
  30 + [rr:class mo:Signal ;
  31 + rr:template "http://musicbrainz.org/recording/{gid}#_"] ;
  32 + rr:predicateObjectMap
  33 + [rr:predicate mo:musicbrainz_guid ;
  34 + rr:objectMap [rr:column "gid" ; rr:datatype xsd:string]] ,
  35 + [rr:predicate dc:title ;
  36 + rr:objectMap [rr:column "name"]] ,
  37 + [rr:predicate mo:duration ;
  38 + rr:objectMap [rr:column "length"; rr:datatype xsd:float]] .
  39 +
  40 +lb:recording_annotation a rr:TriplesMap ;
  41 + rr:logicalTable [rr:sqlQuery
  42 + """SELECT gid, text
  43 + FROM annotation
  44 + INNER JOIN recording_annotation
  45 + ON annotation.id = recording_annotation.annotation
  46 + INNER JOIN recording
  47 + ON recording_annotation.recording = recording.id"""] ;
  48 + rr:subjectMap lb:sm_recording ;
  49 + rr:predicateObjectMap
  50 + [rr:predicate rdfs:comment ;
  51 + rr:objectMap [rr:column "text"]] .
mappings/release.ttl View file @ de10106
... ... @@ -161,4 +161,16 @@
161 161 [rr:predicate event:place ;
162 162 rr:objectMap [rr:template "http://musicbrainz.org/area/{country}#_" ;
163 163 rr:termType rr:IRI]] .
  164 +
  165 +lb:release_annotation a rr:TriplesMap ;
  166 + rr:logicalTable [rr:sqlQuery
  167 + """SELECT gid, text
  168 + FROM annotation
  169 + INNER JOIN release_annotation
  170 + ON annotation.id = release_annotation.annotation
  171 + INNER JOIN release ON release_annotation.release = release.id"""] ;
  172 + rr:subjectMap lb:sm_release ;
  173 + rr:predicateObjectMap
  174 + [rr:predicate rdfs:comment ;
  175 + rr:objectMap [rr:column "text"]] .
mappings/release_group.ttl View file @ de10106
... ... @@ -84,4 +84,17 @@
84 84 rr:predicateObjectMap
85 85 [rr:predicate rdfs:seeAlso ;
86 86 rr:objectMap [rr:column "url" ; rr:termType rr:IRI]] .
  87 +
  88 +lb:release_group_annotation a rr:TriplesMap ;
  89 + rr:logicalTable [rr:sqlQuery
  90 + """SELECT gid, text
  91 + FROM annotation
  92 + INNER JOIN release_group_annotation
  93 + ON annotation.id = release_group_annotation.annotation
  94 + INNER JOIN release_group
  95 + ON release_group_annotation.release_group = release_group.id"""] ;
  96 + rr:subjectMap lb:sm_release_group ;
  97 + rr:predicateObjectMap
  98 + [rr:predicate rdfs:comment ;
  99 + rr:objectMap [rr:column "text"]] .
mappings/work.ttl View file @ de10106
... ... @@ -23,6 +23,7 @@
23 23 # MB work => mo:MusicalWork, mo:Composition
24 24  
25 25 lb:sm_work rr:template "http://musicbrainz.org/work/{gid}#_" .
  26 +lb:sm_composition rr:template "http://musicbrainz.org/work/{gid}#composition" .
26 27  
27 28 lb:Work a rr:TriplesMap ;
28 29 rr:logicalTable [rr:tableName "work"] ;
... ... @@ -39,6 +40,24 @@
39 40 rr:predicateObjectMap
40 41 [rr:predicate mo:produced_work ;
41 42 rr:objectMap lb:sm_work] .
  43 +
  44 +#Note there is no longer a direct association between artists and works
  45 +# rather composition is one of the advanced relationships between
  46 +# artists and works
  47 +lb:composition_artist a rr:TriplesMap ;
  48 + rr:logicalTable [rr:sqlQuery
  49 + """SELECT work.gid, artist.gid AS artist_gid
  50 + FROM artist
  51 + INNER JOIN l_artist_work ON artist.id = l_artist_work.entity0
  52 + INNER JOIN link ON l_artist_work.link = link.id
  53 + INNER JOIN link_type ON link_type = link_type.id
  54 + INNER JOIN work on l_artist_work.entity1 = work.id
  55 + WHERE link_type.gid='d59d99ea-23d4-4a80-b066-edca32ee158f'"""] ;
  56 + rr:subjectMap lb:sm_composition ;
  57 + rr:predicateObjectMap
  58 + [rr:predicate mo:composer ;
  59 + rr:objectMap [rr:template "http://musicbrainz.org/artist/{artist_gid}#_" ;
  60 + rr:termType rr:IRI]] .
42 61  
43 62 #BN: turned rdfs:seeAlso into foaf:isPrimaryTopicOf
44 63 lb:work_wikipedia a rr:TriplesMap ;