-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery5.sparql
60 lines (52 loc) · 2.29 KB
/
query5.sparql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX pfn: <https://polifonia-project.eu/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
CONSTRUCT {
?pilot_iri a pfn:pilot ;
rdfs:label ?pilot ;
pfn:hasPart ?part_iri ;
pfn:hasQuestion ?question_iri ;
pfn:hasAnswer ?answer_iri .
?part_iri pfn:hasQuestion ?question_iri ;
rdfs:label ?part ;
pfn:hasQuestion ?question_iri .
?question_iri pfn:hasAnswer ?answer_iri ;
rdfs:label ?question ;
?pilot_iri ?answer_text .
?answer_iri rdfs:label ?answer ;
rdfs:seeAlso ?question_iri .
}
WHERE {
SERVICE <x-sparql-anything:file:./surveyExtraction.xlsx> {
?r a fx:root ;
?p ?row .
?row rdf:_1 ?part ;
rdf:_2 ?question ;
rdf:_3 ?pilot ;
rdf:_4 ?answer .
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/pilot/", STR(ENCODE_FOR_URI(?pilot)))) as ?pilot_iri)
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/part/", STR(ENCODE_FOR_URI(?part)))) as ?part_iri)
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/question/", STR(ENCODE_FOR_URI(SHA1(?question))))) as ?question_iri)
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/answer/", STR(ENCODE_FOR_URI(SHA1(?answer))))) as ?answer_iri)
}
# Group answers by related questions and pilot
{
SELECT ?question_iri ?pilot_iri (GROUP_CONCAT(?answer; SEPARATOR="; ") AS ?answer_text) {
SERVICE <x-sparql-anything:file:./surveyExtraction.xlsx> {
?r a fx:root ;
?p ?row .
?row rdf:_1 ?part ;
rdf:_2 ?question ;
rdf:_3 ?pilot ;
rdf:_4 ?answer .
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/question/", STR(ENCODE_FOR_URI(SHA1(?question))))) as ?question_iri)
BIND(IRI(CONCAT("https://polifonia-project.eu/resource/pilot/", STR(ENCODE_FOR_URI(?pilot)))) as ?pilot_iri)
}
}
GROUP BY ?question_iri ?pilot_iri
}
}