1 | prefix skos: <http://www.w3.org/2004/02/skos/core#>
|
---|
2 | prefix dct: <http://purl.org/dc/terms/>
|
---|
3 | prefix xsd: <http://www.w3.org/2001/XMLSchema#>
|
---|
4 |
|
---|
5 | PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
---|
6 | PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
---|
7 |
|
---|
8 | prefix dbc: <http://dbpedia.org/resource/Category:>
|
---|
9 | prefix dbr: <http://dbpedia.org/resource/>
|
---|
10 | prefix dbp: <http://dbpedia.org/property/>
|
---|
11 |
|
---|
12 | PREFIX dbo: <http://dbpedia.org/ontology/>
|
---|
13 |
|
---|
14 | PREFIX prov: <http://www.w3.org/ns/prov#>
|
---|
15 |
|
---|
16 | SELECT ?country_in_year (?year AS ?Year) (?country AS ?Country) ?entrant ?song
|
---|
17 |
|
---|
18 | WHERE {
|
---|
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 | }
|
---|
62 | ORDER BY DESC(?countries_in_esc_by_year)
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|