source: main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/errata/foo2-nooptional.sparql@ 34813

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

Snapshot of work (2nd go) on errata

File size: 2.0 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 (?entrant_label AS ?Creator) ?song (?song_label AS ?Title) (?was_derived_from AS ?WikipediaURL)
19WHERE {
20 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
21 ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
22
23 ?country_in_year dct:subject ?countries_in_esc_by_year.
24 bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") AS ?year).
25 FILTER ( xsd:integer(?year) < 1969).
26
27 ?country_in_year dbp:country ?country.
28
29 ?country_in_year dbp:entrant ?entrant.
30 }
31
32# OPTIONAL {
33 ?entrant_errata_uri dct:source ?entrant.
34# }
35
36 BIND (IF(isIRI(?entrant),?entrant,?entrant_errata_uri) AS ?entrant_robust)
37
38 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
39
40 ?country_in_year dbp:song ?song.
41
42 }
43
44# OPTIONAL {
45 ?song_errata_uri dct:source ?song.
46# }
47
48 BIND (IF(isIRI(?song),?song,?song_errata_uri) AS ?song_robust)
49
50 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
51
52 ?entrant_robust rdfs:label ?entrant_label
53 FILTER (lang(?entrant_label) = 'en').
54
55
56 ?song_robust rdfs:label ?song_label_raw
57 FILTER (lang(?song_label_raw) = 'en').
58
59 # Create more DL friendly song-title metadata from Wikipedia song-label
60 BIND(REPLACE(?song_label_raw, "\\s*\\(.*?song\\)$", "", "i") AS ?song_label).
61
62 OPTIONAL {
63 ?song_robust prov:wasDerivedFrom ?was_derived_from
64 }
65 }
66}
67ORDER BY ASC(?countries_in_esc_by_year) ?country
Note: See TracBrowser for help on using the repository browser.