-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecartico-onstage-ex1.rq
71 lines (56 loc) · 2.89 KB
/
ecartico-onstage-ex1.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
#+ summary: What is the age of playwriters when their work is first performed?
#+ 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#>
# What is the age of playwriters when their work is first performed?
# Using: ECARTICO + ONSTAGE
# 2020-04-29
# Expected rows: 10
SELECT DISTINCT ?name ?birthYear (min(?performanceDate) as ?firstPerformance) ((year(?firstPerformance) - ?birthYear) as ?age) ?deathYear
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 a schema:CreativeWork ;
schema:creator ?personOnstage .
# A performance is played on a date. The play is based on the work.
?show a schema:Event ;
schema:startDate ?performanceDate ;
schema:subEvent*/schema:workPerformed ?work .
# Some birthDate and deathDate values are of type xsd:gYear. Cast them to integer.
BIND(IF(DATATYPE(?performanceDate) = xsd:gYear, xsd:integer(str(?performanceDate)), ?performanceDate) as ?performanceYear)
}
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 ?firstPerformance
HAVING(min(?performanceDate) < ?deathDate)
ORDER BY ?name