-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.am
330 lines (247 loc) · 10.9 KB
/
Makefile.am
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
###############################################################################
## Makefile for Northern Sámi--Bokmål
###############################################################################
LANG1=sme
LANG2=nob
PREFIX1=$(LANG1)-$(LANG2)
PREFIX2=$(LANG2)-$(LANG1)
BASENAME=apertium-$(PREFIX1)
TARGETS_COMMON = \
$(PREFIX1).automorf.hfst \
$(PREFIX1).automorf-untrimmed.hfst \
$(PREFIX1).mor.rlx.bin \
$(PREFIX1).syn.rlx.bin \
$(PREFIX1).lex.bin \
$(PREFIX1).autobil.bin \
$(PREFIX1).autogen.bin \
$(PREFIX1).t1x.bin \
$(PREFIX1).t2x.bin \
$(PREFIX1).t3x.bin \
$(PREFIX1).t4x.bin \
$(PREFIX1).rtx.bin \
$(PREFIX2).automorf-untrimmed.bin \
$(PREFIX1).autoseq.bin \
$(LANG2).autoseq.bin
# last one is technically nob→sme, but handy for debugging
# This include defines goals for install-modes, .deps/.d and .mode files:
@ap_include@
# simple make just builds sme-nob, `make nob-sme' to try nob-sme
nob-sme: $(TARGETS2)
TARGETS2 = \
$(PREFIX2).autogen.hfst \
$(PREFIX2).autobil.bin \
$(PREFIX2).automorf.bin \
$(PREFIX2).prob \
$(PREFIX2).rlx.bin \
$(PREFIX2).t1x.bin \
$(PREFIX2).automorf.bin
debug: \
$(BASENAME).$(PREFIX1).mor.rlx \
$(BASENAME).$(PREFIX1).syn.rlx \
$(BASENAME).$(PREFIX2).rlx \
$(PREFIX1).val.bin
# Fast build – nearly everything but dictionaries:
r: modes/$(PREFIX1).mode \
$(PREFIX1).t1x.bin $(PREFIX1).t2x.bin $(PREFIX1).t3x.bin $(PREFIX1).t4x.bin \
$(PREFIX1).lex.bin \
$(PREFIX1).autoseq.bin \
$(LANG2).autoseq.bin \
$(PREFIX1).rtx.bin
# debug/devel/temporary stuff:
nouns-nob-sme: nob-sme dev/nouns-nob-sme/$(PREFIX2).t1x.bin dev/nouns-nob-sme/$(PREFIX2).rlx.bin modes/nouns-nob-sme.mode
dev/nouns-nob-sme/$(PREFIX2).rlx.bin: dev/nouns-nob-sme/$(BASENAME).$(PREFIX2).rlx
cg-comp $< $@
dev/nouns-nob-sme/$(PREFIX2).t1x.bin: dev/nouns-nob-sme/$(BASENAME).$(PREFIX2).t1x
apertium-validate-transfer $<
apertium-preprocess-transfer $< $@
###############################################################################
## Monolingual transducers
###############################################################################
# Override prefixes from ap_include, since we need the derivation-pos-changes:
.deps/%.autobil.prefixes: %.autobil.bin .deps/.d
lt-print -H $< >.deps/$*.autobil.att
hfst-txt2fst --disjunct -i .deps/$*.autobil.att | hfst-minimise -o .deps/$*.autobil.hfst
hfst-project -p upper .deps/$*.autobil.hfst -o .deps/$*.autobil.upper # bidix
echo '[ "<n>" -> [ "<n>" | "<ex_n>" ] ] .o. [ "<adj>" -> [ "<adj>" | "<ex_adj>" ] ] .o. [ "<vblex>" -> [ "<vblex>" |"<ex_vblex>" ] ] .o. [ "<iv>" -> [ "<iv>" | "<ex_iv>" ] ] .o. [ "<tv>" -> [ "<tv>" | "<ex_tv>" ] ]' \
| hfst-regexp2fst -o .deps/$*.derivpos.hfst
hfst-compose -1 .deps/$*.autobil.upper -2 .deps/$*.derivpos.hfst -o .deps/$*.autobil-derivpos.hfst
hfst-project -p lower .deps/$*.autobil-derivpos.hfst -o .deps/$*.autobil-derivpos.hfsa # bidix with n -> n|ex_n
echo ' [ ? - %+ ]* ' | hfst-regexp2fst > .deps/$*.any-nonplus.hfst # [^+]*
hfst-concatenate -1 .deps/$*.autobil-derivpos.hfsa -2 .deps/$*.any-nonplus.hfst -o .deps/$*.autobil.nonplussed # bidix [^+]*
echo ' %+ ' | hfst-regexp2fst > .deps/$*.single-plus.hfst # +
hfst-concatenate -1 .deps/$*.single-plus.hfst -2 .deps/$*.autobil.nonplussed -o .deps/$*.autobil.postplus # + bidix [^+]*
hfst-repeat -f0 -t2 -i .deps/$*.autobil.postplus -o .deps/$*.autobil.postplus.0,2 # (+ bidix [^+]*){0,2} -- gives at most two +
hfst-concatenate -1 .deps/$*.autobil.nonplussed -2 .deps/$*.autobil.postplus.0,2 -o $@ # bidix [^+]* (+ bidix [^+]*){0,2}
# -------------------
# Northern Saami analysis:
# -------------------
.deps/$(LANG1).automorf.hfst: $(AP_SRC1)/apertium-und.$(LANG1)-und.LR.att.gz .deps/.d
$(ZCAT) $< | hfst-txt2fst > $@
.deps/$(PREFIX1).automorf-rmderiv-trimmed.hfst: .deps/$(LANG1).automorf-rmderiv.hfst .deps/$(PREFIX1).autobil.prefixes
hfst-compose-intersect -1 $< -2 .deps/$(PREFIX1).autobil.prefixes -o $@
.deps/rm-deriv-cmp.hfst: rm-deriv-cmp.twol .deps/.d
hfst-twolc -i $< -o $@
.deps/$(LANG1).automorf-rmderiv.hfst: .deps/$(LANG1).automorf.hfst .deps/rm-deriv-cmp.hfst
hfst-compose-intersect -1 $< -2 .deps/rm-deriv-cmp.hfst -o $@
.deps/$(PREFIX1).automorf-rmderiv-trimmed-min.hfst: .deps/$(PREFIX1).automorf-rmderiv-trimmed.hfst
hfst-minimize -i $< -o $@
$(PREFIX1).automorf.hfst: .deps/$(PREFIX1).automorf-rmderiv-trimmed-min.hfst
hfst-fst2fst -w -i $< -o $@
$(PREFIX1).automorf-untrimmed.hfst: .deps/$(LANG1).automorf.hfst
hfst-fst2fst -w -i $< -o $@
# -------------------
# Northern Saami generation:
# ---------------------
.deps/$(LANG1).autogen.hfst: $(AP_SRC1)/apertium-$(LANG1).$(LANG1).RL.att.gz .deps/.d
$(ZCAT) $< | hfst-txt2fst > $@
$(PREFIX2).autogen.hfst: .deps/$(LANG1).autogen.hfst
hfst-fst2fst -O -i $< -o $@
# --------------------------
# Norwegian Bokmål analysis:
# --------------------------
$(PREFIX2).automorf-untrimmed.bin: $(AP_SRC2)/$(LANG2).automorf.bin
cp $< $@
$(PREFIX2).automorf.bin: $(AP_SRC2)/$(LANG2).automorf.bin $(PREFIX2).autobil.bin
lt-trim $^ $@
# -------------------
# Norwegian Bokmål generation:
# ---------------------
$(PREFIX1).autogen.bin: $(AP_SRC2)/$(LANG2).autogen.bin
cp $< $@
###############################################################################
## Disambiguation rules
###############################################################################
$(PREFIX1).mor.rlx.bin: $(AP_SRC1)/$(LANG1).mor.rlx.bin
cp $< $@
$(PREFIX1).syn.rlx.bin: $(AP_SRC1)/$(LANG1).syn.rlx.bin
cp $< $@
$(PREFIX2).rlx.bin: $(AP_SRC2)/$(LANG2).rlx.bin
cp $< $@
$(PREFIX2).prob: $(AP_SRC2)/$(LANG2).prob
cp $< $@
# Debug goals:
$(BASENAME).$(PREFIX1).mor.rlx: $(AP_SRC1)/disambiguator-mt-gt.cg3
cp $< $@
$(BASENAME).$(PREFIX1).syn.rlx: $(AP_SRC1)/functions-mt-gt.cg3
cp $< $@
$(BASENAME).$(PREFIX2).rlx: $(AP_SRC2)/apertium-$(LANG2).$(LANG2).rlx
cp $< $@
###############################################################################
## Separable / discontiguous multiwords
###############################################################################
$(PREFIX1).autoseq.bin: $(BASENAME).$(PREFIX1).lsx
lsx-comp lr $< $@
$(PREFIX2).autoseq.bin: $(BASENAME).$(PREFIX2).lsx
lsx-comp lr $< $@
$(LANG1).autoseq.bin: $(BASENAME).$(LANG1).lsx
lsx-comp lr $< $@
$(LANG2).autoseq.bin: $(BASENAME).$(LANG2).lsx
lsx-comp lr $< $@
###############################################################################
## Bilingual dictionaries
###############################################################################
$(PREFIX1).autobil.bin: $(BASENAME).$(PREFIX1).dix
apertium-validate-dictionary $<
lt-comp lr $< $@
$(PREFIX2).autobil.bin: $(BASENAME).$(PREFIX1).dix
apertium-validate-dictionary $<
lt-comp rl $< $@
###############################################################################
## Lexical selection rules
###############################################################################
$(PREFIX1).lex.bin: $(BASENAME).$(PREFIX1).lex
cg-comp $< $@
##
## VALENCY
##
$(PREFIX1).val.bin: $(BASENAME).$(PREFIX1).val
cg-comp $< $@
###############################################################################
## Structural transfer rules
###############################################################################
define ap-transfer-lint =
@( command -v apertium-preprocess-transfer-bytecode-j >/dev/null && apertium-preprocess-transfer-bytecode-j $< /dev/null ) || true
endef
$(PREFIX1).t1x.bin: $(BASENAME).$(PREFIX1).t1x
apertium-validate-transfer $<
apertium-preprocess-transfer $< $@
# Not using ap-transfer-lint for t1x yet: https://github.com/apertium/lttoolbox-java/issues/2
$(PREFIX1).t2x.bin: $(BASENAME).$(PREFIX1).t2x
apertium-validate-interchunk $<
$(ap-transfer-lint)
apertium-preprocess-transfer $< $@
$(PREFIX1).t3x.bin: $(BASENAME).$(PREFIX1).t3x
apertium-validate-interchunk $<
$(ap-transfer-lint)
apertium-preprocess-transfer $< $@
$(PREFIX1).t4x.bin: $(BASENAME).$(PREFIX1).t4x
apertium-validate-postchunk $<
$(ap-transfer-lint)
apertium-preprocess-transfer $< $@
# Alternative versions using vm-for-transfer-cpp:
$(PREFIX1).v1x.bin: $(BASENAME).$(PREFIX1).t1x
apertium-validate-transfer $<
apertium-compile-transfer -i $< -o $@
$(PREFIX1).v2x.bin: $(BASENAME).$(PREFIX1).t2x
apertium-validate-interchunk $<
apertium-compile-transfer -i $< -o $@
$(PREFIX1).v3x.bin: $(BASENAME).$(PREFIX1).t3x
apertium-validate-interchunk $<
apertium-compile-transfer -i $< -o $@
$(PREFIX1).v4x.bin: $(BASENAME).$(PREFIX1).t4x
apertium-validate-postchunk $<
apertium-compile-transfer -i $< -o $@
vm-transfer: $(PREFIX1).v1x.bin \
$(PREFIX1).v2x.bin \
$(PREFIX1).v3x.bin \
$(PREFIX1).v4x.bin
###############################################################################
## Distribution
###############################################################################
# Files which aren't built, but are distributed:
EXTRA_DIST= \
$(BASENAME).$(PREFIX1).lex \
$(BASENAME).$(PREFIX1).val \
$(BASENAME).$(PREFIX1).dix \
$(BASENAME).$(PREFIX1).t1x \
$(BASENAME).$(PREFIX1).t2x \
$(BASENAME).$(PREFIX1).t3x \
$(BASENAME).$(PREFIX1).t4x \
rm-deriv-cmp.twol \
modes.xml
###############################################################################
## Installation
###############################################################################
apertium_sme_nobdir=$(prefix)/share/apertium/$(BASENAME)/
# Files which should be installed to $(prefix)/share/apertium/$(BASENAME)/:
apertium_sme_nob_DATA=$(TARGETS_COMMON) \
$(BASENAME).$(PREFIX1).t1x \
$(BASENAME).$(PREFIX1).t2x \
$(BASENAME).$(PREFIX1).t3x \
$(BASENAME).$(PREFIX1).t4x
# All modes are created by the same goal, listing several will just give problems with make -j2
noinst_DATA=modes/$(PREFIX1).mode
install-data-local: install-modes
###############################################################################
## Cleanup
###############################################################################
CLEANFILES = $(TARGETS_COMMON)
clean-local:
-rm -rf .deps modes
###############################################################################
## Test
###############################################################################
test-bidix-gen:
dev/sme-nob.inconsistency.sh
test-previous-offenders: all
./previous-offenders
test-install: all
DESTDIR=tmp-$@ make install
find tmp-$@ -type f -name '*.mode' | xargs sed -i.tmp "s% '\($(prefix)\)% 'tmp-$@/\1%g"
echo "Mus lea oahpahus gaskkal guovtti ja njealji." | apertium -d tmp-$@/$(prefix)/share/apertium sme-nob | tee tmp-$@/mt
@echo "Jeg har undervisning mellom to og fire." > tmp-$@/ref
@diff tmp-$@/ref tmp-$@/mt
@rm -rf tmp-$@
# TODO: test-bidix-gen script needs fixing
test: all test-previous-offenders test-install
apertium-regtest test