-
Notifications
You must be signed in to change notification settings - Fork 1
/
query-entities.sparql
361 lines (303 loc) · 18.1 KB
/
query-entities.sparql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX mm: <http://w3id.org/polifonia/ontology/music-meta/>
PREFIX mp: <http://w3id.org/polifonia/ontology/music-projection/>
PREFIX mr: <http://w3id.org/polifonia/ontology/music-representation/>
PREFIX core: <http://w3id.org/polifonia/ontology/core/>
PREFIX tunes: <http://w3id.org/polifonia/ontology/tunes/>
PREFIX src: <http://w3id.org/polifonia/ontology/source/>
PREFIX pon-resource: <http://w3id.org/polifonia/resource/tunes/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
CONSTRUCT {
?entity_iri a mm:MusicEntity ;
core:id ?entity_iri_local ; # add to ontology
rdfs:label ?entity_title ; #this needs a better solution.
core:title ?entity_title ; #this needs a better solution.
core:title ?entity_title_in_source ; #this needs a better solution.
src:hasIdentifier ?identifier_id_in_collection ;
core:image ?entity_image_url ;
mm:hasComposer ?composer_iri ;
core:hasAgentRole ?blank_any_agentrole ;
core:description ?entity_description_url ;
core:isMemberOf ?collection_iri ; # rism/MTC/session etc.
core:isMemberOf ?entity_collection_membership_iri ; #Any collection
mm:hasFormType ?entity_type_iri ;
core:hasPart ?abstract_score_iri ; #one for each 'work'
#core:hasPart ?lyrics_iri ; #why is this both here and at abstract score?
mm:isRealisedBy ?musical_performance_iri ;
#mm:isRecordedBy ?blank_recording_process ; #moved to MusicalPerformance
src:hasSource ?source_iri ;
# new blank node SourceSituation (reification)
tunes:hasSourceIdentifiers ?blank_source_identifier ;
core:isInvolvedIn ?blank_tf_membership ;
core:isInvolvedIn ?blank_tf_var_membership ;
rdfs:comment ?entity_comment .
?identifier_id_in_collection a src:Identifier ;
src:hasIdentifierType ?id_in_collection_identifier_type_iri ;
src:hasIdentifierValue ?entity_id ;
src:identifierIssuedBy ?source_id_issuer_iri . #colection
?blank_source_identifier a tunes:SourceIdentifier ;
tunes:hasSourceId ?entity_serial_number_in_source ;
tunes:pageInSource ?entity_page_number_in_source .
?blank_tf_membership a tunes:CollectionMembership ;
core:hasMembershipStrength ?tunefamily_confidence ; #neutral, weak, strong
core:hasMember ?tunefamily_iri . #shouldn't this be the inverse of hasMember ?
?blank_tf_var_membership a tunes:CollectionMembership ;
core:hasMembershipStrength ?tunefamily_variation_confidence ;
core:hasMember ?entity_related_to_tunefamily_iri . #shouldn't this be the inverse of hasMember ?
?blank_any_agentrole a core:AgentRole ;
core:hasRole ?any_role_iri ;
core:hasAgent ?any_agent_iri .
# Collection memberships
?entity_collection_membership_iri core:hasMember ?entity_iri .
?source_iri src:hasSubject ?entity_iri .
?tunefamily_iri core:hasMember ?entity_iri .
?collection_iri core:hasMember ?entity_iri .
#
?abstract_score_iri a mm:AbstractScore ;
core:id ?abstract_score_iri_local ;
mm:hasText ?lyrics_iri ; #We only have lyrics information for the entire song, and for the first stanza
core:hasPart ?stanza_iri ;
mm:isRealisedIn ?score_iri ;
core:isPartOf ?entity_iri .
?score_iri a mm:Score ;
core:id ?score_iri_local ; # add to ontology
core:title ?score_title ; # add to ontology
core:title ?score_title_in_source ;
core:description ?score_description_url ; # add to ontology
mm:hasScorePart ?score_part_iri ;
core:isPartOf ?entity_iri .
# mm:hasPublicationSituation ?publication_iri . # this now is in the source objct. Why also include it here?
?stanza_iri a mm:CompositionPart, mm:Stanza ;
core:id ?stanza_iri_local ;
core:image ?stanza_image_url ;
core:description ?entity_description_url ;
rdfs:label ?stanza_label ;
core:title ?stanza_label ;
mm:isRealisedIn ?score_iri ;
core:isPartOf ?abstract_score_iri ;
core:isPartOf ?entity_iri .
?score_part_iri a mm:ScorePart ;
core:id ?score_part_iri_local ;
core:image ?score_part_image_url ;
core:description ?entity_description_url ;
rdfs:label ?voice_label ;
core:title ?voice_label ;
mm:isRealisedIn ?score_iri ;
core:isPartOf ?abstract_score_iri ;
core:isPartOf ?entity_iri .
# here also mm:isrealisedIn ?score_iri ? Otherwise it is not clear what melody belongs to this part.
?score_excerpt_iri a mm:CompositionPart ;
core:id ?score_excerpt_iri_local ;
core:description ?entity_description_url ;
core:image ?excerpt_image_url ;
core:title ?excerpt_title ;
core:title ?excerpt_title_in_source ;
rdfs:label ?excerpt_title ;
mm:isRealisedIn ?score_iri ;
core:isPartOf ?abstract_score_iri ;
core:isPartOf ?entity_iri .
?lyrics_iri a mm:Text, mm:Lyrics ;
core:id ?lyrics_iri_local ;
core:hasText ?blank_text_fragment ;
core:isMemberOf ?textfamily_iri .
?blank_text_fragment a mm:TextFragment ;
core:text ?entity_lyrics_first_line .
?musical_performance_iri a mm:MusicalPerformance, core:InformationRealization ;
mm:isRecordedBy ?blank_recording_process ;
core:id ?musical_performance_iri_local ;
mm:isPerformedBy ?entity_singer_iri .
?blank_recording_process a mm:RecordingProcess ;
mm:producesRecording ?recording_iri ;
core:hasPlace ?blank_recording_place ;
core:hasTimeInterval ?blank_recording_timeinterval .
?blank_recording_place a core:Place ;
core:name ?entity_place_of_recording_name ;
core:latitude ?entity_place_of_recording_latitude ;
core:longitude ?entity_place_of_recording_longitude .
?blank_recording_timeinterval a core:TimeInterval ;
core:date ?entity_date_of_recording .
?recording_iri a mm:Recording ;
core:id ?recording_iri_local ;
core:url ?entity_audio_url .
}
WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:location ?_filepath .
?base_root a fx:root ;
?entities_slot ?entity_base .
# Required
?entity_base
xyz:entity_title ?entity_title ;
xyz:entity_iri_local ?entity_iri_local .
BIND(?entity_title AS ?score_title)
# collection iri
OPTIONAL { ?entity_base xyz:collection_iri_local ?collection_iri_local . }
BIND(IF(BOUND(?collection_iri_local), IRI(concat(str(pon-resource:), ?collection_iri_local)), ?nothing) AS ?collection_iri)
# entity identifer - not optional
?entity_base xyz:entity_id ?entity_id .
BIND(IRI(concat(str(pon-resource:), "IdentifierType/IDInCollection")) AS ?id_in_collection_identifier_type_iri)
BIND(IF(BOUND(?collection_iri), ?collection_iri, ?nothing) AS ?source_id_issuer_iri)
BIND(fx:bnode(concat(str(pon-resource::), (?entity_iri_local), "IDinCollection")) AS ?identifier_id_in_collection)
# title in score
OPTIONAL { ?entity_base xyz:entity_title_in_source ?entity_title_in_source . }
BIND(IF(BOUND(?entity_title_in_source), ?entity_title_in_source, ?nothing) AS ?score_title_in_source)
# Entity IRI
BIND(IRI(concat(str(pon-resource:), ?entity_iri_local)) AS ?entity_iri)
# Image for Entity
OPTIONAL { ?entity_base xyz:entity_image_url ?entity_image_url . }
# Composition Part (RISM)
OPTIONAL { ?entity_base xyz:melody_work_number ?melody_work_number . }
OPTIONAL { ?entity_base xyz:melody_movement_number ?melody_movement_number . }
OPTIONAL { ?entity_base xyz:melody_excerpt_number ?melody_excerpt_number . }
# Abstract Score
#make a separate abstract score for each work.
BIND(
IF(
!BOUND(?melody_work_number),
concat(?entity_iri_local, "/AbstractScore"),
concat(?entity_iri_local, "/AbstractScore/", ?melody_work_number)
)
AS ?abstract_score_iri_local
)
BIND(IRI(concat(str(pon-resource:), ?abstract_score_iri_local)) AS ?abstract_score_iri)
# score
BIND(
IF(
!BOUND(?melody_work_number),
concat(?entity_iri_local, "/Score"),
concat(?entity_iri_local, "/Score/", ?melody_work_number)
)
AS ?score_iri_local
)
BIND(IRI(concat(str(pon-resource:), ?score_iri_local)) AS ?score_iri)
# Voice
OPTIONAL { ?entity_base xyz:melody_voice_number ?melody_voice_number . }
OPTIONAL { ?entity_base xyz:melody_voice_id ?melody_voice_id . }
BIND(IF(BOUND(?melody_voice_number), concat(?entity_iri_local, '/ScorePart/', ?melody_voice_id), ?nothing) AS ?score_part_iri_local)
BIND(IF(BOUND(?melody_voice_number), IRI(concat(str(?entity_iri), '/ScorePart/', ?melody_voice_id)), ?nothing) AS ?score_part_iri)
BIND(IF(BOUND(?melody_voice_number), concat(?entity_title, ', Part #', ?melody_voice_number), ?nothing) AS ?voice_label)
# Image for voice
OPTIONAL { ?entity_base xyz:voice_image_url ?score_part_image_url . }
# Stanza
OPTIONAL { ?entity_base xyz:melody_stanza_number ?melody_stanza_number . }
OPTIONAL { ?entity_base xyz:melody_stanza_id ?melody_stanza_id . }
BIND(IF(BOUND(?melody_stanza_number), concat(?entity_iri_local, '/Stanza/', ?melody_stanza_id) , ?nothing) AS ?stanza_iri_local)
BIND(IF(BOUND(?melody_stanza_number), IRI(concat(str(?entity_iri), '/Stanza/', ?melody_stanza_id)) , ?nothing) AS ?stanza_iri)
BIND(IF(BOUND(?melody_stanza_number), concat(?entity_title, ', Stanza #', ?melody_stanza_number), ?nothing) AS ?stanza_label)
# Image for stanza
OPTIONAL { ?entity_base xyz:stanza_image_url ?stanza_image_url . }
# Excerpt (in RISM terminology)
OPTIONAL { ?entity_base xyz:excerpt_id ?excerpt_id . }
BIND(IF(BOUND(?excerpt_id), concat(?entity_iri_local, "/CompositionPart/", ?excerpt_id) , ?nothing) AS ?score_excerpt_iri_local)
BIND(IF(BOUND(?excerpt_id), IRI(concat(str(?entity_iri), "/CompositionPart/", ?excerpt_id)) , ?nothing) AS ?score_excerpt_iri)
OPTIONAL { ?entity_base xyz:excerpt_title ?excerpt_title . }
OPTIONAL { ?entity_base xyz:excerpt_title_in_source ?excerpt_title_in_source . }
# Image for excerpt
OPTIONAL { ?entity_base xyz:excerpt_image_url ?excerpt_image_url . }
# Weblink
OPTIONAL { ?entity_base xyz:entity_description_url ?entity_description_url . }
# Type
OPTIONAL {
?entity_base xyz:entity_types_iris_local ?entity_types_base .
?entity_types_base ?entity_type_slot ?entity_type_iri_local .
}
BIND(IF(BOUND(?entity_type_iri_local), IRI(concat(str(pon-resource:), ?entity_type_iri_local)), ?nothing) as ?entity_type_iri)
# Composers
OPTIONAL {
?entity_base xyz:composers_iris_local ?composers_iris_local_base .
?composers_iris_local_base ?composer_slot ?composer_iri_local .
}
BIND(IF(BOUND(?composer_iri_local), IRI(concat(str(pon-resource:), ?composer_iri_local)), ?nothing) AS ?composer_iri)
# Any Agents
OPTIONAL {
?entity_base xyz:any_agent_roles ?any_agent_roles_base .
?any_agent_roles_base ?any_agent_role_slot ?any_agent_role_base .
?any_agent_role_base
xyz:any_agent_iri_local ?any_agent_iri_local ;
xyz:any_role_iri_local ?any_role_iri_local
}
BIND(IF(BOUND(?any_agent_role_slot), IRI(concat(str(pon-resource:), ?any_agent_iri_local)), ?nothing) AS ?any_agent_iri)
BIND(IF(BOUND(?any_agent_role_slot), IRI(concat(str(pon-resource:), ?any_role_iri_local)), ?nothing) AS ?any_role_iri)
BIND(IF(BOUND(?any_agent_role_slot), replace(str(?any_agent_role_slot), str(rdf:), ""), ?nothing) AS ?any_agent_role_id)
BIND(IF(BOUND(?any_agent_role_slot), fx:bnode(concat(str(?source_iri), "anyagent", ?any_agent_role_id)), ?nothing) AS ?blank_any_agentrole)
# Any collection
OPTIONAL {
?entity_base xyz:entity_collection_memberships_iris_local ?entity_collection_memberships_iris_local_base .
?entity_collection_memberships_iris_local_base ?collection_slot ?entity_collection_membership_iri_local .
}
BIND(IF(BOUND(?entity_collection_membership_iri_local), IRI(concat(str(pon-resource:), ?entity_collection_membership_iri_local)), ?nothing) AS ?entity_collection_membership_iri)
# Tune Family
OPTIONAL { ?entity_base xyz:tunefamily_iri_local ?tunefamily_iri_local . }
BIND(IF(BOUND(?tunefamily_iri_local), IRI(concat(str(pon-resource:), ?tunefamily_iri_local)), ?nothing) AS ?tunefamily_iri)
BIND(IF(BOUND(?tunefamily_iri_local), fx:bnode(concat(str(?entity_iri), "tf")), ?nothing) as ?blank_tf_membership)
OPTIONAL { ?entity_base xyz:entity_tunefamily_confidence ?tunefamily_confidence . }
# Tune Family VAR
OPTIONAL { ?entity_base xyz:entity_related_to_tunefamily_iri_local ?entity_related_to_tunefamily_iri_local . }
BIND(IF(BOUND(?entity_related_to_tunefamily_iri_local), IRI(concat(str(pon-resource:), ?entity_related_to_tunefamily_iri_local)), ?nothing) AS ?entity_related_to_tunefamily_iri)
BIND(IF(BOUND(?entity_related_to_tunefamily_iri_local), fx:bnode(concat(str(?entity_iri), "vartf")), ?nothing) AS ?blank_tf_var_membership)
BIND(IF(BOUND(?entity_related_to_tunefamily_iri_local), "weak", ?nothing) AS ?tunefamily_variation_confidence)
# Lyrics and Text Family
OPTIONAL { ?entity_base xyz:entity_lyrics_first_line ?entity_lyrics_first_line . }
OPTIONAL { ?entity_base xyz:textfamily_iri_local ?textfamily_iri_local . }
BIND(IF(BOUND(?entity_lyrics_first_line), concat(?entity_iri_local, "/Lyrics"), ?nothing) AS ?lyrics_iri_local) #first line of first stanza
BIND(IF(BOUND(?entity_lyrics_first_line), IRI(concat(str(?entity_iri), "/Lyrics")), ?nothing) AS ?lyrics_iri) #first line of first stanza
BIND(IF(BOUND(?entity_lyrics_first_line), fx:bnode(concat(str(?entity_iri), "/TextFragment")), ?nothing) AS ?blank_text_fragment) #first line of first stanza
BIND(IF(BOUND(?textfamily_iri_local), IRI(concat(str(pon-resource:), ?textfamily_iri_local)), ?nothing) AS ?textfamily_iri)
# Source
OPTIONAL { ?entity_base xyz:source_iri_local ?source_iri_local . }
BIND(IF(BOUND(?source_iri_local), IRI(concat(str(pon-resource:), ?source_iri_local)), ?nothing) AS ?source_iri)
OPTIONAL { ?entity_base xyz:entity_serial_number_in_source ?entity_serial_number_in_source . }
OPTIONAL { ?entity_base xyz:entity_page_number_in_source ?entity_page_number_in_source . }
BIND (
COALESCE(
IF(BOUND(?entity_serial_number_in_source), "Y", 1/0),
IF(BOUND(?entity_page_number_in_source), "Y", 1/0),
?nothing
) AS ?source_identifier_present
)
BIND(IF(BOUND(?source_identifier_present), fx:bnode(concat(str(?entity_iri), "si")), ?nothing) AS ?blank_source_identifier)
# Performance, Audio Recording and Singer(s)
OPTIONAL {
?entity_base xyz:entity_singers_iris_local ?entity_singers_iris_local_base .
?entity_singers_iris_local_base ?singer_slot ?entity_singer_iri_local .
}
BIND(IF(BOUND(?entity_singer_iri_local), IRI(concat(str(pon-resource:), ?entity_singer_iri_local)), ?nothing) AS ?entity_singer_iri)
BIND(IF(BOUND(?entity_singer_iri_local), concat(?entity_iri_local, "/MusicalPerformance"), ?nothing) AS ?musical_performance_iri_local)
BIND(IF(BOUND(?entity_singer_iri_local), IRI(concat(str(?entity_iri), "/MusicalPerformance")), ?nothing) AS ?musical_performance_iri)
OPTIONAL { ?entity_base xyz:entity_year_of_recording ?entity_year_of_recording . }
OPTIONAL { ?entity_base xyz:entity_month_of_recording ?entity_month_of_recording . }
OPTIONAL { ?entity_base xyz:entity_day_of_recording ?entity_day_of_recording . }
OPTIONAL { ?entity_base xyz:entity_date_of_recording ?entity_date_of_recording . } # Y-M-D
BIND(IF(BOUND(?entity_date_of_recording), fx:bnode(concat(str(?entity_iri), "recdate")), ?nothing) AS ?blank_recording_timeinterval)
OPTIONAL { ?entity_base xyz:entity_place_of_recording_name ?entity_place_of_recording_name . }
OPTIONAL { ?entity_base xyz:entity_place_of_recording_latitude ?entity_place_of_recording_latitude . }
OPTIONAL { ?entity_base xyz:entity_place_of_recording_longitude ?entity_place_of_recording_longitude . }
BIND (
COALESCE(
IF(BOUND(?entity_place_of_recording_name), "Y", 1/0),
IF(BOUND(?entity_place_of_recording_latitude), "Y", 1/0),
IF(BOUND(?entity_place_of_recording_longitude), "Y", 1/0),
?nothing
) AS ?recording_place_present
)
BIND(IF(BOUND(?recording_place_present), fx:bnode(concat(str(?entity_iri), "recplace")), ?nothing) as ?blank_recording_place)
# Recording process
BIND (
COALESCE(
IF(BOUND(?recording_place_present), "Y", 1/0),
IF(BOUND(?entity_date_of_recording), "Y", 1/0),
?nothing
) AS ?recording_process_present
)
BIND(IF(BOUND(?recording_process_present), fx:bnode(concat(str(?entity_iri), "recprocess")), ?nothing) as ?blank_recording_process)
BIND(IF(BOUND(?recording_process_present), concat(?entity_iri_local, "/Recording"), ?nothing) as ?recording_iri_local)
BIND(IF(BOUND(?recording_process_present), IRI(concat(str(?entity_iri), "/Recording")), ?nothing) as ?recording_iri)
# Comment
OPTIONAL { ?entity_base xyz:entity_comment ?entity_comment . }
}
}