-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathga-ecartico-onstage-ex1.rq
56 lines (44 loc) · 1.91 KB
/
ga-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
#+ summary: What is the age of playwriters when their work is first performed? In Golden Agents ontology.
#+ endpoint: https://sparql.diginfra.net/sparql
#+ method: GET
#+ tags:
#+ - ecartico
#+ - onstage
#+ - linkset
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ga: <https://data.goldenagents.org/ontology/>
# What is the age of playwriters when their work is first performed?
# Using: ECARTICO + ONSTAGE through Golden Agents ontology
# 2020-03-20
# Expected rows: 13
SELECT DISTINCT ?name ?birthYear (min(?performanceDate) as ?firstPerformance) ((year(?firstPerformance) - ?birthYear) as ?age) ?deathYear
WHERE {
?person a ga:CreativeAgent .
# {
# ?personOnstage owl:sameAs* ?personEcartico .
# } UNION {
# ?personEcartico owl:sameAs* ?personOnstage .
# }
# Biographic information
?person ga:hasName ?name ;
ga:birthDate ?birthDate ;
ga:deathDate ?deathDate .
# 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)
# A work is written by a person.
?person ga:authorOf ?work .
# A work is performed.
?work a ga:Story ;
ga:performedAs/ga:subEventOf* ?performance .
# A performance is played on a date.
?performance a ga:CreativeAct ;
ga:startDate ?performanceDate .
# Some birthDate and deathDate values are resources (schema:StructuredValue). Filter those out.
FILTER (!ISURI(?birthDate) && !ISURI(?deathDate))
}
GROUP BY ?person ?name ?birthYear ?deathYear
HAVING(year(?firstPerformance) <= ?deathYear)
ORDER BY ?name