1 |
|
---|
2 | SELECT *
|
---|
3 | WHERE {
|
---|
4 | dbr:Belgium_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
5 | dbr:Belgium_in_the_Eurovision_Song_Contest_1956 dbp:entrant/rdfs:label ?entrant_lang_label.
|
---|
6 | }
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 | # get the language labels for the artist
|
---|
11 |
|
---|
12 | SELECT ?entrant ?entrant_lang_label WHERE {
|
---|
13 | dbr:Belgium_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
14 | {
|
---|
15 | SELECT ?entrant ?entrant_lang_label WHERE {
|
---|
16 | ?entrant rdfs:label ?entrant_lang_label
|
---|
17 | }
|
---|
18 | }
|
---|
19 | }
|
---|
20 |
|
---|
21 |
|
---|
22 | # Match the song and the artist, in cases where there are multiple entrants/songs for a country (e.g. 1956(
|
---|
23 |
|
---|
24 | SELECT ?entrant ?song WHERE {
|
---|
25 | dbr:Belgium_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
26 | dbr:Belgium_in_the_Eurovision_Song_Contest_1956 dbp:song ?song.
|
---|
27 | ?song dbp:artist ?entrant.
|
---|
28 |
|
---|
29 |
|
---|
30 | # More interesting example where 2 entries from France both have URI for artist and song
|
---|
31 | # matching goes correctly
|
---|
32 |
|
---|
33 | SELECT ?entrant ?song WHERE {
|
---|
34 | dbr:France_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
35 | dbr:France_in_the_Eurovision_Song_Contest_1956 dbp:song ?song.
|
---|
36 | ?song dbp:artist ?entrant.
|
---|
37 |
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | SELECT ?countries_in_esc_by_year ?country_in_year ?year ?country ?entrant ?song
|
---|
46 | WHERE {
|
---|
47 | ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
|
---|
48 |
|
---|
49 | ?country_in_year dct:subject ?countries_in_esc_by_year.
|
---|
50 | bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") as ?year).
|
---|
51 | FILTER ( xsd:integer(?year) < 2020).
|
---|
52 |
|
---|
53 | ?country_in_year dbp:country ?country.
|
---|
54 | ?country_in_year dbp:entrant ?entrant.
|
---|
55 | ?country_in_year dbp:song ?song
|
---|
56 | FILTER (isLITERAL(?entrant) || isLITERAL(?song))
|
---|
57 | # ?song rdfs:label ?song_label
|
---|
58 | # FILTER (lang(?song_label) = 'en').
|
---|
59 |
|
---|
60 |
|
---|
61 | }
|
---|
62 | ORDER BY DESC(?countries_in_esc_by_year)
|
---|
63 |
|
---|
64 |
|
---|
65 | ####
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 | SELECT ?countries_in_esc_by_year ?country_in_year ?year ?country ?entrant ?song_uri
|
---|
70 | WHERE {
|
---|
71 | ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
|
---|
72 |
|
---|
73 | ?country_in_year dct:subject ?countries_in_esc_by_year.
|
---|
74 | bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") as ?year).
|
---|
75 | FILTER ( xsd:integer(?year) < 2020).
|
---|
76 |
|
---|
77 | ?country_in_year dbp:country ?country.
|
---|
78 | ?country_in_year dbp:entrant ?entrant.
|
---|
79 | ?country_in_year dbp:song ?song
|
---|
80 | FILTER (isLITERAL(?song))
|
---|
81 | BIND(?song as ?song_uri)
|
---|
82 | # BIND (IF(isLITERAL(?song),URI(CONCAT("http://dbpedia.org/resource/", ?song)),?song) AS ?song_uri)
|
---|
83 |
|
---|
84 | }
|
---|
85 | ORDER BY DESC(?countries_in_esc_by_year)
|
---|
86 |
|
---|
87 | ####
|
---|
88 |
|
---|
89 |
|
---|
90 | SELECT ?countries_in_esc_by_year ?country_in_year ?year ?country ?entrant ?song_uri
|
---|
91 | WHERE {
|
---|
92 | ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
|
---|
93 |
|
---|
94 | ?country_in_year dct:subject ?countries_in_esc_by_year.
|
---|
95 | bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") as ?year).
|
---|
96 | FILTER ( xsd:integer(?year) < 2020).
|
---|
97 |
|
---|
98 | ?country_in_year dbp:country ?country.
|
---|
99 | ?country_in_year dbp:entrant ?entrant.
|
---|
100 | ?country_in_year dbp:song ?song
|
---|
101 | FILTER (isLITERAL(?song))
|
---|
102 | # BIND(?song as ?song_uri)
|
---|
103 |
|
---|
104 | BIND (IF(isLITERAL(?song),
|
---|
105 | REPLACE(?song,"^\"Amami se vuoi$","Amami se vuoi"), ?song) AS ?song_curated)
|
---|
106 |
|
---|
107 | BIND (IF(isLITERAL(?song_curated),URI(CONCAT("http://dbpedia.org/resource/", ?song_curated)),?song_curated) AS ?song_uri)
|
---|
108 |
|
---|
109 | }
|
---|
110 | ORDER BY DESC(?countries_in_esc_by_year)
|
---|
111 |
|
---|
112 | ##======
|
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 | SELECT ?countries_in_esc_by_year ?country_in_year ?year ?country ?entrant ?song_uri
|
---|
117 | WHERE {
|
---|
118 | ?countries_in_esc_by_year skos:broader dbc:Countries_in_the_Eurovision_Song_Contest_by_year.
|
---|
119 |
|
---|
120 | ?country_in_year dct:subject ?countries_in_esc_by_year.
|
---|
121 | bind( REPLACE(str(?country_in_year), ".*(\\d{4})", "$1") as ?year).
|
---|
122 | FILTER ( xsd:integer(?year) < 2020).
|
---|
123 |
|
---|
124 | ?country_in_year dbp:country ?country.
|
---|
125 | ?country_in_year dbp:entrant ?entrant.
|
---|
126 | ?country_in_year dbp:song ?song
|
---|
127 | FILTER (isLITERAL(?song))
|
---|
128 | BIND(?song as ?song_uri)
|
---|
129 |
|
---|
130 | BIND (IF(isLITERAL(?song),
|
---|
131 | REPLACE(?song,"^\"Amami se vuoi$","Amami se vuoi"), ?song) AS ?song_curated)
|
---|
132 |
|
---|
133 | # BIND (IF(isLITERAL(?song_curated),URI(CONCAT("http://dbpedia.org/resource/", ?song_curated)),?song_curated) AS ?song_uri)
|
---|
134 |
|
---|
135 | }
|
---|
136 |
|
---|
137 | #====
|
---|
138 |
|
---|
139 |
|
---|
140 |
|
---|
141 | INSERT DATA
|
---|
142 | {
|
---|
143 | <http://example/book1> dc:title "A new book" ;
|
---|
144 | dc:creator "A.N.Other" .
|
---|
145 | }
|
---|
146 |
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 | ### Trying to get federated search going
|
---|
152 | # but generated error:
|
---|
153 |
|
---|
154 | # Virtuoso 42000 Error SQ070:SECURITY: Must have SELECT privileges on view DB.DBA.SPARQL_SINV_2 for group ID 112 (SPARQL), user ID 112 (SPARQL)
|
---|
155 | #
|
---|
156 | # SPARQL query:
|
---|
157 | # define sql:big-data-const 0
|
---|
158 | #output-format:text/html
|
---|
159 | # define sql:signal-unconnected-variables 1
|
---|
160 | # define sql:signal-void-variables 1
|
---|
161 | # define input:default-graph-uri <http://dbpedia.org>
|
---|
162 | # SELECT ?entrant ?song WHERE {
|
---|
163 | # dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
164 | # SERVICE <https://bedrock.resnet.cms.waikato.ac.nz/sparql/greenstone/sparql> {
|
---|
165 | # dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:song ?song.
|
---|
166 | # }
|
---|
167 | #
|
---|
168 | #}
|
---|
169 |
|
---|
170 |
|
---|
171 | SELECT ?entrant ?song WHERE {
|
---|
172 | dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
173 | SERVICE <https://bedrock.resnet.cms.waikato.ac.nz/sparql/greenstone/sparql> {
|
---|
174 | dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:song ?song.
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | ## The following worked on local sparql endpoitn
|
---|
179 |
|
---|
180 | prefix dbr: <http://dbpedia.org/resource/>
|
---|
181 | prefix dbp: <http://dbpedia.org/property/>
|
---|
182 |
|
---|
183 | SELECT ?entrant ?song WHERE {
|
---|
184 | SERVICE <https://dbpedia.demo.openlinksw.com/sparql> {
|
---|
185 | dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:entrant ?entrant.
|
---|
186 | ?song dbp:artist ?entrant
|
---|
187 | }
|
---|
188 | dbr:Italy_in_the_Eurovision_Song_Contest_1956 dbp:song ?song
|
---|
189 | }
|
---|
190 |
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|