-
Notifications
You must be signed in to change notification settings - Fork 91
/
Makefile
2378 lines (1888 loc) · 88.8 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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*-makefile-*-
#
#------------------------------------------------------------
#
# build scripts for data sets of the
# Tatoeba Translation Challenge
#
# https://github.com/Helsinki-NLP/Tatoeba-Challenge
#------------------------------------------------------------
##
## TODO: add clean-up recipes
## TODO: get rid of some hard-coded paths
## TODO: properly integrate software dependencies
## TODO: integrate more data filters (OPUS-Filter?)
##
##
##--------------------------------------------------------------------
## (1) create a new release including everything:
##
## make release
## module load allas
## allas-conf
## make upload
##--------------------------------------------------------------------
## (2) create a new testset release (including devsets)
##
## make testset-release
## module load allas
## allas-conf
## make upload-test upload-dev
##--------------------------------------------------------------------
## (3) update dev and test data (incremental updates from Tatoeba)
##
## make update ................... update test data with latest Tatoeba data
## make upload-devtest ........... upload the devtest tarball (do that after update!)
##--------------------------------------------------------------------
## other important recipes:
##
## make cleanup .................. some cleanup in tatoeba data release dirs
##--------------------------------------------------------------------
## (4) working with Tatoeba-MT models
##
## make update-models .......... update the model releases
##
## The command above will run:
##
## make cleanup-model-dirs ..... remove duplicates in released model dir
## make upload-models .......... upload models in release-dir
## make released-model-list .... generate a list of released models
## make released-model-results . generate results tables
## make update-git ............. update the git repository
##
SHELL := bash
CPU_MODULES := parallel
## OPUS home directory and language code conversion tools
## OPUSMT_HOMEDIR: local copy of Opus-MT-train project
## TODO: get rid of some hard-coded paths?
OPUS_HOME = /projappl/nlpl/data/OPUS
OPUSMT_HOMEDIR = ../Opus-MT-train
## VERSION ............. version of the current release
## TATOEBA_VERSION ..... Tatoeba corpus release this is based on
TODAY := $(shell date +%F)
# VERSION = v2020-07-28
# VERSION = v2021-08-07
VERSION = v2023-09-26
TATOEBA_VERSION = v2023-04-12
# TATOEBA_VERSION = v2020-05-31
# TATOEBA_VERSION = v20190709
## previous release (used for merging with new release)
PREVIOUS_VERSION = v2021-08-07
## maximum size of dev and test sets
## (currently MAX_TESTSIZE is not used in his makefile)
MAX_TESTSIZE ?= 10000
MAX_DEVSIZE ?= 10000
## corpora in OPUS used for training
## exclude Tatoeba (= test/dev data), WMT-News (reserve for comparison with other models)
## TODO: do we want to / need toexclude some other data sets?
OPUS_CORPORA := ${sort ${notdir ${shell find ${OPUS_HOME} -maxdepth 1 -mindepth 1 -type d}}}
EXCLUDE_CORPORA := Tatoeba WMT-News MPC1
TRAIN_CORPORA := ${filter-out ${EXCLUDE_CORPORA},${OPUS_CORPORA}}
## Tatoeba MT models
## - release directory
## - data container on allas
MODEL_RELEASEDIR = models
MODEL_CONTAINER = Tatoeba-MT-models
## some more tools and parameters
## - check if there is dedicated scratch space (e.g. on puhti nodes)
## - check if terashuf and pigz are available
ifdef LOCAL_SCRATCH
TMPDIR = ${LOCAL_SCRATCH}
endif
## scripts and tools
SCRIPTDIR = scripts
TOKENIZER = ${SCRIPTDIR}/moses/tokenizer
ISO639 = iso639
GET_ISO_CODE = ${ISO639} -m
## set additional argument options for opus_read (if it is used)
## e.g. OPUSREAD_ARGS = -a certainty -tr 0.3
## TODO: should we always use opus_read instead of pre-extracted moses-style files?
## (disadvantage: much slower!)
OPUSREAD_ARGS =
## settings for sort
THREADS ?= 4
SORT := LC_ALL=C sort -T ${TMPDIR} -S100M --parallel=${THREADS}
## tool for shuffling data (terashuf or sort)
SHUFFLE = ${shell which terashuf 2>/dev/null}
ifeq (${SHUFFLE},)
SHUFFLE = ${SORT} --random-sort
endif
## check whether parsort is available
ifneq (${shell which parsort 2>/dev/null},)
SORT := LC_ALL=C parsort -T ${TMPDIR} -S100M
endif
## use pigz if available
GZIP := ${shell which pigz 2>/dev/null}
GZIP ?= gzip
ZCAT := ${GZIP} -cd
## check whether GNU parallel is available
ifneq (${shell which parallel 2>/dev/null},)
PARALLEL_ARGS := --pipe --keep-order -q -L10000 --max-procs 25%
PARALLEL := parallel ${PARALLEL_ARGS}
endif
## basic training data filtering pipeline
## TODO: get rid of recode?
## TODO: use GNU parallel?
## NEW: use ftfy library for basic unicode fixing
BASIC_FILTERS = | ftfy \
| $(TOKENIZER)/deescape-special-chars.perl \
| sed 's/(Translated with Google Translate)//g'
#BASIC_FILTERS = | perl -CS -pe 'tr[\x{9}\x{A}\x{D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}][]cd;' \
# | recode -f utf8..utf16 | recode -f utf16..utf8 \
# | $(TOKENIZER)/deescape-special-chars.perl \
# | sed 's/(Translated with Google Translate)//g'
## DONE: remove lines 2 and 3 (they do too much, also remove emojis)
##
# | perl -CS -pe 's/\&\s*\#\s*160\s*\;/ /g' \
# | perl -pe 's/[\p{C}-[\n\t]]/ /g;' \
## available OPUS languages (IDs in the way they appear in the corpus)
ifneq (${wildcard opus-langs.txt},)
OPUS_LANGS = ${shell head -1 opus-langs.txt}
endif
ifneq (${wildcard opus-langpairs3.txt},)
OPUS_PAIRS3 = ${shell head -1 opus-langpairs.txt}
endif
## all languages in the current Tatoeba data set in OPUS
TATOEBA_LANGS := ${sort ${patsubst %.txt.gz,%,${notdir ${wildcard ${OPUS_HOME}/Tatoeba/${TATOEBA_VERSION}/mono/*.txt.gz}}}}
TATOEBA_PAIRS := ${sort ${patsubst %.xml.gz,%,${notdir ${wildcard ${OPUS_HOME}/Tatoeba/${TATOEBA_VERSION}/xml/*.xml.gz}}}}
## ISO-639-3 language codes
OPUS_LANGS3 = ${sort ${filter-out xxx,${shell ${GET_ISO_CODE} ${OPUS_LANGS}}}}
TATOEBA_LANGS3 = ${sort ${filter-out xxx,${shell ${GET_ISO_CODE} ${TATOEBA_LANGS}}}}
TATOEBA_PAIRS3 = ${sort ${shell ${SCRIPTDIR}/convert_langpair_codes.pl ${TATOEBA_PAIRS}}}
## data directories
DATADIR = data
RELEASEHOME = ${DATADIR}/release
RELEASEDIR = ${RELEASEHOME}/${VERSION}
TESTRELEASEDIR = ${RELEASEHOME}/test/${VERSION}
DEVRELEASEDIR = ${RELEASEHOME}/dev/${VERSION}
INFODIR = ${RELEASEDIR}
BICLEANERDIR = ${RELEASEHOME}/bicleaner/${VERSION}
PREVIOUS_RELEASEDIR = ${RELEASEHOME}/${PREVIOUS_VERSION}
## additional data directories for
## - incremental updates of dev/test data (DEVTESTDIR)
## - latest test and dev data sets
DEVTESTDIR = ${DATADIR}/devtest
TESTDATADIR = ${DATADIR}/test
DEVDATADIR = ${DATADIR}/dev
## all data files we need to produce
TRAIN_DATA = ${patsubst %,${RELEASEDIR}/%/train.id.gz,${TATOEBA_PAIRS3}}
TEST_DATA = ${patsubst %,${RELEASEDIR}/%/test.id,${TATOEBA_PAIRS3}}
DEV_DATA = ${patsubst %,${RELEASEDIR}/%/dev.id,${TATOEBA_PAIRS3}}
TEST_TSV := ${patsubst ${RELEASEDIR}/%.id,${DATADIR}/test/%.txt,${wildcard ${RELEASEDIR}/*/test.id}}
DEV_TSV := ${patsubst ${RELEASEDIR}/%.id,${DATADIR}/dev/%.txt,${wildcard ${RELEASEDIR}/*/dev.id}}
LANGIDS := ${patsubst %,${INFODIR}/%/langids,${TATOEBA_PAIRS3}}
OVERLAPTEST := ${patsubst ${RELEASEDIR}/%/train.id.gz,${INFODIR}/%/overlap-with-test,${wildcard ${RELEASEDIR}/*/train.id.gz}}
OVERLAPDEV := ${patsubst ${RELEASEDIR}/%/train.id.gz,${INFODIR}/%/overlap-with-dev,${wildcard ${RELEASEDIR}/*/train.id.gz}}
## dev and test files with version numbers
TEST_RELEASE_TSV := ${patsubst ${RELEASEDIR}/%/test.id,${TESTRELEASEDIR}/tatoeba-test-${VERSION}.%.txt.gz,\
${wildcard ${RELEASEDIR}/*/test.id}}
DEV_RELEASE_TSV := ${patsubst ${RELEASEDIR}/%/dev.id,${DEVRELEASEDIR}/tatoeba-dev-${VERSION}.%.txt.gz,\
${wildcard ${RELEASEDIR}/*/dev.id}}
## language pairs that we can release
RELEASE_DATA := $(shell find ${RELEASEDIR} -maxdepth 1 -mindepth 1 -type d -name '*-*')
## this is for regular updates of testdata with new Tatoeba releases in OPUS
## call `make update-testdata`
UPDATED_TEST_DATA = ${patsubst %,${DEVTESTDIR}/%/test-${TATOEBA_VERSION}.txt,${TATOEBA_PAIRS3}}
## statistics of all files
STATISTICS = ${DATADIR}/README-${VERSION}.md
DATA_COUNT_FILES = ${RELEASEDIR}/released-bitexts.txt \
${RELEASEDIR}/released-bitexts-no-test.txt \
${RELEASEDIR}/released-bitexts-insufficient.txt \
${RELEASEDIR}/released-bitexts-highest.txt \
${RELEASEDIR}/released-bitexts-higher.txt \
${RELEASEDIR}/released-bitexts-medium.txt \
${RELEASEDIR}/released-bitexts-lower.txt \
${RELEASEDIR}/released-bitexts-lowest.txt \
${RELEASEDIR}/released-bitexts-zero-shot.txt \
${RELEASEDIR}/released-bitexts-min200.txt \
${RELEASEDIR}/released-bitexts-min1000.txt
DOWNLOADURL := https://object.pouta.csc.fi
TATOEBA_DATAURL := https://object.pouta.csc.fi/Tatoeba-Challenge
TATOEBA_MODELURL := https://object.pouta.csc.fi/Tatoeba-MT-models
DEVTEST_CONTAINER = Tatoeba-Challenge-devtest
RELEASE_CONTAINER = Tatoeba-Challenge-${VERSION}
WIKIDOC_CONTAINER = Tatoeba-Challenge-WikiDoc-${VERSION}
WIKISHUF_CONTAINER = Tatoeba-Challenge-WikiShuffled-${VERSION}
PIVOT_LANG ?= eng
EXTRA_OPUS_LANGS3 = ${filter-out ${TATOEBA_LANGS3},${OPUS_LANGS3}}
EXTRA_OPUS_PAIRS3 = ${filter-out ${TATOEBA_PAIRS3},\
${shell cat opus-langpairs3.txt | tr ' ' "\n" |\
grep '${PIVOT_LANG}' | grep -v xxx | grep '^...-...$$'}}
EXTRA_TRAIN_DATA = ${patsubst %,${RELEASEDIR}/%/train.id.gz,${EXTRA_OPUS_PAIRS3}}
## monolingual data taken from Wikimedia sources
## prepared by the Opus-MT-train project
OPUSMT_WIKIDIR = ${OPUSMT_HOMEDIR}/backtranslate/wikidoc
# WIKI_LANGS = ${notdir ${wildcard ${OPUSMT_WIKIDIR}/*}}
WIKI_LANGS = aa ab ace ady af ak als am an ang ar arc ary arz as ast atj av awa ay az azb ba ban bar bcl be bg bh bi bjn bm bn bo bpy br bs bug bxr ca cdo ce ceb ch cho chr chy ckb co cr crh cs csb cu cv cy da de din diq dsb dty dv dz ee el eml en eo es et eu ext fa ff fi fj fo fr frp frr fur fy ga gag gan gcr gd gl glk gn gom gor got gu gv ha hak haw he hi hif ho hr hsb ht hu hy hyw hz ia id ie ig ii ik ilo inh io is it iu ja jam jbo jv ka kaa kab kbd kbp kg ki kj kk kl km kn ko koi kr krc ks ksh ku kv kw ky la lad lb lbe lez lfn lg li lij lmo ln lo lrc lt ltg lv mai mdf mg mh mhr mi min mk ml mn mnw mr mrj ms mt mus mwl my myv mzn na nah nap nds ne new ng nl nn no nov nqo nrm nso nv ny oc olo om or os pa pag pam pap pcd pdc pfl pi pih pl pms pnb pnt ps pt qu rm rmy rn ro ru rue rw sa sah sat sc scn sco sd se sg sh shn si sk sl sm sn so sq sr srn ss st stq su sv sw szl szy ta tcy te ten tet tg th ti tk tl tn to tpi tr ts tt tum tw ty tyv udm ug uk ur uz ve vec vep vi vls vo wa war wo wuu xal xh xmf yi yo za zea zh zu
WIKI_LANGS3 = ${sort ${filter-out xxx,${shell ${GET_ISO_CODE} ${WIKI_LANGS}}}}
WIKI_DOCS = ${patsubst %,${RELEASEDIR}/%/wikipedia.id.gz,${WIKI_LANGS3}} \
${patsubst %,${RELEASEDIR}/%/wikibooks.id.gz,${WIKI_LANGS3}} \
${patsubst %,${RELEASEDIR}/%/wikinews.id.gz,${WIKI_LANGS3}} \
${patsubst %,${RELEASEDIR}/%/wikiquote.id.gz,${WIKI_LANGS3}} \
${patsubst %,${RELEASEDIR}/%/wikisource.id.gz,${WIKI_LANGS3}}
## language labels included in a wiki data set
## TODO: empty lines also have language labels (should we remove them?)
WIKI_LABELS = ${patsubst %.id.gz,%.langs.txt,${WIKI_DOCS}}
## new lang ID files with normalised codes and script info
# NEW_TEST_IDS := ${patsubst ${RELEASEDIR}/%.ids,${RELEASEDIR}/%.id,${wildcard ${RELEASEDIR}/*/test.ids}}
# NEW_DEV_IDS := ${patsubst ${RELEASEDIR}/%.ids,${RELEASEDIR}/%.id,${wildcard ${RELEASEDIR}/*/dev.ids}}
# NEW_TRAIN_IDS := ${patsubst ${RELEASEDIR}/%.ids.gz,${RELEASEDIR}/%.id.gz,${wildcard ${RELEASEDIR}/*/train.ids.gz}}
.PHONY: all data testdata devdata traindata statistics test-tsv dev-tsv
.PHONY: upload upload-test upload-devtest upload-train upload-mono
.PHONY: extra-traindata extra-statistics extra-upload
.PHONY: update update-testdata
.PRECIOUS: ${DATADIR}/%/README.md
.PRECIOUS: ${DATADIR}/subsets/${VERSION}/%.md
## make all (completely new release)
## including training data and extra data sets
all: opus-langpairs3.txt
${MAKE} data
${MAKE} extra-traindata
${MAKE} released-remove-empty
${MAKE} dev-tsv test-tsv test-release dev-release
${MAKE} ${DATADIR}/README.md
${MAKE} langids subsets
${MAKE} extra-statistics
${MAKE} released-data-counts
${MAKE} release-tag
## TODO: there is some kind of memory-leak somewhere that causes jobs to crahs
## some dataset seems to require a lot of memory (langid or shuffling?)
release-job:
${MAKE} HPC_MEM=128g HPC_CORES=16 HPC_DISK=1000 HPC_TIME=3-00 release.submit
# ${MAKE} HPC_MEM=32g HPC_CORES=16 HPC_DISK=1000 HPC_TIME=3-00 release.submit
# ${MAKE} HPC_MEM=32g HPC_CORES=16 HPC_DISK=1000 HPC_TIME=14-00 HPC_QUEUE=longrun release.submit
release:
rm -f opus-langs.txt opus-langpairs.txt opus-langpairs3.txt
${MAKE} opus-langpairs3.txt
${MAKE} TATOEBA_VERSION=${notdir ${shell realpath ${OPUS_HOME}/Tatoeba/latest 2>/dev/null}} \
VERSION=v${TODAY} all
mv -f README.md README.backup
${MAKE} TATOEBA_VERSION=${notdir ${shell realpath ${OPUS_HOME}/Tatoeba/latest 2>/dev/null}} \
VERSION=v${TODAY} README.md
cp README.md README-v${TODAY}.md
@echo "--------------------------------"
@echo "Don't forget to upload the data!"
@echo " module load allas"
@echo " allas-conf"
@echo " make VERSION=v${TODAY} upload-release"
@echo "And then push the updates to git"
@echo " make VERSION=v${TODAY} release-push"
@echo "--------------------------------"
release-tag:
@echo "# Release ${VERSION}" >> ${DATADIR}/Releases.md
@echo "" >> ${DATADIR}/Releases.md
@echo "* [Test data](${TATOEBA_DATAURL}-devtest/test-${VERSION}.tar) (${VERSION})" >> ${DATADIR}/Releases.md
@echo "* [Development data](${TATOEBA_DATAURL}-devtest/dev-${VERSION}.tar) (${VERSION})" >> ${DATADIR}/Releases.md
@echo "* [Bilingual training data](README-${VERSION}.md) (${VERSION}), language-pair specific downloads" >> ${DATADIR}/Releases.md
@echo "* [Extra bilingual training data](subsets/NoTestData-${VERSION}.md) (${VERSION}), language-pair specific downloads" >> ${DATADIR}/Releases.md
@echo "" >> ${DATADIR}/Releases.md
git add ${TESTDATADIR}/*/*.txt
git add ${DEVDATADIR}/*/*.txt
git add ${DEVTESTDIR}/*/*.txt
git add ${RELEASEDIR}/*.txt
git add ${TESTRELEASEDIR}/*.txt.gz
git add ${DEVRELEASEDIR}/*.txt.gz
git add ${DATADIR}/*-${VERSION}.md ${DATADIR}/subsets/*.md ${DATADIR}/subsets/${VERSION}/*.md
git add README-${VERSION}.md
git add ${DATA_COUNT_FILES}
git commit -am 'updated dev and test data (${VERSION})'
git tag -a ${VERSION} -m "release version ${VERSION}"
release-push:
git push origin master
git push origin ${VERSION}
.PHONY: released-data-counts
released-data-counts: ${DATA_COUNT_FILES}
.PHONY: release-bicleaner-scores
release-bicleaner-scores: $(patsubst %.gz,%.done,$(wildcard ${BICLEANERDIR}/*.gz))
echo ${BICLEANERDIR}
BicleanerScores.md:
@echo "# Bicleaner AI scores" > $@
@echo "" >> $@
@echo "Here are [bicleaner AI](https://github.com/bitextor/bicleaner-ai) scores for selected bitexts from release ${VERSION}." >> $@
@echo "The scores correspond to lines in the training data. The scores apply models from Bicleaner AI v2.3.2." >> $@
@echo "" >> $@
@for f in $(sort $(notdir $(wildcard ${BICLEANERDIR}/*.gz))); do \
echo "* [$$f](${TATOEBA_DATAURL}-${VERSION}/$$f)" >> $@; \
done
## generate readme file
TESTSET_VERSION ?= ${VERSION}
DEVSET_VERSION ?= ${VERSION}
TRAINSET_VERSION ?= ${VERSION}
EXTRATRAINSET_VERSION ?= ${VERSION}
MONO_VERSION ?= ${VERSION}
README.md: README.template ${TESTDATADIR}-${VERSION} ${DEVDATADIR}-${VERSION}
sed -e 's/%%RELEASE%%/${VERSION}/g' \
-e 's/%%TESTSET_RELEASE%%/${TESTSET_VERSION}/g' \
-e 's/%%DEVSET_RELEASE%%/${DEVSET_VERSION}/g' \
-e 's/%%TRAINSET_RELEASE%%/${TRAINSET_VERSION}/g' \
-e 's/%%EXTRATRAINSET_RELEASE%%/${EXTRATRAINSET_VERSION}/g' \
-e 's/%%MONO_RELEASE%%/${MONO_VERSION}/g' \
-e 's/%%NR_BITEXTS%%/${shell tail -n +2 ${RELEASEDIR}/released-bitexts.txt | cut -f10 | grep . | wc -l | numfmt --grouping}/' \
-e 's/%%NR_LANGPAIRS%%/${shell tail -n +2 ${RELEASEDIR}/released-bitexts.txt | wc -l | numfmt --grouping}/' \
-e 's/%%NR_LANGS%%/${shell tail -n +2 ${RELEASEDIR}/released-bitexts.txt | cut -f1 | tr '-' ' ' | tr ' ' "\n" | sort -u | wc -l}/' \
-e 's/%%NR_TEST_LANGPAIRS%%/${shell cat ${RELEASEDIR}/released-bitexts-min200.txt | wc -l}/' \
-e 's/%%NR_TEST_LANGS%%/${shell cut -f1 ${RELEASEDIR}/released-bitexts-min200.txt | tr '-' ' ' | tr ' ' "\n" | sort -u | wc -l}/' \
-e 's/%%TRAIN_SIZE%%/${shell tail -n +2 ${RELEASEDIR}/released-bitexts.txt | awk "{SUM+=\$$10}END{print SUM}" | numfmt --to=si}/' \
< $< > $@
tail -n +2 ${RELEASEDIR}/released-bitexts.txt | awk "{SUM+=\$$10}END{print SUM}" | numfmt --to=si
cp $@ README-${VERSION}.md
## make a new test set release
## (skip training data)
## TODO: How do we present that on the website?
testset-all: opus-langs.txt
${MAKE} testdata
${MAKE} devdata
${MAKE} dev-tsv test-tsv
${MAKE} released-data-counts
${MAKE} testset-release-tag
testset-release:
${MAKE} TATOEBA_VERSION=${notdir ${shell realpath ${OPUS_HOME}/Tatoeba/latest 2>/dev/null}} \
VERSION=v${TODAY} testset-all
mv -f README.md README-v${TODAY}.md
${MAKE} TESTSET_VERSION=v${TODAY} DEVSET_VERSION=v${TODAY} README.md
@echo "--------------------------------"
@echo "Don't forget to upload the data!"
@echo " module load allas"
@echo " allas-conf"
@echo " make VERSION=v${TODAY} upload-test upload-dev"
@echo "And then push the updates to git"
@echo " make VERSION=v${TODAY} release-push"
@echo "--------------------------------"
testset-release-tag:
@echo "# Release ${VERSION}" >> ${DATADIR}/Releases.md
@echo "" >> ${DATADIR}/Releases.md
@echo "* [Test data](${TATOEBA_DATAURL}}-devtest/test-${VERSION}.tar) (${VERSION})" >> ${DATADIR}/Releases.md
@echo "* [Development data](${TATOEBA_DATAURL}}-devtest/dev-${VERSION}.tar) (${VERSION})" >> ${DATADIR}/Releases.md
@echo "" >> ${DATADIR}/Releases.md
git add ${TESTDATADIR}/*/*.txt
git add ${DEVDATADIR}/*/*.txt
git add ${DEVTESTDIR}/*/*.txt
git add ${DATA_COUNT_FILES}
git commit -am 'updated dev and test data (${VERSION})'
git tag -a ${VERSION} -m "release version ${VERSION}"
# data: ${TEST_DATA} ${DEV_DATA} ${TRAIN_DATA}
data: ${TEST_DATA} ${DEV_DATA}
${MAKE} traindata
traindata: ${TRAIN_DATA}
testdata: ${TEST_DATA}
devdata: ${DEV_DATA}
MISSING_TRAIN_DATA = $(patsubst %,%.missing,${TRAIN_DATA})
print-missing-traindata: ${MISSING_TRAIN_DATA}
${MISSING_TRAIN_DATA}:
@if [ ! -e $(@:.missing=) ]; then echo "$(@:.missing=)"; fi
## divide into several jobs for creating training data
## each one for 500 language pairs
## TODO: more generic sharding
## TODO: separate big from smaller language pairs (difficult!)
TRAIN_DATA_1_500 := $(wordlist 1,500,${TRAIN_DATA})
TRAIN_DATA_501_1000 := $(wordlist 501,1000,${TRAIN_DATA})
TRAIN_DATA_1001_1500 := $(wordlist 1001,1500,${TRAIN_DATA})
TRAIN_DATA_1501_2000 := $(wordlist 1501,2000,${TRAIN_DATA})
TRAIN_DATA_2001_2500 := $(wordlist 2001,2500,${TRAIN_DATA})
TRAIN_DATA_2501_3000 := $(wordlist 2501,3000,${TRAIN_DATA})
TRAIN_DATA_3001_3500 := $(wordlist 3001,3500,${TRAIN_DATA})
TRAIN_DATA_3501_end := $(wordlist 3501,$(words ${TRAIN_DATA}),${TRAIN_DATA})
TRAIN_DATA_LAST500 = $(wordlist $(shell echo $$(( $(words ${TRAIN_DATA}) - 500 ))),\
$(words ${TRAIN_DATA}),\
${TRAIN_DATA})
traindata-jobs:
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_1_500.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_501_1000.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_1001_1500.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_1501_2000.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_2001_2500.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_2501_3000.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_3001_3500.submit
${MAKE} HPC_MEM=32g HPC_CORES=8 HPC_DISK=500 HPC_TIME=3-00 traindata_3501_end.submit
traindata_1_500: ${TRAIN_DATA_1_500}
traindata_501_1000: ${TRAIN_DATA_501_1000}
traindata_1001_1500: ${TRAIN_DATA_1001_1500}
traindata_1501_2000: ${TRAIN_DATA_1501_2000}
traindata_2001_2500: ${TRAIN_DATA_2001_2500}
traindata_2501_3000: ${TRAIN_DATA_2501_3000}
traindata_3001_3500: ${TRAIN_DATA_3001_3500}
traindata_3501_end: ${TRAIN_DATA_3501_end}
## this is for regular updates of testdata with new Tatoeba releases in OPUS
## call `make update-testdata`
update update-testdata: ${UPDATED_TEST_DATA}
test-tsv: ${TEST_TSV}
dev-tsv: ${DEV_TSV}
test-release: ${TEST_RELEASE_TSV}
dev-release: ${DEV_RELEASE_TSV}
langids: ${RELEASEDIR}/langids-train.txt ${RELEASEDIR}/langids-dev.txt ${RELEASEDIR}/langids-test.txt \
${RELEASEDIR}/langids-common.txt ${RELEASEDIR}/langids-train-only.txt ${RELEASEDIR}/langids-devtest-only.txt
statistics: ${STATISTICS}
overlaps: ${OVERLAPTEST} ${OVERLAPDEV}
## make a new release (upload all data)
upload: upload-test upload-dev upload-devtest upload-train upload-mono
upload-release: upload-test upload-dev upload-train
## individual data set uploads
upload-devtest: ${DEVTESTDIR}.done
upload-test: ${TESTDATADIR}-${VERSION}.done ${RELEASEHOME}/test.done
upload-dev: ${DEVDATADIR}-${VERSION}.done ${RELEASEHOME}/dev.done
upload-train: ${patsubst %,%.done,${RELEASE_DATA}}
upload-mono: ${patsubst %,${RELEASEDIR}/%.done,${WIKI_LANGS3}} # ${RELEASEDIR}/wiki.langs.done
upload-wikishuffled: ${patsubst wiki-shuffled/%,${RELEASEDIR}/wiki-shuffled-%.done,${wildcard wiki-shuffled/???}}
upload-wikidoc: ${patsubst wiki-doc/%,${RELEASEDIR}/wiki-doc-%.done,${wildcard wiki-doc/???}}
.PHONY: cleanup-models
cleanup-models:
${MAKE} cleanup-model-dirs
## all models sub directories (basically language pairs)
RELEASED_MODELS = ${notdir ${wildcard ${MODEL_RELEASEDIR}/*}}
LANGPAIR ?= $(firstword ${RELEASED_MODELS})
## release only one model and update all lists
.PHONY: update-model
update-model:
${MAKE} RELEASED_MODELS=${LANGPAIR} update-models
## release all models and update all lists
.PHONY: update-models
update-models:
${MAKE} upload-models
${MAKE} released-model-list
${MAKE} released-model-results
python3 ${SCRIPTDIR}/convert-model-info-to-json.py
git add ${MODEL_RELEASEDIR}/*/README.md
git add ${MODEL_RELEASEDIR}/*/*.yml
git add ${MODEL_RELEASEDIR}/*.json
git add results/*.md
git add models/*.txt
git add models/results/*.txt
${MAKE} GIT_COMMIT_MESSAGE='latest models added' update-git
GIT_COMMIT_MESSAGE ?= latest changes
.PHONY: update-git
update-git:
git commit -am "${GIT_COMMIT_MESSAGE}"
git push origin master
.PHONY: upload-models
upload-models:
which a-put
if [ -e models-links.tar ]; then \
tar -xf models-links.tar; \
rm -f models-links.tar; \
fi
find ${MODEL_RELEASEDIR}/ -type l | tar -cf models-links.tar -T -
-find ${MODEL_RELEASEDIR}/ -type l -delete
-if [ `find ${MODEL_RELEASEDIR} -mindepth 2 -type d | wc -l` -gt 0 ]; then \
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
echo "There are sub-directories in ${MODEL_RELEASEDIR}/*/"; \
echo "Please, check carefully and cleanup the release directory"; \
echo "I will skip uploading modeling models now!"; \
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; \
else \
cd ${MODEL_RELEASEDIR} && swift upload ${MODEL_CONTAINER} --changed --skip-identical ${RELEASED_MODELS}; \
fi
tar -xf models-links.tar
rm -f models-links.tar
swift post ${MODEL_CONTAINER} --read-acl ".r:*"
swift list ${MODEL_CONTAINER} > index.txt
swift upload ${MODEL_CONTAINER} index.txt
rm -f index.txt
if [ `find ${MODEL_RELEASEDIR} -mindepth 2 -type d | wc -l` -eq 0 ]; then \
for m in ${RELEASED_MODELS}; do \
rm -f ${MODEL_RELEASEDIR}/$$m/*.zip; \
done \
fi
## list model-specific evaluation sub-directories
## (those should be packed into zip files before uploading things!)
.PHONY: find-model-evaluation-subdirs
find-model-evaluation-subdirs:
find ${MODEL_RELEASEDIR} -mindepth 2 -type d
## pack evaluation files into zip files
## if those model-specific subdirs still exist
.PHONY: pack-model-evaluation-subdirs
pack-model-evaluation-subdirs:
( o=`pwd`; \
for m in `find ${MODEL_RELEASEDIR} -mindepth 2 -type d`; do \
if [ ! -e $$m.eval.zip ]; then \
cd $$m; \
zip $$o/$$m.eval.zip *.*; \
cd $$o; \
rm -fr $$m; \
fi \
done )
## make swift commands to delete erroneous files that have been uploaded
## dangerous - be careful what you do with those!
.PHONY: delete-model-evaluation-subdirs
delete-model-evaluation-subdirs:
@which a-put > /dev/null
@swift list ${MODEL_CONTAINER} |\
grep '.*/.*/.*' | grep -v '^spm/' |\
sed 's#^#swift delete ${MODEL_CONTAINER} #'
# @find ${MODEL_RELEASEDIR} -mindepth 2 -type d -exec find {} -type f \; |\
# sed 's#^${MODEL_RELEASEDIR}/#swift delete ${MODEL_CONTAINER} #'
.PHONY: upload-model-index
upload-model-index:
swift post ${MODEL_CONTAINER} --read-acl ".r:*"
swift list ${MODEL_CONTAINER} > index.txt
swift upload ${MODEL_CONTAINER} index.txt
rm -f index.txt
.PHONY: released-model-list
released-model-list: models/results/tatoeba-test-${VERSION}.txt \
models/results/tatoeba-test.txt \
models/results/other.txt \
models/released-models.txt \
models/released-model-results.txt \
models/released-model-results-all.txt \
models/released-model-results-${VERSION}.txt \
models/released-model-results-other.txt \
models/released-model-languages.txt
# RESULT_FILES = results/tatoeba-results-all.md \
# results/tatoeba-results-all-subset-zero.md \
# results/tatoeba-results-all-subset-lowest.md \
# results/tatoeba-results-all-subset-lower.md \
# results/tatoeba-results-all-subset-medium.md \
# results/tatoeba-results-all-subset-higher.md \
# results/tatoeba-results-all-subset-highest.md
RESULT_FILES = results/tatoeba-results-all.md \
results/tatoeba-results-tatoeba.md \
results/tatoeba-results-other.md \
results/tatoeba-results-${VERSION}.md \
results/tatoeba-results-${VERSION}-subset-zero.md \
results/tatoeba-results-${VERSION}-subset-lowest.md \
results/tatoeba-results-${VERSION}-subset-lower.md \
results/tatoeba-results-${VERSION}-subset-medium.md \
results/tatoeba-results-${VERSION}-subset-higher.md \
results/tatoeba-results-${VERSION}-subset-highest.md
.PHONY: released-model-results results
released-model-results results: ${RESULT_FILES} results/tatoeba-models-all.md
released-model-maps: model-map-src2trg-all.html model-map-trg2src-all.html \
model-map-src2trg.html model-map-trg2src.html
MODEL_ALLMAP_WARNING = <p><b>IMPORTANT NOTE: Some of the test sets used in measuring translation quality are WAY TOO SMALL to be reliable! Some of them include only a few lines of reference translations!</b></p>
MODEL_MAP_WARNING = <p><b>IMPORTANT NOTE: Some of the test sets used in measuring translation quality are very small and will not be reliable! Check the details in the Tatoeba MT Challenge benchmark releases!</b></p>
SRC2TRG_MAP_DESCRIPTION = <p>Available translation models for various language pairs. Colors indicate the quality on a scale from red (bad) to green (best) measured by chr-F2 scores. Click on the dots to get more information about the language pair and to get links for downloading the model.</p> \
<p>The dots on the map indicate the source language. Select the target language from the menu in the upper-right corner of the map.</p>
TRG2SRC_MAP_DESCRIPTION = <p>Available translation models for various language pairs. Colors indicate the quality on a scale from red (bad) to green (best) measured by chr-F2 scores. Click on the dots to get more information about the language pair and to get links for downloading the model.</p> \
<p>The dots on the map indicate the target language. Select the source language from the menu in the upper-right corner of the map.</p>
# FIX_LANG_CODES = sed -e 's/kur_Latn/kmr/' \
# -e 's/kur_Arab/ckb/' \
# -e 's/fas/pes/' \
# -e 's/sqi/sqj/' \
## double check (move macro language swahili to individual lang swahili?)
#
# -e 's/swa/swh/'
model-map-src2trg-all.html: models/released-model-results-all.txt
python3 scripts/create-map.py < $< > ${@:.html=.json}
cat scripts/create-src2trg-map.js >> ${@:.html=.json}
cat scripts/create-map.html-template |\
sed -e 's#__TITLE__#Tatoeba MT Challenge - Pre-trained NMT models (source language plot)#' \
-e 's#__DESCRIPTION__#${SRC2TRG_MAP_DESCRIPTION}${MODEL_ALLMAP_WARNING}#' \
-e 's#__JSONFILE__#${@:.html=.json}#' > $@
model-map-trg2src-all.html: models/released-model-results-all.txt
python3 scripts/create-map.py -t < $< > ${@:.html=.json}
cat scripts/create-trg2src-map.js >> ${@:.html=.json}
cat scripts/create-map.html-template |\
sed -e 's#__TITLE__#Tatoeba MT Challenge - Pre-trained NMT models (target language plot)#' \
-e 's#__DESCRIPTION__#${TRG2SRC_MAP_DESCRIPTION}${MODEL_ALLMAP_WARNING}#' \
-e 's#__JSONFILE__#${@:.html=.json}#' > $@
model-map-src2trg.html: models/released-model-results.txt
python3 scripts/create-map.py < $< > ${@:.html=.json}
cat scripts/create-src2trg-map.js >> ${@:.html=.json}
cat scripts/create-map.html-template |\
sed -e 's#__TITLE__#Tatoeba MT Challenge - Pre-trained NMT models (source language plot)#' \
-e 's#__DESCRIPTION__#${SRC2TRG_MAP_DESCRIPTION}${MODEL_MAP_WARNING}#' \
-e 's#__JSONFILE__#${@:.html=.json}#' > $@
model-map-trg2src.html: models/released-model-results.txt
python3 scripts/create-map.py -t < $< > ${@:.html=.json}
cat scripts/create-trg2src-map.js >> ${@:.html=.json}
cat scripts/create-map.html-template |\
sed -e 's#__TITLE__#Tatoeba MT Challenge - Pre-trained NMT models (target language plot)#' \
-e 's#__DESCRIPTION__#${TRG2SRC_MAP_DESCRIPTION}${MODEL_MAP_WARNING}#' \
-e 's#__JSONFILE__#${@:.html=.json}#' > $@
print-extra-traindata:
for l in ${EXTRA_TRAIN_DATA}; do \
if [ ! -e $$l ]; then \
echo $$l; \
fi \
done
# @echo ${sort ${EXTRA_TRAIN_DATA}} | tr ' ' "\n"
## extra training data where we don't have any
## tatoeba test data (only paired with PIVOT_LANG (English))
extra-traindata: ${EXTRA_TRAIN_DATA}
extra-statistics:
${MAKE} STATISTICS=${DATADIR}/subsets/NoTestData-${VERSION}.md \
TATOEBA_PAIRS3="${EXTRA_OPUS_PAIRS3}" statistics
extra-upload: ${patsubst %,${RELEASEDIR}/%.done,${EXTRA_OPUS_PAIRS3}}
## list of all languages in OPUS
opus-langs.txt:
wget -O - -q http://opus.nlpl.eu/opusapi/?languages=true |\
sed 's/^.*\[//;s/\].*$$//' |\
tr ',' "\n" | sed 's/"//g' | \
grep -v 'simple' | grep -v '^jw_' |\
sort | tr "\n" ' ' > $@
## all language pairs in opus in one file
opus-langpairs.txt: opus-langs.txt
for l in ${shell head -1 $<}; do \
echo "fetch language pairs for $$l"; \
wget -O - -q http://opus.nlpl.eu/opusapi/?source=$$l\&languages=true |\
sed 's/^.*\[//;s/\].*$$//' |\
tr ',' "\n" | sed 's/"//g' | \
grep -v 'simple' | grep -v 'jw_' |\
sort | tr "\n" ' ' > $@.tmp; \
for t in `cat $@.tmp`; do \
if [ $$t \< $$l ]; then \
echo "$$t-$$l" >> $@.all; \
else \
echo "$$l-$$t" >> $@.all; \
fi \
done; \
rm -f $@.tmp; \
done
tr ' ' "\n" < $@.all |\
sed 's/ //g' | sort -u | tr "\n" ' ' > $@
rm -f $@.all
## opus language pairs in ISO639-3 codes
opus-langpairs3.txt: opus-langpairs.txt
cat $< | xargs ${SCRIPTDIR}/convert_langpair_codes.pl | \
tr ' ' "\n" | sort -u | tr "\n" ' ' | sed 's/ $$//' > $@
## language IDs in training/dev/test
${RELEASEDIR}/langids-train.txt: ${LANGIDS}
find ${INFODIR} -name langids | xargs cat | grep 'train ' | \
cut -f2 | tr ' ' "\n" | sort -u > $@
${RELEASEDIR}/langids-test.txt: ${LANGIDS}
find ${INFODIR} -name langids | xargs cat | grep 'test ' | \
cut -f2 | tr ' ' "\n" | sort -u > $@
${RELEASEDIR}/langids-dev.txt: ${LANGIDS}
find ${INFODIR} -name langids | xargs cat | grep 'dev ' | \
cut -f2 | tr ' ' "\n" | sort -u > $@
${RELEASEDIR}/langids-devtest.txt: ${RELEASEDIR}/langids-dev.txt ${RELEASEDIR}/langids-test.txt
cat $^ | sort -u | grep . > $@
${RELEASEDIR}/langids-common.txt: ${RELEASEDIR}/langids-train.txt ${RELEASEDIR}/langids-devtest.txt
comm -1 -2 $^ | grep . > $@
${RELEASEDIR}/langids-train-only.txt: ${RELEASEDIR}/langids-train.txt ${RELEASEDIR}/langids-devtest.txt
comm -2 -3 $^ | grep . > $@
${RELEASEDIR}/langids-devtest-only.txt: ${RELEASEDIR}/langids-train.txt ${RELEASEDIR}/langids-devtest.txt
comm -1 -3 $^ | grep . > $@
## cleanup some orphan files and directories
cleanup:
-for d in ${EXTRA_OPUS_PAIRS3}; do \
if [ -e ${RELEASEDIR}/$$d/train.d ]; then \
rm -f ${RELEASEDIR}/$$d/train.d/*; \
rmdir ${RELEASEDIR}/$$d/train.d; \
fi; \
rmdir ${RELEASEDIR}/$$d; \
done
## some minor fixes with uncommon langIDs in OPUS data
FIXLANGIDS = | sed 's/ze_zh/zh/g;s/_Hani//g;s/-han[st]//g;s/zht/zh_TW/g;s/zhs/zh_CN/g'
## create training data by concatenating all data sets
## using normalized language codes (macro-languages)
## TODO: this assumes that we have plain text moses files for all corpora
# test-create-train: ${RELEASEDIR}/afr-heb/train.id.gz
test-create-train: ${RELEASEDIR}/nld-uzb/train.id.gz
OPUS_API := https://opus.nlpl.eu/opusapi/
OPUS_API_MOSES := ${OPUS_API}?preprocessing=moses&version=latest
${RELEASEDIR}/%/train.id.gz:
@echo "make train data for ${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}"
@rm -f $@.tmp1 $@.tmp2
@mkdir -p ${dir $@}train.d
@( l=${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}; \
s=${firstword ${subst -, ,${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}}}; \
t=${lastword ${subst -, ,${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}}}; \
E=`${SCRIPTDIR}/find_opus_langs.pl $$s ${OPUS_LANGS}`; \
F=`${SCRIPTDIR}/find_opus_langs.pl $$t ${OPUS_LANGS}`; \
for e in $$E; do \
for f in $$F; do \
if [ $$e == $$f ]; then a=$${e}1;b=$${f}2; \
else a=$${e};b=$${f}; fi; \
for z in `wget -O - -q "${OPUS_API_MOSES}&source=$$e&target=$$f" | sed 's/^.*\[//;s/\].*$$//' | tr ',' "\n" | sed 's/"//g' | grep 'url:' | cut -f2- -d:`; do \
c=`echo "$$z" | cut -f4 -d/ | sed 's/^OPUS-//'`; \
v=`echo "$$z" | cut -f5 -d/`; \
if [ `echo '${EXCLUDE_CORPORA}' | tr ' ' "\n" | grep "$$c" | wc -l` -eq 0 ]; then \
echo "downloading $$c-$$v"; \
wget -q -O ${dir $@}train.d/moses.zip $$z; \
unzip -qq -n -d ${dir $@}train.d ${dir $@}train.d/moses.zip; \
rm -f ${dir $@}train.d/moses.zip; \
paste ${dir $@}train.d/*.$$a ${dir $@}train.d/*.$$b ${BASIC_FILTERS} \
| ${SCRIPTDIR}/exclude-identical.pl \
| ${SCRIPTDIR}/bitext-match-lang.py -s $$e -t $$f > $@.tmp2; \
rm -f ${dir $@}train.d/*; \
if [ -e $@.tmp2 ]; then \
cut -f1 $@.tmp2 | ${PARALLEL} langscript -3 -l $$e -r -D ${FIXLANGIDS} > $@.tmp2srcid; \
cut -f2 $@.tmp2 | ${PARALLEL} langscript -3 -l $$f -r -D ${FIXLANGIDS} > $@.tmp2trgid; \
paste $@.tmp2srcid $@.tmp2trgid $@.tmp2 | sed "s/^/$$c-$$v /" >> $@.tmp1; \
rm -f $@.tmp2 $@.tmp2srcid $@.tmp2trgid; \
fi \
else \
echo "exclude $$c-$$v"; \
fi \
done \
done \
done \
)
## merge with previous releases if PREVIOUS_VERSION is set
ifdef PREVIOUS_VERSION
-${MAKE} $(patsubst ${RELEASEDIR}/%,${PREVIOUS_RELEASEDIR}/%,$@)
@if [ -e $(patsubst ${RELEASEDIR}/%,${PREVIOUS_RELEASEDIR}/%,$@) ]; then \
echo "merge with previous version!"; \
l=${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}; \
s=${firstword ${subst -, ,${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}}}; \
t=${lastword ${subst -, ,${patsubst ${RELEASEDIR}/%/train.id.gz,%,$@}}}; \
paste <(gzip -cd $(patsubst ${RELEASEDIR}/%.id.gz,${PREVIOUS_RELEASEDIR}/%.src.gz,$@)) \
<(gzip -cd $(patsubst ${RELEASEDIR}/%.id.gz,${PREVIOUS_RELEASEDIR}/%.trg.gz,$@)) \
| ${SCRIPTDIR}/exclude-identical.pl > $@.tmp2; \
${GZIP} -cd $(patsubst ${RELEASEDIR}/%,${PREVIOUS_RELEASEDIR}/%,$@) | cut -f1 > $@.tmp2corpus; \
if [ -e $@.tmp2 ]; then \
cut -f1 $@.tmp2 | ${PARALLEL} langscript -3 -l $$s -r -D ${FIXLANGIDS} > $@.tmp2srcid; \
cut -f2 $@.tmp2 | ${PARALLEL} langscript -3 -l $$t -r -D ${FIXLANGIDS} > $@.tmp2trgid; \
paste $@.tmp2corpus $@.tmp2srcid $@.tmp2trgid $@.tmp2 >> $@.tmp1; \
rm -f $@.tmp2 $@.tmp2srcid $@.tmp2trgid $@.tmp2corpus; \
fi \
fi
endif
## sort, de-duplicate and shuffle the collected data
@if [ -s $@.tmp1 ]; then \
${SORT} -t ' ' -k4,5 -u < $@.tmp1 \
| ${SHUFFLE} \
| scripts/exclude-devtest.pl -a -l \
${dir $@}test.src ${dir $@}test.trg \
${dir $@}dev.src ${dir $@}dev.trg > $@.tmp2 2>$(@:.id.gz=.log); \
cut -f4 $@.tmp2 | ${GZIP} -c > ${dir $@}train.src.gz; \
cut -f5 $@.tmp2 | ${GZIP} -c > ${dir $@}train.trg.gz; \
cut -f1,2,3 $@.tmp2 | ${GZIP} -c > $@; \
fi
rm -f $@.tmp1 $@.tmp2
rmdir ${dir $@}train.d
## download the previous release
ifdef PREVIOUS_VERSION
PREVIOUS_DOWNLOAD_BASE_URL := https://object.pouta.csc.fi/Tatoeba-Challenge-${PREVIOUS_VERSION}
${PREVIOUS_RELEASEDIR}/%/train.id.gz:
@wget -q $(patsubst ${PREVIOUS_RELEASEDIR}/%/train.id.gz,${PREVIOUS_DOWNLOAD_BASE_URL}/%.tar,$@)
@if [ -e $(patsubst ${PREVIOUS_RELEASEDIR}/%/train.id.gz,%.tar,$@) ]; then \
tar -xf $(patsubst ${PREVIOUS_RELEASEDIR}/%/train.id.gz,%.tar,$@); \
rm -f $(patsubst ${PREVIOUS_RELEASEDIR}/%/train.id.gz,%.tar,$@); \
fi
endif
ifdef CHECK_PREVIOUS_VERSION
ifdef PREVIOUS_VERSION
TESTDATA_THIS_RELEASE := $(patsubst ${RELEASEDIR}/%,%,$(dir $(wildcard ${RELEASEDIR}/*/test.id)))
TRAINDATA_THIS_RELEASE := $(patsubst ${RELEASEDIR}/%,%,$(dir $(wildcard ${RELEASEDIR}/*/train.id.gz)))
TRAINDATA_PREVIOUS_RELEASE := $(patsubst ${PREVIOUS_RELEASEDIR}/%,%,$(dir $(wildcard ${PREVIOUS_RELEASEDIR}/*/train.id.gz)))
## get all training data from the previous release that are missing from the current release
## for which we also have test data in the current release
TRAINDATA_MISSING = $(filter ${TESTDATA_THIS_RELEASE},$(filter-out ${TRAINDATA_THIS_RELEASE},${TRAINDATA_PREVIOUS_RELEASE}))
print-missing-from-previous: