summaryrefslogtreecommitdiff
path: root/word-aligner/makefiles/makefile.grammars
diff options
context:
space:
mode:
Diffstat (limited to 'word-aligner/makefiles/makefile.grammars')
-rw-r--r--word-aligner/makefiles/makefile.grammars69
1 files changed, 69 insertions, 0 deletions
diff --git a/word-aligner/makefiles/makefile.grammars b/word-aligner/makefiles/makefile.grammars
new file mode 100644
index 00000000..a6167010
--- /dev/null
+++ b/word-aligner/makefiles/makefile.grammars
@@ -0,0 +1,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
+