-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaterialization.ttl
54 lines (49 loc) · 1.82 KB
/
materialization.ttl
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
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ff: <https://foerderfunke.org/default#> .
# MATERIALIZATION RULES
ff:CalculateAgeFromBirthdate a ff:MaterializationRule, ff:SparqlRule ;
rdfs:label "Calculate the age from the birthdate" ;
ff:input ff:hasBirthday ;
ff:output ff:hasAge ;
ff:suggestPermanentMaterialization true ;
ff:ifPermanentlyMaterializedAddPeriodicCheck "on-app-startup" ;
ff:sparqlConstructQuery """
PREFIX ff: <https://foerderfunke.org/default#>
CONSTRUCT {
?person ff:hasAge ?age .
} WHERE {
?person ff:hasBirthday ?bday .
BIND(YEAR(NOW()) - YEAR(?bday) - IF(MONTH(NOW()) < MONTH(?bday) || (MONTH(NOW()) = MONTH(?bday) && DAY(NOW()) < DAY(?bday)), 1, 0) AS ?age) .
}
""" .
ff:DeriveStateFromCity a ff:MaterializationRule, ff:SparqlRule ;
rdfs:label "Derive the federal state someone lives in based on their residence city" ;
ff:input ff:hasResidence ;
ff:output ff:residesInState ;
ff:sparqlConstructQuery """
PREFIX ff: <https://foerderfunke.org/default#>
CONSTRUCT {
?person ff:residesInState ?state .
} WHERE {
?person ff:hasResidence ?city .
ff:CityStateMap ff:mappedCityToState ?mapping .
?mapping ff:city ?city ;
ff:state ?state .
}
""" .
# CONSTANTS
ff:CityStateMap a ff:MapOfConstants ;
rdfs:comment "Mapping of German cities to their respective federal states (Bundesland)" ;
ff:mappedCityToState [
ff:city "Jena" ;
ff:state "Thüringen"
] ;
ff:mappedCityToState [
ff:city "München" ;
ff:state "Bayern"
] ;
ff:mappedCityToState [
ff:city "Berlin" ;
ff:state "Berlin"
] .