summaryrefslogtreecommitdiff
path: root/word-aligner/makefiles/makefile.grammars
blob: a6167010c75c373df494e244b859e5cf4b79ab8e (plain)
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
all: corpus.f-e.lex-grammar.gz corpus.e-f.lex-grammar.gz corpus.class.e corpus.class.f weights.init.gz

clean:
	$(RM) orthonorm-dict.* voc2class* corpus.class.* corpus.e-f corpus.f-e weights* corpus.f-e.lex-grammar* *.model1 *voc corpus.e-f.lex-grammar*

GZIP = /usr/bin/gzip
ZCAT = zcat
EXTRACT_WEIGHTS = $(SCRIPT_DIR)/extract_weights.pl
EXTRACT_GRAMMAR = $(SCRIPT_DIR)/extract_grammar.pl
SUPPLEMENT_WEIGHTS = $(SCRIPT_DIR)/supplement_weights_file.pl
EXTRACT_VOCAB = $(SCRIPT_DIR)/extract_vocab.pl
ORTHONORM_E = $(SCRIPT_DIR)/ortho-norm/$(E_LANG).pl
ORTHONORM_F = $(SCRIPT_DIR)/ortho-norm/$(F_LANG).pl
CLASSIFY = $(SCRIPT_DIR)/classify.pl
MAKE_LEX_GRAMMAR = $(SCRIPT_DIR)/make_lex_grammar.pl
MODEL1 = $(TRAINING_DIR)/model1
MERGE_CORPUS = $(SCRIPT_DIR)/merge_corpus.pl

orthonorm-dict.e: corpus.e
	$(EXTRACT_VOCAB) corpus.e > e.voc
	$(ORTHONORM_E) < e.voc > e.ortho-voc
	$(MERGE_CORPUS) e.voc e.ortho-voc > $@

orthonorm-dict.f: corpus.f
	$(EXTRACT_VOCAB) corpus.f > f.voc
	$(ORTHONORM_F) < f.voc > f.ortho-voc
	$(MERGE_CORPUS) f.voc f.ortho-voc > $@

voc2class.e: corpus.e $(MKCLS)
	$(MKCLS) -c$(NCLASSES) -n10 -pcorpus.e -Vvoc2class.e opt

voc2class.f: corpus.f $(MKCLS)
	$(MKCLS) -c$(NCLASSES) -n10 -pcorpus.f -Vvoc2class.f opt

corpus.class.e: corpus.e voc2class.e $(CLASSIFY)
	$(CLASSIFY) voc2class.e corpus.e > $@

corpus.class.f: corpus.f voc2class.f $(CLASSIFY)
	$(CLASSIFY) voc2class.f corpus.f > $@

corpus.f-e: corpus.f corpus.e $(MERGE_CORPUS)
	$(MERGE_CORPUS) corpus.f corpus.e > $@

corpus.e-f: corpus.f corpus.e $(MERGE_CORPUS)
	$(MERGE_CORPUS) corpus.e corpus.f > $@

corpus.f-e.model1: corpus.f-e $(MODEL1)
	$(MODEL1) corpus.f-e > corpus.f-e.model1

corpus.e-f.model1: corpus.e-f $(MODEL1)
	$(MODEL1) corpus.e-f > corpus.e-f.model1

bidir.grammars: corpus.f-e corpus.f-e.model1 corpus.e-f.model1 orthonorm-dict.f orthonorm-dict.e voc2class.e voc2class.f
	$(RM) $@
	$(MAKE_LEX_GRAMMAR) corpus.f-e corpus.f-e.model1 corpus.e-f.model1 orthonorm-dict.f orthonorm-dict.e voc2class.e voc2class.f > bidir.grammars

corpus.f-e.lex-grammar.gz: bidir.grammars
	$(EXTRACT_GRAMMAR) 1 bidir.grammars | $(GZIP) -9 > corpus.f-e.lex-grammar.gz

corpus.e-f.lex-grammar.gz: bidir.grammars
	$(EXTRACT_GRAMMAR) 2 bidir.grammars | $(GZIP) -9 > corpus.e-f.lex-grammar.gz

weights.init.gz: bidir.grammars voc2class.f voc2class.e
	$(EXTRACT_WEIGHTS) bidir.grammars > weights.init
	$(SUPPLEMENT_WEIGHTS) voc2class.f > weights.dup
	$(SUPPLEMENT_WEIGHTS) voc2class.e >> weights.dup
	sort -u weights.dup >> weights.init
	$(GZIP) -9 weights.init