prefix skos: prefix dct: prefix xsd: PREFIX rdf: PREFIX rdfs: prefix dbc: prefix dbr: prefix dbp: PREFIX dbo: PREFIX prov: SELECT ?countries_in_esc_by_year ?country_in_year (?year AS ?Year) (?country AS ?Country) ?entrant_robust (?entrant_label AS ?Creator) ?song_robust (?song_label AS ?Title) (?was_derived_from AS ?WikipediaURL) WHERE { SERVICE { ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year. ?country_in_year dct:subject ?countries_in_esc_by_year. bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") AS ?year). FILTER ( xsd:integer(?year) = 1993). ?country_in_year dbp:country ?country. ?country_in_year dbp:entrant ?entrant. } OPTIONAL { ?entrant_errata_uri dct:source ?entrant. } BIND (IF(isIRI(?entrant),?entrant,?entrant_errata_uri) AS ?entrant_robust) SERVICE { ?country_in_year dbp:song ?song. } OPTIONAL { ?song_errata_uri dct:source ?song. } BIND (IF(isIRI(?song),?song,?song_errata_uri) AS ?song_robust) SERVICE { OPTIONAL { ?entrant_robust rdfs:label ?entrant_label FILTER (lang(?entrant_label) = 'en'). ?song_robust rdfs:label ?song_label_raw FILTER (lang(?song_label_raw) = 'en'). # Create more DL friendly song-title metadata from Wikipedia song-label BIND(REPLACE(?song_label_raw, "\\s*\\(.*?song\\)$", "", "i") AS ?song_label). ?song_robust prov:wasDerivedFrom ?was_derived_from } } } ORDER BY ASC(?countries_in_esc_by_year) ?country