-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecartico-onstage-ex2.rq
72 lines (57 loc) · 2.85 KB
/
ecartico-onstage-ex2.rq
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
61
62
63
64
65
66
67
68
69
70
71
72
#+ summary: How many plays were made and performed during a playwriter's life?
#+ endpoint: https://sparql.diginfra.net/sparql
#+ method: GET
#+ tags:
#+ - ecartico
#+ - onstage
#+ - linkset
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# How many plays were made and performed during a playwriter's life?
# Using: ECARTICO + ONSTAGE
# 2020-04-29
# Expected rows: 10
SELECT DISTINCT ?name ?birthYear (min(?performanceDate) as ?firstPerformanceAlive) (max(?performanceDate) as ?lastPerformanceAlive) ?deathYear
(COUNT(DISTINCT ?work) as ?works) (COUNT(DISTINCT ?show) as ?shows)
(COUNT(DISTINCT ?performingEvent) as ?performances)
WHERE {
GRAPH <https://data.goldenagents.org/datasets/ufab7d657a250e3461361c982ce9b38f3816e0c4b/ecartico_20200316/> {
# Biographic info
?personEcartico a schema:Person ;
schema:name ?name ;
schema:birthDate ?birthDate ;
schema:deathDate ?deathDate .
# Some birthDate and deathDate values are resources (schema:StructuredValue). Filter those out.
FILTER (!ISURI(?birthDate) && !ISURI(?deathDate))
FILTER (DATATYPE(?birthDate) = xsd:date) # please, format all dates in xsd:date...
FILTER (DATATYPE(?deathDate) = xsd:date) # please, format all dates in xsd:date...
# Some birthDate and deathDate values are of type xsd:gYear. Cast them to integer.
BIND(IF(DATATYPE(?birthDate) = xsd:date, year(?birthDate), xsd:integer(substr(str(?birthDate), 0, 4))) as ?birthYear)
BIND(IF(DATATYPE(?deathDate) = xsd:date, year(?deathDate), xsd:integer(substr(str(?deathDate), 0, 4))) as ?deathYear)
}
GRAPH <https://data.goldenagents.org/datasets/ufab7d657a250e3461361c982ce9b38f3816e0c4b/onstage_20200316/> {
?personOnstage a schema:Person .
# A work is written by a person.
?work schema:creator ?personOnstage .
# A performance is played on a date and has one or multiple subevents.
?show schema:startDate ?performanceDate ;
schema:subEvent ?performingEvent .
# The play is based on the work.
?performingEvent schema:workPerformed ?work .
}
# Only performances during a person's life
FILTER(year(?performanceDate) <= ?deathYear)
GRAPH ?linkset {
{
?personOnstage ?link ?personEcartico
} UNION {
?personEcartico ?link ?personOnstage
}
}
FILTER(?linkset = <https://data.goldenagents.org/datasets/ufab7d657a250e3461361c982ce9b38f3816e0c4b/linkset_ecartico_onstage_sameas_including_external_links_20190218/> ||
?linkset = <https://data.goldenagents.org/datasets/ufab7d657a250e3461361c982ce9b38f3816e0c4b/linkset_onstage_ecartico_sameas_20190218/> )
}
GROUP BY ?personEcartico ?name ?birthYear ?deathYear ?deathDate
ORDER BY ?name