-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (46 loc) · 2.24 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
# Ducks Project
data/ducks/temp:
mkdir -p data/ducks/temp
## get a list of all duck names for reconciliation with wikidata
data/ducks/temp/duck_names.csv: data/ducks/temp
arq --query queries/all_ducks.rq --data data/ducks/ducks.ttl --results=csv > $@
## some names won't work as is, so we need to fix the list a bit
data/ducks/temp/duck_names_fixed.csv: data/ducks/temp/duck_names.csv
sed "1d" $< | sed "s/Abner Duck/Whitewater Duck/" | sed -E "s/(Dewey|Huey|Louie)/& Duck/" > $@
## get the matching wikidata items using wdreconcile
data/ducks/temp/wikidata_ducks.csv: data/ducks/temp/duck_names_fixed.csv
python bin/reconcile_with_wikidata.py --input $< --output $@
## revert the name changes from earlier
data/ducks/temp/wikidata_ducks_fixed.csv: data/ducks/temp/wikidata_ducks.csv
sed -E 's/(Dewey|Huey|Louie) Duck/\1/g' $< | sed -E 's/Whitewater/Abner/g' > $@
## generate a turtle file with wikidata items and labels
data/ducks/temp/wikidata_ducks.ttl: data/ducks/temp/wikidata_ducks_fixed.csv
python bin/turtle_from_csv.py --input $< > $@
## merge wikidata ducks with our ducks
data/ducks/temp/ducks_merged.ttl: data/ducks/temp/wikidata_ducks.ttl data/ducks/ducks.ttl
rdfpipe -i turtle $^ > $@
## generate links between our ducks and the wikidata ducks
data/ducks/temp/wikidata_links.ttl: data/ducks/temp/ducks_merged.ttl
arq --query queries/join_wikidata.rq --data $< > $@
## get duck names in other languages by querying wikidata's SPARQL endpoint
data/ducks/temp/wikidata_labels.ttl: data/ducks/ducks.ttl data/ducks/temp/wikidata_links.ttl
python bin/get_wikidata_labels.py --ducks $< --links $(word 2,$^) > $@
## finally, merge everything
data/ducks/all.ttl: data/ducks/ducks.ttl data/ducks/temp/wikidata_labels.ttl data/ducks/temp/wikidata_links.ttl
rdfpipe -i turtle $^ > $@
clean-ducks:
rm -rf data/ducks/temp
# data/ducks/duck_names_fixed.txt: data/ducks/duck_names.csv
data/all.ttl: data/ducks.ttl data/wikidata_labels.ttl data/wikidata_links.ttl
rdfpipe -i turtle $^ > $@
generate-ducks:
python bin/generate.py --config config/ducks.yml
generate-ducks+serve_locally:
python bin/generate.py --config config/ducks.yml --site_url http://localhost:8000 --serve
_site:
mkdir _site
data/temp:
mkdir data/temp
clean:
rm -rf _site
rm -rf data/temp