source: main/trunk/model-sites-dev/eurovision-lod/collect/eurovision/prepare/fix-problem-entrants--using-errata.sparql@ 34945

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

More flexible way to determine song -- entrant relationship; getting entrant-label now optional, as if a string, then there is no rdfs:label field

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
16SELECT ?country_in_year (?year AS ?Year) (?country AS ?Country) ?entrant ?song
17
18WHERE {
19 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
20 ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
21
22 ?country_in_year dct:subject ?countries_in_esc_by_year.
23 bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") as ?year).
24 FILTER ( xsd:integer(?year) < 2020).
25
26 ?country_in_year dbp:country ?country.
27
28 ?country_in_year dbp:entrant ?entrant_errata.
29 FILTER (isLITERAL(?entrant_errata)).
30
31 ?country_in_year dbp:song ?song
32 FILTER (isURI(?song)).
33 }
34
35 ?country_in_year dbp:entrant ?entrant.
36 ?country_in_year dct:source ?entrant_errata.
37
38
39 # Would like to do the following:
40 # ?song dbp:artist ?entrant.
41 # in the 'dbpedia' graph however, the 'entrant' sitting in 'song' is sometimes a *string* not a URI
42 # =>
43 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
44 ?song dbp:artist|dbp:as ?songentrant_from_dbpedia.
45 }
46 OPTIONAL {
47 ?song dbp:artist ?songentrant_from_errata.
48 }
49 # If a string, look for a better result in the 'errata' graph
50 BIND(IF(isLITERAL(?songentrant_from_dbpedia),?songentrant_from_errata,?songentrant_from_dbpedia) AS ?entrant2).
51 FILTER (sameTERM(?entrant2,?entrant)).
52
53 ?entrant dct:source ?entrant_errata.
54
55 OPTIONAL {
56 SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
57 ?entrant rdfs:label ?entrant_label
58 FILTER (lang(?entrant_label) = 'en').
59 }
60 }
61}
62ORDER BY DESC(?countries_in_esc_by_year)
63
64
65
Note: See TracBrowser for help on using the repository browser.