source: main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/errata-lod/local--countries-in-esc-by-year-in-1956--with-errata.sparql@ 35057

Last change on this file since 35057 was 35057, checked in by davidb, 3 years ago

Sparql query to pick up on the more tricy 1956 entries (where there are 2 entries per country)

File size: 4.6 KB
Line 
1prefix skos: <http://www.w3.org/2004/02/skos/core#>
2prefix dct: <http://purl.org/dc/terms/>
3prefix xsd: <http://www.w3.org/2001/XMLSchema#>
4
5PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
6PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
7
8prefix dbc: <http://dbpedia.org/resource/Category:>
9prefix dbr: <http://dbpedia.org/resource/>
10prefix dbp: <http://dbpedia.org/property/>
11
12PREFIX dbo: <http://dbpedia.org/ontology/>
13
14PREFIX prov: <http://www.w3.org/ns/prov#>
15
16
17SELECT ?countries_in_esc_by_year ?country_in_year (?year AS ?Year) (?country AS ?Country)
18 ?entrant_robust (?entrant_label AS ?Creator) ?song_robust (?song_label AS ?Title)
19 (?country_in_year_abstract_en AS ?Abstract_en)
20 (?song_abstract_en AS ?TitleAbstract_en) (?entrant_abstract_en AS ?CreatorAbstract_en)
21 (?was_derived_from AS ?WikipediaURL)
22WHERE {
23 SERVICE <https://dbpedia.org/sparql> {
24 ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
25
26 ?country_in_year dct:subject ?countries_in_esc_by_year.
27## Useful example
28# FILTER (?country_in_year = dbr:Bosnia_and_Herzegovina_in_the_Eurovision_Song_Contest_2010).
29## Useful example
30# FILTER (?country_in_year = dbr:Germany_in_the_Eurovision_Song_Contest_2010).
31
32 bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") AS ?year).
33 FILTER ( xsd:integer(?year) >= 1956 && xsd:integer(?year) <= 1956).
34
35 ?country_in_year dbp:country ?country.
36
37 ?country_in_year dbp:entrant ?entrant
38 FILTER (?entrant != ""@en && ?entrant != dbr:Eurovision_Song_Contest_1985).
39 }
40
41 OPTIONAL {
42 ?entrant_errata_uri dct:source ?entrant.
43 }
44
45 BIND (IF(isIRI(?entrant),?entrant,?entrant_errata_uri) AS ?entrant_robust).
46
47 SERVICE <https://dbpedia.org/sparql> {
48
49 ?country_in_year dbp:song ?song
50 FILTER (?song != ""@en).
51 }
52
53 OPTIONAL {
54 ?song_errata_uri dct:source ?song.
55 }
56
57 BIND (IF(isIRI(?song),?song,?song_errata_uri) AS ?song_robust).
58
59 # Additional 1956 check to avoid cross-product
60 SERVICE <https://dbpedia.org/sparql> {
61 ?song_robust dbp:artist ?entrant_robust.
62 }
63
64 # Create more DL friendly entrant-title metadata from Wikipedia entrant-uri/label
65 BIND(REPLACE(REPLACE(str(?entrant_robust), "^.*/(.*?)(_+\\(.*(singer|duo|band|group|musician)\\))?$", "$1"),"_"," ") AS ?entrant_label).
66
67 # Create more DL friendly song-title metadata from Wikipedia song-uri/label
68 BIND(REPLACE(REPLACE(str(?song_robust), "^.*/(.*?)(_+\\(.*song\\))?$", "$1"),"_"," ") AS ?song_label).
69
70# DBpedia incorrectly maps some songs/entrants to integer numbers
71# Most of these can be fixed with the usual errata approach,
72# however there are a few examples that map to identical
73# integer vals, and therefore are not unique.
74#
75# The chosen solution to address this is to include some
76# bespoke filtering to explicitly rule in the song+entrant combination
77# we want (i.e., the filter has the affect of ruling out the
78# (incorrect) combination we don't want.
79
80#dbr:Macedonia_in_the_Eurovision_Song_Contest_2000
81# song: "100"^^xsd:integer
82# dbr:100%25_te_ljubam
83# dbr:XXL_\(Macedonian_band\))
84#
85#Luxembourg_in_the_Eurovision_Song_Contest_1984
86# song: "100"^^xsd:integer
87# dbr:100%25_d%27amour
88# dbr:Sophie_Carle
89
90#dbr:Belarus_in_the_Eurovision_Song_Contest_2010
91# entrant: "3"^^xsd:integer
92# dbr:3%2B2_\(band\)
93# dbr:Butterflies_\(3%2B2_song\)
94#
95#dbr:Netherlands_in_the_Eurovision_Song_Contest_2011
96# entrant: "3"^^xsd:integer
97# dbr:3JS
98# dbr:Je_vecht_nooit_alleen
99
100 FILTER(
101 (?song != "100"^^xsd:integer && ?entrant != "3"^^xsd:integer)
102 ||
103 (?song = "100"^^xsd:integer
104 && ?song_robust = dbr:100%25_te_ljubam && ?entrant = dbr:XXL_\(Macedonian_band\))
105 ||
106 (?song = "100"^^xsd:integer
107 && ?song_robust = dbr:100%25_d%27amour && ?entrant = dbr:Sophie_Carle)
108 ||
109 (?entrant = "3"^^xsd:integer
110 && ?entrant_robust = dbr:3\+2_\(band\) && ?song_robust = dbr:Butterflies_\(3\+2_song\))
111 ||
112 (?entrant = "3"^^xsd:integer
113 && ?entrant_robust = dbr:3JS && ?song_robust = dbr:Je_vecht_nooit_alleen)
114 ).
115
116# && ?entrant_robust = dbr:3%2B2_\(band\) && ?song_robust = dbr:Butterflies_\(3%2B2_song\))
117
118
119 SERVICE <https://dbpedia.org/sparql> {
120
121 OPTIONAL {
122 ?song_robust prov:wasDerivedFrom ?was_derived_from.
123
124 ?country_in_year dbo:abstract ?country_in_year_abstract_en
125 FILTER (lang(?country_in_year_abstract_en) = 'en').
126
127 ?entrant_robust dbo:abstract ?entrant_abstract_en
128 FILTER (lang(?entrant_abstract_en) = 'en').
129
130 ?song_robust dbo:abstract ?song_abstract_en
131 FILTER (lang(?song_abstract_en) = 'en').
132
133 }
134 }
135}
136ORDER BY ASC(?countries_in_esc_by_year) ?country
137
Note: See TracBrowser for help on using the repository browser.