-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
250 lines (211 loc) · 6.25 KB
/
Makefile
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
.DEFAULT_GOAL := all
SHELL := /usr/bin/env bash
.SHELLFLAGS := -o pipefail -O globstar -c
ROBOT_REPO := https://github.com/ontodev/robot
ROBOT_DIR := tools/robot
ROBOT := $(ROBOT_DIR)/bin/robot
HERMIT_HOST := http://www.hermit-reasoner.com/download/1.3.8
HERMIT_DIR := tools/hermit
HERMIT := $(HERMIT_DIR)/bin/hermit
UNSTAR_HOST := https://raw.githubusercontent.com/rybesh/unstar/main/dist
UNSTAR_DIR := tools/unstar
UNSTAR := $(UNSTAR_DIR)/unstar
VENV_DIR := tools/venv
PYTHON := $(VENV_DIR)/bin/python
PYLODE := $(VENV_DIR)/bin/pylode
RDFPIPE := $(VENV_DIR)/bin/rdfpipe
EDTFO := https://periodo.github.io/edtf-ontology
RPO := http://josd.github.io/eye/reasoning/rpo
CASES := $(dir $(shell find cases/level-? -name edtf.ttl))
LEVEL_0 := $(dir $(shell find cases/level-0 -name edtf.ttl))
LEVEL_1 := $(dir $(shell find cases/level-1 -name edtf.ttl))
LEVEL_2 := $(dir $(shell find cases/level-2 -name edtf.ttl))
RULESETS := \
rdfs-domain \
rdfs-range \
rdfs-subClassOf \
owl-hasValue
# Tools ########################################################################
$(PYTHON):
python3 -m venv $(VENV_DIR)
$(PYTHON) -m pip install --upgrade pip
$(RDFPIPE): | $(PYTHON)
$(PYTHON) -m pip install rdflib
$(PYLODE): | $(PYTHON)
$(PYTHON) -m pip install pyLODE==2.13.2
$(ROBOT):
mkdir -p $(ROBOT_DIR)/bin
curl -L $(ROBOT_REPO)/releases/download/v1.8.1/robot.jar \
> $(ROBOT_DIR)/bin/robot.jar
curl -L $(ROBOT_REPO)/raw/master/bin/robot > $@
chmod +x $@
$(HERMIT):
mkdir -p $(HERMIT_DIR)/bin
curl -L $(HERMIT_HOST)/HermiT.zip \
> $(HERMIT_DIR)/hermit.zip
unzip $(HERMIT_DIR)/hermit.zip -d $(HERMIT_DIR)/bin
rm $(HERMIT_DIR)/hermit.zip
echo "#! /bin/sh" > $@
echo "DIR=\$$(dirname \$$0)" >> $@
echo "exec java -jar \"\$$DIR/HermiT.jar\" \"\$$@\"" >> $@
chmod +x $@
$(UNSTAR):
curl $(UNSTAR_HOST)/unstar.tgz | tar -C tools -xzf -
# Ontology docs ################################################################
doc/html/index.html: edtfo.ttl tools/diagram.sed | $(PYLODE)
riot -q --validate $<
$(PYLODE) -c false -i $< -o $@
sed -f tools/diagram.sed -i "" $@
doc/html/report.html: edtfo.ttl tools/report-profile.txt | $(ROBOT)
riot -q --validate $<
$(ROBOT) report --input $< --output $@ \
--profile tools/report-profile.txt
merged.ttl: edtfo.ttl | $(ROBOT)
riot -q --validate $<
$(ROBOT) merge --input $< --output $@
doc/html/validation.txt: merged.ttl | $(ROBOT)
$(ROBOT) validate-profile --input $< --output $@ --profile Full
# Utils ########################################################################
cache/%.n3:
mkdir -p cache
curl -L $(RPO)/$*.n3 > $@
ruleset_urls := $(foreach ruleset,$(RULESETS),$(RPO)/$(ruleset).n3)
cached_rulesets := $(foreach ruleset,$(RULESETS),cache/$(ruleset).n3)
rules/derived/regexes.n3: rules/regexes.n3
mkdir -p rules/derived
eye --quiet $^ --pass-only-new > $@
joinwith = $(subst $(eval) ,$1,$2)
rulepath = $(call joinwith,/,$(wordlist 1,2,$(subst /, , $1)))
# Cases ########################################################################
cases/level-1/interval/qualified-%/owltime-raw.ttl: \
rules/regexes.n3 \
rules/derived/regexes.n3 \
rules/common.n3 \
rules/level-1/qualification/rules.n3 \
rules/level-1/interval/rules.n3 \
cases/level-1/interval/qualified-%/edtf.ttl \
| $(cached_rulesets)
eye \
--quiet \
--nope \
--wcache $(RPO) cache \
$(ruleset_urls) \
$^ \
--pass \
> $@
cases/level-2/interval/qualified-%/owltime-raw.ttl: \
rules/regexes.n3 \
rules/derived/regexes.n3 \
rules/common.n3 \
rules/level-2/qualification/rules.n3 \
rules/level-2/interval/rules.n3 \
cases/level-2/interval/qualified-%/edtf.ttl \
| $(cached_rulesets)
eye \
--quiet \
--nope \
--wcache $(RPO) cache \
$(ruleset_urls) \
$^ \
--pass \
> $@
cases/level-2/interval/unspecified-%/owltime-raw.ttl: \
rules/regexes.n3 \
rules/derived/regexes.n3 \
rules/common.n3 \
rules/level-2/unspecified/rules.n3 \
rules/level-2/interval/rules.n3 \
cases/level-2/interval/unspecified-%/edtf.ttl \
| $(cached_rulesets)
eye \
--quiet \
--nope \
--wcache $(RPO) cache \
$(ruleset_urls) \
$^ \
--pass \
> $@
.SECONDEXPANSION:
cases/%/owltime-raw.ttl: \
rules/regexes.n3 \
rules/derived/regexes.n3 \
rules/common.n3 \
rules/$$(call rulepath,$$*)/rules.n3 \
cases/%/edtf.ttl \
| $(cached_rulesets)
eye \
--quiet \
--nope \
--skolem-genid "$*" \
--wcache $(RPO) cache \
$(ruleset_urls) \
$^ \
--pass \
> $@
cases/%/owltime.ttl: \
cases/%/owltime-raw.ttl \
tools/cleanup-inferences.rq \
| $(UNSTAR) $(RDFPIPE)
arq --data=$< --query=$(word 2,$^) \
| $(UNSTAR) - \
| $(RDFPIPE) -i turtle -o longturtle - \
| ./tools/unuuid/unuuid.py \
| sed -E "s|http://josd.github.io|https://periodo.github.io/edtf-ontology|" \
| sed -E "s|[[:space:]]{4}| |g" \
> $@
./tools/check-triple-count $@
cases_owltime := $(foreach case,$(CASES),$(case)owltime.ttl)
level0_owltime := $(foreach case,$(LEVEL_0),$(case)owltime.ttl)
level1_owltime := $(foreach case,$(LEVEL_1),$(case)owltime.ttl)
level2_owltime := $(foreach case,$(LEVEL_2),$(case)owltime.ttl)
# Phony targets ################################################################
# check that : prefix matches filename
check_prefixes: $(cases_owltime)
./tools/check-prefixes
check_turtle_syntax: $(cases_owltime)
riot -q --validate cases/level-?/**/*.ttl
check_invalid_cases:
./tools/check-invalid-cases
check_cases: check_prefixes check_turtle_syntax check_invalid_cases
all: \
doc/html/report.html \
doc/html/validation.txt \
doc/html/index.html \
check_cases
level0: $(level0_owltime)
level1: $(level1_owltime)
level2: $(level2_owltime)
watch:
ls edtfo.ttl | entr make -s doc/html/report.html
serve: | $(PYTHON)
$(PYTHON) -m http.server -b 127.0.0.1 -d doc/html
publish: all
./tools/publish
clean_cases:
rm -f $(cases_owltime)
rm -f $(subst owltime.ttl,owltime-raw.ttl,$(cases_owltime))
clean: clean_cases
rm -rf $(VENV_DIR) $(ROBOT_DIR) $(HERMIT_DIR) \
rm -rf rules/derived cache \
doc/html/index.html doc/html/report.html doc/html/validation.txt \
.PRECIOUS: \
cache/%.n3 \
cases/%/owltime.ttl \
cases/level-1/qualification/%/owltime.ttl \
cases/level-1/interval/qualified-%/owltime.ttl \
cases/level-2/qualification/%/owltime.ttl \
cases/level-2/interval/qualified-%/owltime.ttl
.PHONY: \
check_prefixes \
check_turtle_syntax \
check_cases \
check_invalid_cases \
all \
level0 \
level1 \
level2 \
watch \
serve \
publish \
clean \
clean_cases