-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
110 lines (86 loc) · 4.47 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
MAKEFLAGS += --no-builtin-rules
# Update with `python3 src/helper.py makefile > generated.mk`
include generated.mk
.PHONY: test extensions
.SECONDARY: # keep intermediate files
.DELETE_ON_ERROR:
ALL_PAIRS = $(shell python3 src/helper.py all_pairs)
ALL_LANGS = $(shell python3 src/helper.py all_langs)
ALL_RAW = $(addprefix dictionaries/raw/,$(addsuffix .sqlite3,${ALL_LANGS} ${ALL_PAIRS}))
ALL_PROCESSED_LANGS = $(addprefix dictionaries/processed/,$(addsuffix .sqlite3,${ALL_LANGS}))
ALL_PROCESSED_PAIRS = $(addprefix dictionaries/processed/,$(addsuffix .sqlite3,${ALL_PAIRS}))
ALL_PROCESSED = ${ALL_PROCESSED_LANGS} ${ALL_PROCESSED_PAIRS}
ALL_WDWEB_PAIRS = $(addprefix dictionaries/wdweb/,$(addsuffix .sqlite3,${ALL_PAIRS}))
ALL_WDWEB_LANGS = $(addprefix dictionaries/wdweb/,$(addsuffix .sqlite3,${ALL_LANGS}))
ALL_GENERIC = $(addprefix dictionaries/generic/,$(addsuffix .sqlite3,${ALL_PAIRS}))
all: venv wdweb check
raw: ${ALL_RAW} raw-check
processed: ${ALL_PROCESSED}
generic: ${ALL_GENERIC}
wdweb: ${ALL_WDWEB_PAIRS} ${ALL_WDWEB_LANGS}
test:
python3 -m unittest discover -s src
clean:
rm -fr dictionaries
distclean: clean
rm -fr venv
dictionaries/infer.sqlite3: ${ALL_PROCESSED}
rm -f dictionaries/infer.sqlite3
for langpair in ${ALL_PAIRS}; do src/run.py infer-collect $$langpair; done
src/run.py infer
.SECONDEXPANSION:
${ALL_RAW}: dictionaries/raw/%.sqlite3: virtuoso/ttl/$$(firstword $$(subst -, ,%)).inserted
src/run.py raw $*
raw-check:
for f in dictionaries/raw/*-*.sqlite3 ; do translations=$$(echo "SELECT count(*) FROM translation" | sqlite3 -noheader $$f) ; [ $$translations -eq 0 ] && echo "$$f has no translations!" || true ; done
${ALL_PROCESSED_LANGS}: dictionaries/processed/%.sqlite3: dictionaries/raw/%.sqlite3
src/run.py process $*
.SECONDEXPANSION:
${ALL_PROCESSED_PAIRS}: dictionaries/processed/%.sqlite3: dictionaries/raw/%.sqlite3 \
dictionaries/processed/$$(firstword $$(subst -, ,%)).sqlite3 \
dictionaries/processed/$$(word 2,$$(subst -, ,%)).sqlite3
src/run.py process $*
${ALL_GENERIC}: dictionaries/generic/%.sqlite3: dictionaries/processed/%.sqlite3 dictionaries/infer.sqlite3
src/run.py generic $*
.SECONDEXPANSION:
${ALL_WDWEB_PAIRS}: dictionaries/wdweb/%.sqlite3: \
dictionaries/processed/$$(firstword $$(subst -, ,%)).sqlite3 \
dictionaries/processed/$$(word 2,$$(subst -, ,%)).sqlite3 \
dictionaries/generic/%.sqlite3 \
dictionaries/generic/$$(firstword $$(subst -, ,%))-$$(word 2,$$(subst -, ,%)).sqlite3 \
dictionaries/infer.sqlite3
src/run.py wdweb $*
${ALL_WDWEB_LANGS}: dictionaries/wdweb/%.sqlite3: dictionaries/processed/%.sqlite3
src/run.py wdweb $*
venv:
python3 -m venv venv
venv/bin/pip install -r requirements.txt
check:
find . -name '*.sqlite3' -empty | grep . && echo 'WARNING: Empty databases found!' || echo 'Results look ok' ; true
release-web:
rsync -avz --progress -e ssh dictionaries/wdweb/ www.wikdict.com:wikdict-prod/data/$(shell date +%Y-%m)
#scp -rC dictionaries/wdweb/ www.wikdict.com:wikdict-prod/data/$(shell date +%Y-%m)
ssh www.wikdict.com ln -sfT $(shell date +%Y-%m) wikdict-prod/data/dict
release-sitemap:
rsync -avz --progress -e ssh sitemap www.wikdict.com:wikdict-prod/static
release-download:
rsync -avz --progress -e ssh dictionaries/generic/ www.wikdict.com:hosts/download/dictionaries/sqlite/2_$(shell date +%Y-%m)
rsync -avz --progress -e ssh dictionaries/processed/??.sqlite3 www.wikdict.com:hosts/download/dictionaries/sqlite/2_$(shell date +%Y-%m)
ssh www.wikdict.com ln -sfT 2_$(shell date +%Y-%m) hosts/download/dictionaries/sqlite/2
release-tei:
rsync -avz --progress -e ssh dictionaries/tei/* www.wikdict.com:hosts/download/dictionaries/tei/recommended
release-tei-noinfl:
rsync -avz --progress -e ssh dictionaries/tei/* www.wikdict.com:hosts/download/dictionaries/tei/no-infl
dictionaries/kobo/dicthtml-%.zip:
pyglossary $< $@ --write-format Kobo
dictionaries/stardict/%.zip: dictionaries/stardict/%
cd $</.. && zip -r `basename $@` `basename $<`
dictionaries/stardict/%:
mkdir -p $@
pyglossary $< $@/stardict --write-format Stardict
# These will be missing prerequisites in some cases (small dicts), just use `make --keep-going`.
kobo: $(shell grep kobo/dicthtml generated.mk | cut -d: -f1)
stardict: $(shell grep stardict generated.mk | awk -F ':' '{print $$1 ".zip"}')
release-converted:
rsync -avz --progress -e ssh dictionaries/kobo/*.zip www.wikdict.com:hosts/download/dictionaries/kobo
rsync -avz --progress -e ssh dictionaries/stardict/*.zip www.wikdict.com:hosts/download/dictionaries/stardict