forked from openvanilla/McBopomofo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (114 loc) · 4.26 KB
/
Copy pathMakefile
File metadata and controls
135 lines (114 loc) · 4.26 KB
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
PYTHON ?= python3
.PHONY: sort clean format typecheck analyze
all: data.txt data-plain-bpmf.txt associated-phrases-v2.txt
install: all
data-plain-bpmf.txt: curation/compilers/plain_bpmf_compiler.py \
curation/compilers/compiler_utils.py \
BPMFBase.txt BPMFPunctuations.txt
$(PYTHON) -m curation.compilers.plain_bpmf_compiler \
--bpmf_base BPMFBase.txt \
--punctuations BPMFPunctuations.txt \
--output data-plain-bpmf.txt
data-raw.txt: curation/compilers/main_compiler.py \
curation/compilers/compiler_utils.py \
BPMFBase.txt BPMFMappings.txt BPMFPunctuations.txt \
PhraseFreq.txt phrase.occ Symbols.txt Macros.txt \
heterophony1.list heterophony2.list heterophony3.list
$(PYTHON) -m curation.compilers.main_compiler \
--heterophony1 heterophony1.list \
--heterophony2 heterophony2.list \
--heterophony3 heterophony3.list \
--phrase_freq PhraseFreq.txt \
--bpmf_mappings BPMFMappings.txt \
--bpmf_base BPMFBase.txt \
--punctuations BPMFPunctuations.txt \
--symbols Symbols.txt \
--macros Macros.txt \
--output data-raw.txt
data.txt: curation/compilers/postprocess.py curation/mandarin/grid.py data-raw.txt Postprocess.txt
$(PYTHON) -m curation.compilers.postprocess \
--input data-raw.txt \
--directive Postprocess.txt \
--output data.txt
associated-phrases-v2.txt: data.txt curation/builders/phrase_deriver.py associated-punctuation.txt
$(PYTHON) -m curation.builders.phrase_deriver $< $@ associated-punctuation.txt
PhraseFreq.txt: curation/builders/frequency_builder.py phrase.occ exclusion.txt
$(PYTHON) -m curation.builders.frequency_builder
clean:
rm -f data.txt data-plain-bpmf.txt phrase.list
# FOR INTERNAL USE
_install: tidy sort check all
@cp -a data.txt data-plain-bpmf.txt $(HOME)/Library/Input\ Methods/McBopomofo.app/Contents/Resources/
@pkill -HUP -f McBopomofo || echo McBopomofo is not running
_deploy: _install
@rsync -avx data.txt data-plain-bpmf.txt $(RHOST):"Library/Input\ Methods/McBopomofo.app/Contents/Resources/"
@test "$(RHOST)" && ssh $(RHOST) "pkill -HUP -f McBopomofo || echo McBopomofo is not running" || true
sort: SHELL:=/bin/bash
sort: export LC_ALL=C
sort:
@env LC_ALL=C sort -k1 phrase.occ | uniq | grep -v '^$$' > tmp
@mv tmp phrase.occ
@env LC_ALL=C sort -k1 BPMFMappings.txt | uniq | grep -v '^$$' > tmp
@mv tmp BPMFMappings.txt
@env LC_ALL=C sort -k1 heterophony1.list|uniq>tmp
@mv tmp heterophony1.list
@env LC_ALL=C sort -k1 heterophony2.list|uniq>tmp
@mv tmp heterophony2.list
@env LC_ALL=C sort -k1 heterophony3.list|uniq>tmp
@mv tmp heterophony3.list
@env LC_ALL=C sort -k1 exclusion.txt|uniq>tmp
@mv tmp exclusion.txt
@env LC_ALL=C sort -k1 Symbols.txt | uniq | grep -v '^$$' > tmp
@mv tmp Symbols.txt
check: SHELL:=/bin/bash
check: export LC_ALL=C
check:
@python3 scripts/check.py
tidy:
@sed -i '' -e 's/ //g' phrase.occ
@sed -i '' -e 's/ / /g;s/ / /g;s/ $$//g' BPMFMappings.txt
@sed -i '' -e 's/|/ㄧ/g;s/ / /g' BPMFMappings.txt
@sed -i '' -e 's/ [:0-9:]*$$//g' BPMFMappings.txt
@sed -i '' -e 's/1/˙/g;s/2/ˊ/g;s/3/ˇ/g;s/4/ˋ/g' BPMFMappings.txt
_phrase.occ: phrase.list
@$(PYTHON) scripts/count_occurrences.py phrase.list > tmp && mv tmp phrase.occ
phrase.list: BPMFBase.txt BPMFMappings.txt
awk 'length($$1)<4{print $$1}' BPMFBase.txt > tmp
awk '{print $$1}' BPMFMappings.txt >> tmp
sort -u tmp | uniq > phrase.list
_myclean:
cd ../.. && xcodebuild -derivedDataPath build clean
_myprodbuild:
cd ../.. && \
xcodebuild \
-scheme McBopomofo \
-configuration Release \
-derivedDataPath build \
build
_mydebugbuild:
cd ../.. && \
xcodebuild \
-scheme McBopomofo \
-configuration Debug \
-derivedDataPath build \
build
_mycodecheck:
@for myfile in curation/*/*.py scripts/*.py; do \
pycodestyle --ignore=E501,E722,E701,E221,W605 $$myfile; \
done
format:
black \
curation/analyzers/find_cover_issues.py \
curation/mandarin/*.py \
curation/compilers/postprocess.py \
curation/utils/lmreader.py \
tests/*.py
typecheck:
mypy \
curation/analyzers/find_cover_issues.py \
curation/compilers/postprocess.py
ANALYZE_LIMIT = 50
analyze: curation/analyzers/find_cover_issues.py data.txt
$(PYTHON) -m curation.analyzers.find_cover_issues \
--input data.txt \
--limit $(ANALYZE_LIMIT)