File size: 147,169 Bytes
78aa4ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "ari_en_nso_JW300.ipynb",
      "provenance": [],
      "collapsed_sections": [
        "1bM3_Zn34LGu"
      ],
      "toc_visible": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HlK7-onojaYL",
        "colab_type": "text"
      },
      "source": [
        "# <center>Masakhane - Machine Translation for African Languages (Using JoeyNMT)</center>\n",
        "## <leftalign> Author : Ari Ramkilowan</leftalign>\n",
        "## <leftalign> Language Pair : English - Sepedi</leftalign>\n",
        "## <leftalign> Corpus : JW300 </leftalign>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rIzB5Yo6nugf",
        "colab_type": "text"
      },
      "source": [
        "<hr>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "jPmely-suPXt",
        "colab_type": "text"
      },
      "source": [
        "## Install JoeyNMT"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "K00EyOQ3ubNH",
        "colab_type": "code",
        "outputId": "cd78988b-26d5-480c-c09b-1abfd9e7a37f",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "! git clone https://github.com/joeynmt/joeynmt.git\n",
        "! cd joeynmt; pip3 install ."
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Cloning into 'joeynmt'...\n",
            "remote: Enumerating objects: 149, done.\u001b[K\n",
            "remote: Counting objects:   0% (1/149)\u001b[K\rremote: Counting objects:   1% (2/149)\u001b[K\rremote: Counting objects:   2% (3/149)\u001b[K\rremote: Counting objects:   3% (5/149)\u001b[K\rremote: Counting objects:   4% (6/149)\u001b[K\rremote: Counting objects:   5% (8/149)\u001b[K\rremote: Counting objects:   6% (9/149)\u001b[K\rremote: Counting objects:   7% (11/149)\u001b[K\rremote: Counting objects:   8% (12/149)\u001b[K\rremote: Counting objects:   9% (14/149)\u001b[K\rremote: Counting objects:  10% (15/149)\u001b[K\rremote: Counting objects:  11% (17/149)\u001b[K\rremote: Counting objects:  12% (18/149)\u001b[K\rremote: Counting objects:  13% (20/149)\u001b[K\rremote: Counting objects:  14% (21/149)\u001b[K\rremote: Counting objects:  15% (23/149)\u001b[K\rremote: Counting objects:  16% (24/149)\u001b[K\rremote: Counting objects:  17% (26/149)\u001b[K\rremote: Counting objects:  18% (27/149)\u001b[K\rremote: Counting objects:  19% (29/149)\u001b[K\rremote: Counting objects:  20% (30/149)\u001b[K\rremote: Counting objects:  21% (32/149)\u001b[K\rremote: Counting objects:  22% (33/149)\u001b[K\rremote: Counting objects:  23% (35/149)\u001b[K\rremote: Counting objects:  24% (36/149)\u001b[K\rremote: Counting objects:  25% (38/149)\u001b[K\rremote: Counting objects:  26% (39/149)\u001b[K\rremote: Counting objects:  27% (41/149)\u001b[K\rremote: Counting objects:  28% (42/149)\u001b[K\rremote: Counting objects:  29% (44/149)\u001b[K\rremote: Counting objects:  30% (45/149)\u001b[K\rremote: Counting objects:  31% (47/149)\u001b[K\rremote: Counting objects:  32% (48/149)\u001b[K\rremote: Counting objects:  33% (50/149)\u001b[K\rremote: Counting objects:  34% (51/149)\u001b[K\rremote: Counting objects:  35% (53/149)\u001b[K\rremote: Counting objects:  36% (54/149)\u001b[K\rremote: Counting objects:  37% (56/149)\u001b[K\rremote: Counting objects:  38% (57/149)\u001b[K\rremote: Counting objects:  39% (59/149)\u001b[K\rremote: Counting objects:  40% (60/149)\u001b[K\rremote: Counting objects:  41% (62/149)\u001b[K\rremote: Counting objects:  42% (63/149)\u001b[K\rremote: Counting objects:  43% (65/149)\u001b[K\rremote: Counting objects:  44% (66/149)\u001b[K\rremote: Counting objects:  45% (68/149)\u001b[K\rremote: Counting objects:  46% (69/149)\u001b[K\rremote: Counting objects:  47% (71/149)\u001b[K\rremote: Counting objects:  48% (72/149)\u001b[K\rremote: Counting objects:  49% (74/149)\u001b[K\rremote: Counting objects:  50% (75/149)\u001b[K\rremote: Counting objects:  51% (76/149)\u001b[K\rremote: Counting objects:  52% (78/149)\u001b[K\rremote: Counting objects:  53% (79/149)\u001b[K\rremote: Counting objects:  54% (81/149)\u001b[K\rremote: Counting objects:  55% (82/149)\u001b[K\rremote: Counting objects:  56% (84/149)\u001b[K\rremote: Counting objects:  57% (85/149)\u001b[K\rremote: Counting objects:  58% (87/149)\u001b[K\rremote: Counting objects:  59% (88/149)\u001b[K\rremote: Counting objects:  60% (90/149)\u001b[K\rremote: Counting objects:  61% (91/149)\u001b[K\rremote: Counting objects:  62% (93/149)\u001b[K\rremote: Counting objects:  63% (94/149)\u001b[K\rremote: Counting objects:  64% (96/149)\u001b[K\rremote: Counting objects:  65% (97/149)\u001b[K\rremote: Counting objects:  66% (99/149)\u001b[K\rremote: Counting objects:  67% (100/149)\u001b[K\rremote: Counting objects:  68% (102/149)\u001b[K\rremote: Counting objects:  69% (103/149)\u001b[K\rremote: Counting objects:  70% (105/149)\u001b[K\rremote: Counting objects:  71% (106/149)\u001b[K\rremote: Counting objects:  72% (108/149)\u001b[K\rremote: Counting objects:  73% (109/149)\u001b[K\rremote: Counting objects:  74% (111/149)\u001b[K\rremote: Counting objects:  75% (112/149)\u001b[K\rremote: Counting objects:  76% (114/149)\u001b[K\rremote: Counting objects:  77% (115/149)\u001b[K\rremote: Counting objects:  78% (117/149)\u001b[K\rremote: Counting objects:  79% (118/149)\u001b[K\rremote: Counting objects:  80% (120/149)\u001b[K\rremote: Counting objects:  81% (121/149)\u001b[K\rremote: Counting objects:  82% (123/149)\u001b[K\rremote: Counting objects:  83% (124/149)\u001b[K\rremote: Counting objects:  84% (126/149)\u001b[K\rremote: Counting objects:  85% (127/149)\u001b[K\rremote: Counting objects:  86% (129/149)\u001b[K\rremote: Counting objects:  87% (130/149)\u001b[K\rremote: Counting objects:  88% (132/149)\u001b[K\rremote: Counting objects:  89% (133/149)\u001b[K\rremote: Counting objects:  90% (135/149)\u001b[K\rremote: Counting objects:  91% (136/149)\u001b[K\rremote: Counting objects:  92% (138/149)\u001b[K\rremote: Counting objects:  93% (139/149)\u001b[K\rremote: Counting objects:  94% (141/149)\u001b[K\rremote: Counting objects:  95% (142/149)\u001b[K\rremote: Counting objects:  96% (144/149)\u001b[K\rremote: Counting objects:  97% (145/149)\u001b[K\rremote: Counting objects:  98% (147/149)\u001b[K\rremote: Counting objects:  99% (148/149)\u001b[K\rremote: Counting objects: 100% (149/149)\u001b[K\rremote: Counting objects: 100% (149/149), done.\u001b[K\n",
            "remote: Compressing objects:   0% (1/104)\u001b[K\rremote: Compressing objects:   1% (2/104)\u001b[K\rremote: Compressing objects:   2% (3/104)\u001b[K\rremote: Compressing objects:   3% (4/104)\u001b[K\rremote: Compressing objects:   4% (5/104)\u001b[K\rremote: Compressing objects:   5% (6/104)\u001b[K\rremote: Compressing objects:   6% (7/104)\u001b[K\rremote: Compressing objects:   7% (8/104)\u001b[K\rremote: Compressing objects:   8% (9/104)\u001b[K\rremote: Compressing objects:   9% (10/104)\u001b[K\rremote: Compressing objects:  10% (11/104)\u001b[K\rremote: Compressing objects:  11% (12/104)\u001b[K\rremote: Compressing objects:  12% (13/104)\u001b[K\rremote: Compressing objects:  13% (14/104)\u001b[K\rremote: Compressing objects:  14% (15/104)\u001b[K\rremote: Compressing objects:  15% (16/104)\u001b[K\rremote: Compressing objects:  16% (17/104)\u001b[K\rremote: Compressing objects:  17% (18/104)\u001b[K\rremote: Compressing objects:  18% (19/104)\u001b[K\rremote: Compressing objects:  19% (20/104)\u001b[K\rremote: Compressing objects:  20% (21/104)\u001b[K\rremote: Compressing objects:  21% (22/104)\u001b[K\rremote: Compressing objects:  22% (23/104)\u001b[K\rremote: Compressing objects:  23% (24/104)\u001b[K\rremote: Compressing objects:  24% (25/104)\u001b[K\rremote: Compressing objects:  25% (26/104)\u001b[K\rremote: Compressing objects:  26% (28/104)\u001b[K\rremote: Compressing objects:  27% (29/104)\u001b[K\rremote: Compressing objects:  28% (30/104)\u001b[K\rremote: Compressing objects:  29% (31/104)\u001b[K\rremote: Compressing objects:  30% (32/104)\u001b[K\rremote: Compressing objects:  31% (33/104)\u001b[K\rremote: Compressing objects:  32% (34/104)\u001b[K\rremote: Compressing objects:  33% (35/104)\u001b[K\rremote: Compressing objects:  34% (36/104)\u001b[K\rremote: Compressing objects:  35% (37/104)\u001b[K\rremote: Compressing objects:  36% (38/104)\u001b[K\rremote: Compressing objects:  37% (39/104)\u001b[K\rremote: Compressing objects:  38% (40/104)\u001b[K\rremote: Compressing objects:  39% (41/104)\u001b[K\rremote: Compressing objects:  40% (42/104)\u001b[K\rremote: Compressing objects:  41% (43/104)\u001b[K\rremote: Compressing objects:  42% (44/104)\u001b[K\rremote: Compressing objects:  43% (45/104)\u001b[K\rremote: Compressing objects:  44% (46/104)\u001b[K\rremote: Compressing objects:  45% (47/104)\u001b[K\rremote: Compressing objects:  46% (48/104)\u001b[K\rremote: Compressing objects:  47% (49/104)\u001b[K\rremote: Compressing objects:  48% (50/104)\u001b[K\rremote: Compressing objects:  49% (51/104)\u001b[K\rremote: Compressing objects:  50% (52/104)\u001b[K\rremote: Compressing objects:  51% (54/104)\u001b[K\rremote: Compressing objects:  52% (55/104)\u001b[K\rremote: Compressing objects:  53% (56/104)\u001b[K\rremote: Compressing objects:  54% (57/104)\u001b[K\rremote: Compressing objects:  55% (58/104)\u001b[K\rremote: Compressing objects:  56% (59/104)\u001b[K\rremote: Compressing objects:  57% (60/104)\u001b[K\rremote: Compressing objects:  58% (61/104)\u001b[K\rremote: Compressing objects:  59% (62/104)\u001b[K\rremote: Compressing objects:  60% (63/104)\u001b[K\rremote: Compressing objects:  61% (64/104)\u001b[K\rremote: Compressing objects:  62% (65/104)\u001b[K\rremote: Compressing objects:  63% (66/104)\u001b[K\rremote: Compressing objects:  64% (67/104)\u001b[K\rremote: Compressing objects:  65% (68/104)\u001b[K\rremote: Compressing objects:  66% (69/104)\u001b[K\rremote: Compressing objects:  67% (70/104)\u001b[K\rremote: Compressing objects:  68% (71/104)\u001b[K\rremote: Compressing objects:  69% (72/104)\u001b[K\rremote: Compressing objects:  70% (73/104)\u001b[K\rremote: Compressing objects:  71% (74/104)\u001b[K\rremote: Compressing objects:  72% (75/104)\u001b[K\rremote: Compressing objects:  73% (76/104)\u001b[K\rremote: Compressing objects:  74% (77/104)\u001b[K\rremote: Compressing objects:  75% (78/104)\u001b[K\rremote: Compressing objects:  76% (80/104)\u001b[K\rremote: Compressing objects:  77% (81/104)\u001b[K\rremote: Compressing objects:  78% (82/104)\u001b[K\rremote: Compressing objects:  79% (83/104)\u001b[K\rremote: Compressing objects:  80% (84/104)\u001b[K\rremote: Compressing objects:  81% (85/104)\u001b[K\rremote: Compressing objects:  82% (86/104)\u001b[K\rremote: Compressing objects:  83% (87/104)\u001b[K\rremote: Compressing objects:  84% (88/104)\u001b[K\rremote: Compressing objects:  85% (89/104)\u001b[K\rremote: Compressing objects:  86% (90/104)\u001b[K\rremote: Compressing objects:  87% (91/104)\u001b[K\rremote: Compressing objects:  88% (92/104)\u001b[K\rremote: Compressing objects:  89% (93/104)\u001b[K\rremote: Compressing objects:  90% (94/104)\u001b[K\rremote: Compressing objects:  91% (95/104)\u001b[K\rremote: Compressing objects:  92% (96/104)\u001b[K\rremote: Compressing objects:  93% (97/104)\u001b[K\rremote: Compressing objects:  94% (98/104)\u001b[K\rremote: Compressing objects:  95% (99/104)\u001b[K\rremote: Compressing objects:  96% (100/104)\u001b[K\rremote: Compressing objects:  97% (101/104)\u001b[K\rremote: Compressing objects:  98% (102/104)\u001b[K\rremote: Compressing objects:  99% (103/104)\u001b[K\rremote: Compressing objects: 100% (104/104)\u001b[K\rremote: Compressing objects: 100% (104/104), done.\u001b[K\n",
            "Receiving objects:   0% (1/2333)   \rReceiving objects:   1% (24/2333)   \rReceiving objects:   2% (47/2333)   \rReceiving objects:   3% (70/2333)   \rReceiving objects:   4% (94/2333)   \rReceiving objects:   5% (117/2333)   \rReceiving objects:   6% (140/2333)   \rReceiving objects:   7% (164/2333)   \rReceiving objects:   8% (187/2333)   \rReceiving objects:   9% (210/2333)   \rReceiving objects:  10% (234/2333)   \rReceiving objects:  11% (257/2333)   \rReceiving objects:  12% (280/2333)   \rReceiving objects:  13% (304/2333)   \rReceiving objects:  14% (327/2333)   \rReceiving objects:  15% (350/2333)   \rReceiving objects:  16% (374/2333)   \rReceiving objects:  17% (397/2333)   \rReceiving objects:  18% (420/2333)   \rReceiving objects:  19% (444/2333)   \rReceiving objects:  20% (467/2333)   \rReceiving objects:  21% (490/2333)   \rReceiving objects:  22% (514/2333)   \rReceiving objects:  23% (537/2333)   \rReceiving objects:  24% (560/2333)   \rReceiving objects:  25% (584/2333)   \rReceiving objects:  26% (607/2333)   \rReceiving objects:  27% (630/2333)   \rReceiving objects:  28% (654/2333)   \rReceiving objects:  29% (677/2333)   \rReceiving objects:  30% (700/2333)   \rReceiving objects:  31% (724/2333)   \rReceiving objects:  32% (747/2333)   \rReceiving objects:  33% (770/2333)   \rReceiving objects:  34% (794/2333)   \rReceiving objects:  35% (817/2333)   \rReceiving objects:  36% (840/2333)   \rReceiving objects:  37% (864/2333)   \rReceiving objects:  38% (887/2333)   \rReceiving objects:  39% (910/2333)   \rReceiving objects:  40% (934/2333)   \rReceiving objects:  41% (957/2333)   \rReceiving objects:  42% (980/2333)   \rReceiving objects:  43% (1004/2333)   \rReceiving objects:  44% (1027/2333)   \rReceiving objects:  45% (1050/2333)   \rReceiving objects:  46% (1074/2333)   \rReceiving objects:  47% (1097/2333)   \rReceiving objects:  48% (1120/2333)   \rReceiving objects:  49% (1144/2333)   \rReceiving objects:  50% (1167/2333)   \rReceiving objects:  51% (1190/2333)   \rReceiving objects:  52% (1214/2333)   \rReceiving objects:  53% (1237/2333)   \rReceiving objects:  54% (1260/2333)   \rReceiving objects:  55% (1284/2333)   \rReceiving objects:  56% (1307/2333)   \rReceiving objects:  57% (1330/2333)   \rReceiving objects:  58% (1354/2333)   \rReceiving objects:  59% (1377/2333)   \rReceiving objects:  60% (1400/2333)   \rReceiving objects:  61% (1424/2333)   \rReceiving objects:  62% (1447/2333)   \rReceiving objects:  63% (1470/2333)   \rReceiving objects:  64% (1494/2333)   \rReceiving objects:  65% (1517/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  66% (1540/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  67% (1564/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  68% (1587/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  69% (1610/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  70% (1634/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  71% (1657/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  72% (1680/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  73% (1704/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  74% (1727/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  75% (1750/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  76% (1774/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  77% (1797/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  78% (1820/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  79% (1844/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  80% (1867/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  81% (1890/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  82% (1914/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  83% (1937/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  84% (1960/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  85% (1984/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  86% (2007/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  87% (2030/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  88% (2054/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  89% (2077/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  90% (2100/2333), 2.36 MiB | 4.58 MiB/s   \rremote: Total 2333 (delta 98), reused 72 (delta 45), pack-reused 2184\u001b[K\n",
            "Receiving objects:  91% (2124/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  92% (2147/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  93% (2170/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  94% (2194/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  95% (2217/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  96% (2240/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  97% (2264/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  98% (2287/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects:  99% (2310/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects: 100% (2333/2333), 2.36 MiB | 4.58 MiB/s   \rReceiving objects: 100% (2333/2333), 2.64 MiB | 5.03 MiB/s, done.\n",
            "Resolving deltas: 100% (1619/1619), done.\n",
            "Processing /content/joeynmt\n",
            "Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.16.0)\n",
            "Requirement already satisfied: pillow in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (6.2.2)\n",
            "Requirement already satisfied: numpy<2.0,>=1.14.5 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.17.5)\n",
            "Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (45.1.0)\n",
            "Requirement already satisfied: torch>=1.1 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.4.0)\n",
            "Requirement already satisfied: tensorflow>=1.14 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.15.0)\n",
            "Requirement already satisfied: torchtext in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.3.1)\n",
            "Collecting sacrebleu>=1.3.6\n",
            "  Downloading https://files.pythonhosted.org/packages/45/31/1a135b964c169984b27fb2f7a50280fa7f8e6d9d404d8a9e596180487fd1/sacrebleu-1.4.3-py3-none-any.whl\n",
            "Collecting subword-nmt\n",
            "  Downloading https://files.pythonhosted.org/packages/74/60/6600a7bc09e7ab38bc53a48a20d8cae49b837f93f5842a41fe513a694912/subword_nmt-0.3.7-py2.py3-none-any.whl\n",
            "Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (3.1.3)\n",
            "Requirement already satisfied: seaborn in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (0.10.0)\n",
            "Collecting pyyaml>=5.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3d/d9/ea9816aea31beeadccd03f1f8b625ecf8f645bd66744484d162d84803ce5/PyYAML-5.3.tar.gz (268kB)\n",
            "\u001b[K     |████████████████████████████████| 276kB 24.8MB/s \n",
            "\u001b[?25hCollecting pylint\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/e9/59/43fc36c5ee316bb9aeb7cf5329cdbdca89e5749c34d5602753827c0aa2dc/pylint-2.4.4-py3-none-any.whl (302kB)\n",
            "\u001b[K     |████████████████████████████████| 307kB 67.8MB/s \n",
            "\u001b[?25hRequirement already satisfied: six==1.12 in /usr/local/lib/python3.6/dist-packages (from joeynmt==0.0.1) (1.12.0)\n",
            "Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.34.2)\n",
            "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (3.1.0)\n",
            "Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.9.0)\n",
            "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.27.1)\n",
            "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.1.0)\n",
            "Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (3.10.0)\n",
            "Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.11.2)\n",
            "Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.8.1)\n",
            "Requirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.1.8)\n",
            "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.1.0)\n",
            "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.15.0)\n",
            "Requirement already satisfied: tensorflow-estimator==1.15.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.15.1)\n",
            "Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (1.0.8)\n",
            "Requirement already satisfied: gast==0.2.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=1.14->joeynmt==0.0.1) (0.2.2)\n",
            "Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from torchtext->joeynmt==0.0.1) (2.21.0)\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from torchtext->joeynmt==0.0.1) (4.28.1)\n",
            "Collecting portalocker\n",
            "  Downloading https://files.pythonhosted.org/packages/91/db/7bc703c0760df726839e0699b7f78a4d8217fdc9c7fcb1b51b39c5a22a4e/portalocker-1.5.2-py2.py3-none-any.whl\n",
            "Requirement already satisfied: typing in /usr/local/lib/python3.6/dist-packages (from sacrebleu>=1.3.6->joeynmt==0.0.1) (3.6.6)\n",
            "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (2.4.6)\n",
            "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (1.1.0)\n",
            "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (2.6.1)\n",
            "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->joeynmt==0.0.1) (0.10.0)\n",
            "Requirement already satisfied: scipy>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from seaborn->joeynmt==0.0.1) (1.4.1)\n",
            "Requirement already satisfied: pandas>=0.22.0 in /usr/local/lib/python3.6/dist-packages (from seaborn->joeynmt==0.0.1) (0.25.3)\n",
            "Collecting astroid<2.4,>=2.3.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/ad/ae/86734823047962e7b8c8529186a1ac4a7ca19aaf1aa0c7713c022ef593fd/astroid-2.3.3-py3-none-any.whl (205kB)\n",
            "\u001b[K     |████████████████████████████████| 215kB 36.6MB/s \n",
            "\u001b[?25hCollecting isort<5,>=4.2.5\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/e5/b0/c121fd1fa3419ea9bfd55c7f9c4fedfec5143208d8c7ad3ce3db6c623c21/isort-4.3.21-py2.py3-none-any.whl (42kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 7.6MB/s \n",
            "\u001b[?25hCollecting mccabe<0.7,>=0.6\n",
            "  Downloading https://files.pythonhosted.org/packages/87/89/479dc97e18549e21354893e4ee4ef36db1d237534982482c3681ee6e7b57/mccabe-0.6.1-py2.py3-none-any.whl\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow>=1.14->joeynmt==0.0.1) (3.2)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow>=1.14->joeynmt==0.0.1) (1.0.0)\n",
            "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.8->tensorflow>=1.14->joeynmt==0.0.1) (2.8.0)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (2019.11.28)\n",
            "Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (1.24.3)\n",
            "Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (2.8)\n",
            "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext->joeynmt==0.0.1) (3.0.4)\n",
            "Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas>=0.22.0->seaborn->joeynmt==0.0.1) (2018.9)\n",
            "Collecting typed-ast<1.5,>=1.4.0; implementation_name == \"cpython\" and python_version < \"3.8\"\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/90/ed/5459080d95eb87a02fe860d447197be63b6e2b5e9ff73c2b0a85622994f4/typed_ast-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (737kB)\n",
            "\u001b[K     |████████████████████████████████| 747kB 69.7MB/s \n",
            "\u001b[?25hCollecting lazy-object-proxy==1.4.*\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/0b/dd/b1e3407e9e6913cf178e506cd0dee818e58694d9a5cd1984e3f6a8b9a10f/lazy_object_proxy-1.4.3-cp36-cp36m-manylinux1_x86_64.whl (55kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 9.8MB/s \n",
            "\u001b[?25hBuilding wheels for collected packages: joeynmt, pyyaml\n",
            "  Building wheel for joeynmt (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for joeynmt: filename=joeynmt-0.0.1-cp36-none-any.whl size=73467 sha256=5e896def4c67279e034c19c21caeb2ec5567599582c93bb52abe938e59ec6f3d\n",
            "  Stored in directory: /tmp/pip-ephem-wheel-cache-sgho47kl/wheels/db/01/db/751cc9f3e7f6faec127c43644ba250a3ea7ad200594aeda70a\n",
            "  Building wheel for pyyaml (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for pyyaml: filename=PyYAML-5.3-cp36-cp36m-linux_x86_64.whl size=44229 sha256=ed83f142725ff5dba14f0f4dc7f30ea5cdba2a766ba1ebedc49fc88365c2bdec\n",
            "  Stored in directory: /root/.cache/pip/wheels/e4/76/4d/a95b8dd7b452b69e8ed4f68b69e1b55e12c9c9624dd962b191\n",
            "Successfully built joeynmt pyyaml\n",
            "Installing collected packages: portalocker, sacrebleu, subword-nmt, pyyaml, typed-ast, lazy-object-proxy, astroid, isort, mccabe, pylint, joeynmt\n",
            "  Found existing installation: PyYAML 3.13\n",
            "    Uninstalling PyYAML-3.13:\n",
            "      Successfully uninstalled PyYAML-3.13\n",
            "Successfully installed astroid-2.3.3 isort-4.3.21 joeynmt-0.0.1 lazy-object-proxy-1.4.3 mccabe-0.6.1 portalocker-1.5.2 pylint-2.4.4 pyyaml-5.3 sacrebleu-1.4.3 subword-nmt-0.3.7 typed-ast-1.4.1\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ZX77ylHfjtY0",
        "colab_type": "text"
      },
      "source": [
        "## Mount Google Drive\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Gg_9x3FloWuU",
        "colab_type": "code",
        "outputId": "98fd36dc-645d-4e64-ad41-b7a1acd29365",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 124
        }
      },
      "source": [
        "# If running on Google Colab - mount google drive\n",
        "\n",
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code&scope=email%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdocs.test%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive%20https%3a%2f%2fwww.googleapis.com%2fauth%2fdrive.photos.readonly%20https%3a%2f%2fwww.googleapis.com%2fauth%2fpeopleapi.readonly\n",
            "\n",
            "Enter your authorization code:\n",
            "··········\n",
            "Mounted at /content/drive\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yhkiqqjt0fV9",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "441Z4I3rn7DB",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# TODO : access data on kaggle kernels"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ufEVGDe_okx3",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# TODO : Access data on paperspace"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "5Roa6jIMov3V",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# TODo : Access data on GCP"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mPElaQv_oy5q",
        "colab_type": "text"
      },
      "source": [
        "## Set your source and target languages\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3Dj54KjZ2wal",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "\n",
        "import os\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "\n",
        "source_language = \"en\"\n",
        "target_language = \"nso\" \n",
        "lc = True  # If True, lowercase the data.\n",
        "seed = 42  # Random seed for shuffling.\n",
        "tag = \"baseline\" # Give a unique name to your folder - this is to ensure you don't rewrite any models you've already submitted\n",
        "# aggressive : more attention and more dropout\n",
        "vocab_size=4000\n",
        "corpus = \"JW300\"\n",
        "\n",
        "os.environ[\"src\"] = source_language # Sets them in bash as well, since we often use bash scripts\n",
        "os.environ[\"trg\"] = target_language\n",
        "os.environ[\"tag\"] = tag\n",
        "os.environ[\"vocab_size\"] = str(vocab_size)\n",
        "os.environ[\"corpus\"] = corpus"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "5YcHw7PW3Tvb",
        "colab_type": "code",
        "outputId": "2cdfaf6d-cb35-40c5-a906-3c81b2a03d92",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "# This will save it to a folder in our gdrive instead!\n",
        "# !mkdir -p \"/content/drive/My Drive/masakhane/$src-$trg-$tag\"\n",
        "gdrive_path = f\"/content/drive/My Drive/masakhane/{source_language}-{target_language}-{tag}/\"\n",
        "os.environ[\"gdrive_path\"] = gdrive_path\n",
        "! echo $gdrive_path"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/content/drive/My Drive/masakhane/en-nso-baseline/\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Y99OKT00fnrO",
        "colab_type": "code",
        "outputId": "48b57d43-7c91-433f-b81d-b7c628a93a86",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 156
        }
      },
      "source": [
        "# create path to joeynmt executables scripts, configs etc\n",
        "\n",
        "joey_path = f\"/content/joeynmt\"\n",
        "os.environ[\"joey_path\"] = joey_path\n",
        "! ls $joey_path/configs"
      ],
      "execution_count": 5,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "iwslt14_deen_bpe.yaml\t\t   transformer_reverse.yaml\n",
            "iwslt_deen_bahdanau.yaml\t   transformer_small.yaml\n",
            "iwslt_envi_luong.yaml\t\t   transformer_wmt17_ende.yaml\n",
            "iwslt_envi_xnmt.yaml\t\t   transformer_wmt17_lven.yaml\n",
            "reverse.yaml\t\t\t   wmt_ende_best.yaml\n",
            "small.yaml\t\t\t   wmt_ende_default.yaml\n",
            "transformer_copy.yaml\t\t   wmt_lven_best.yaml\n",
            "transformer_iwslt14_deen_bpe.yaml  wmt_lven_default.yaml\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1bM3_Zn34LGu",
        "colab_type": "text"
      },
      "source": [
        "## Download the global test set.\n",
        " **(This changes from time to time, do this just to make sure you have the most recent version)**\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "36X7RKhb4a7P",
        "colab_type": "code",
        "outputId": "ddd9a636-1563-40b1-dbdc-38b740bf0ad7",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 610
        }
      },
      "source": [
        "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-any.en\n",
        "  \n",
        "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-$trg.en\n",
        "! mv test.en-$trg.en test.en\n",
        "\n",
        "! wget https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-$trg.$trg \n",
        "! mv test.en-$trg.$trg test.$trg"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "--2019-11-03 20:36:39--  https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-any.en\n",
            "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n",
            "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 277791 (271K) [text/plain]\n",
            "Saving to: ‘test.en-any.en.1’\n",
            "\n",
            "\rtest.en-any.en.1      0%[                    ]       0  --.-KB/s               \rtest.en-any.en.1    100%[===================>] 271.28K  --.-KB/s    in 0.05s   \n",
            "\n",
            "2019-11-03 20:36:40 (5.35 MB/s) - ‘test.en-any.en.1’ saved [277791/277791]\n",
            "\n",
            "--2019-11-03 20:36:42--  https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-nso.en\n",
            "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n",
            "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 205401 (201K) [text/plain]\n",
            "Saving to: ‘test.en-nso.en’\n",
            "\n",
            "test.en-nso.en      100%[===================>] 200.59K  --.-KB/s    in 0.04s   \n",
            "\n",
            "2019-11-03 20:36:42 (5.22 MB/s) - ‘test.en-nso.en’ saved [205401/205401]\n",
            "\n",
            "--2019-11-03 20:36:47--  https://raw.githubusercontent.com/juliakreutzer/masakhane/master/jw300_utils/test/test.en-nso.nso\n",
            "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n",
            "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 244175 (238K) [text/plain]\n",
            "Saving to: ‘test.en-nso.nso’\n",
            "\n",
            "test.en-nso.nso     100%[===================>] 238.45K  --.-KB/s    in 0.05s   \n",
            "\n",
            "2019-11-03 20:36:48 (4.69 MB/s) - ‘test.en-nso.nso’ saved [244175/244175]\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DQjxBMQu4AbK",
        "colab_type": "code",
        "outputId": "10236c38-b28e-4e67-c3ff-ed11f2a502a0",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 237
        }
      },
      "source": [
        "# Read the test data to filter from train and dev splits.\n",
        "# Store english portion in set for quick filtering checks.\n",
        "en_test_sents = set()\n",
        "filter_test_sents = \"test.en-any.en\"\n",
        "j = 0\n",
        "blanks=[]\n",
        "with open(filter_test_sents) as f:\n",
        "  for line in f:\n",
        "    en_test_sents.add(line.strip())\n",
        "    if len(line)<=1:\n",
        "      blanks.append(j)\n",
        "    j += 1\n",
        "print('Loaded {} global test sentences to filter from the training/dev data.'.format(j))"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "error",
          "ename": "FileNotFoundError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-7-55e9942919fa>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0mblanks\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilter_test_sents\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      6\u001b[0m   \u001b[0;32mfor\u001b[0m \u001b[0mline\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m     \u001b[0men_test_sents\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'test.en-any.en'"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "kKr8Kma8oB1u",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# filter test set\n",
        "\n",
        "source_file = f\"test.{source_language}\"\n",
        "target_file = f\"test.{target_language}\"\n",
        "\n",
        "source = []\n",
        "target = []\n",
        "\n",
        "with open(source_file) as f:\n",
        "  source = f.readlines()\n",
        "            \n",
        "with open(target_file) as f:\n",
        "  target = f.readlines()\n",
        "\n",
        "df = pd.DataFrame(zip(source, target), columns=['source_sentence', 'target_sentence'])\n",
        "\n",
        "# remove trailing newline chars\n",
        "df['source_sentence'] = df['source_sentence'].str.rstrip('\" \\n')\n",
        "df['target_sentence'] = df['target_sentence'].str.rstrip('\" \\n')\n",
        "\n",
        "# remove leading newline chars\n",
        "df['source_sentence'] = df['source_sentence'].str.lstrip('\"')\n",
        "df['target_sentence'] = df['target_sentence'].str.lstrip('\"')\n",
        "\n",
        "# remove rows with really short sentences\n",
        "df = df[~(df['source_sentence'].str.len() <8)] # remove rows wher esource text len <8 characters\n",
        "df = df[~(df['target_sentence'].str.len() <8)] # remove rows wher esource text len <8 characters\n",
        "\n",
        "# save the filtered test set\n",
        "df['source_sentence'].to_csv(f'{source_file}', index=False, header=False, doublequote=False)\n",
        "df['target_sentence'].to_csv(f'{target_file}', index=False, header=False, doublequote=False)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_BQ_g1o3gUHD",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# copy test sets to gdrive\n",
        "! cp test.$src \"$gdrive_path\"\n",
        "! cp test.$trg \"$gdrive_path\"\n",
        "! cp test.$src-any.$src \"$gdrive_path\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LY9LrzQp5BOC",
        "colab_type": "text"
      },
      "source": [
        "## Import prepared dataset"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1faMfeV45M9A",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import pandas as pd\n",
        "from IPython.core.interactiveshell import InteractiveShell\n",
        "InteractiveShell.ast_node_interactivity = \"all\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "OgtN5iU95BKe",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# This csv has extra columns added but no preprocessing done. all preprocessing should be captured in the NMT modelling notebook\n",
        "\n",
        "input_file = f\"{gdrive_path}/{source_language}-{target_language}-{corpus}-new.csv\"\n",
        "df = pd.read_csv(input_file)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "7mVDMOgsA2L1",
        "colab_type": "code",
        "outputId": "0715d9cb-e0fb-4ef8-dbb9-4ea068053951",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 206
        }
      },
      "source": [
        "df.head()"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>source_sentence</th>\n",
              "      <th>target_sentence</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>They Rejoiced in Eastern Europe</td>\n",
              "      <td>Ba Ile Ba Thaba Ka Bohlabela Bja Yuropa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>THIS past summer tens of thousands of people f...</td>\n",
              "      <td>SELEMONG se se se fetilego batho ba masome a d...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>The streets of beautiful Budapest , Prague , Z...</td>\n",
              "      <td>Ditarata tša Budapest e botse , Prague , Zagre...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>These identified them as lovers of godly freed...</td>\n",
              "      <td>Tše di be di ba hlaola e le barati ba tokologo...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>For the first time ever , conventions were fre...</td>\n",
              "      <td>Ka lekga la mathomo - thomo , dikopano di ile ...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "                                     source_sentence                                    target_sentence\n",
              "0                    They Rejoiced in Eastern Europe            Ba Ile Ba Thaba Ka Bohlabela Bja Yuropa\n",
              "1  THIS past summer tens of thousands of people f...  SELEMONG se se se fetilego batho ba masome a d...\n",
              "2  The streets of beautiful Budapest , Prague , Z...  Ditarata tša Budapest e botse , Prague , Zagre...\n",
              "3  These identified them as lovers of godly freed...  Tše di be di ba hlaola e le barati ba tokologo...\n",
              "4  For the first time ever , conventions were fre...  Ka lekga la mathomo - thomo , dikopano di ile ..."
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 8
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "94Oq1C-YAkKz",
        "colab_type": "code",
        "outputId": "62356727-32a0-4016-a0b6-e93eb1bfab6e",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "source": [
        "# How many samples\n",
        "size = len(df)\n",
        "print(f\"\\n {size} samples in original text\")\n",
        "  "
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\n",
            " 622966 samples in original text\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XC0KJNbsZz-z",
        "colab_type": "text"
      },
      "source": [
        "## Preprocess input data"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "RNWGwHE-6tHQ",
        "colab_type": "code",
        "outputId": "e86ca1fe-0bd5-4d47-c293-8a4cc143a19c",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 173
        }
      },
      "source": [
        "## Preprocessing - Step 1 : Drop NaNs\n",
        "\n",
        "df_pp = df.dropna()\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping all NaNs\")\n",
        "size = new_size"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 613348 entries, 0 to 622965\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    613348 non-null object\n",
            "target_sentence    613348 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 285.1 MB\n",
            "\n",
            " 9618(1.54 %) samples removed by dropping all NaNs\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "R-CAf05t67va",
        "colab_type": "code",
        "outputId": "590bca3b-0060-4e6b-8b30-2b8dd3c1827a",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 173
        }
      },
      "source": [
        "## Preprocessing - Step 2a : Drop all duplicates in Source (en) text\n",
        "\n",
        "df_pp = df_pp.drop_duplicates(subset='source_sentence')\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping Source sentence duplicates\")\n",
        "size = new_size"
      ],
      "execution_count": 11,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 570881 entries, 0 to 622965\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    570881 non-null object\n",
            "target_sentence    570881 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 302.1 MB\n",
            "\n",
            " 42467(6.92 %) samples removed by dropping Source sentence duplicates\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "IoPGdLI_n6_L",
        "colab_type": "code",
        "outputId": "e6872b32-cfd0-465f-b18c-4092bd4b01f9",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 173
        }
      },
      "source": [
        "## Preprocessing - Step 2b : Drop all duplicates in Target (zu) text\n",
        "\n",
        "df_pp = df_pp.drop_duplicates(subset='target_sentence')\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping Target sentence duplicates\")\n",
        "size = new_size"
      ],
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567792 entries, 0 to 622965\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    567792 non-null object\n",
            "target_sentence    567792 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 359.6 MB\n",
            "\n",
            " 3089(0.54 %) samples removed by dropping Target sentence duplicates\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "q0vDJborInA_",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "##  Preprocessing - Step 3 : Remove all numeric entries\n",
        "\n",
        "pattern = r\"([0-9]*\\.?[0-9]*)\"  # catch integers and decimals\n",
        "import re\n",
        "r = re.compile(pattern)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "n0OvHiNFL-8z",
        "colab_type": "code",
        "outputId": "c1b29cb2-c081-43f5-e69b-226a8a3b2854",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 208
        }
      },
      "source": [
        "%%time\n",
        "##  Preprocessing - Step 3a : Remove all numeric entries - Source text\n",
        "\n",
        "df_pp['source_sentence'] = df_pp['source_sentence'].str.replace(pattern,\"\")\n",
        "df_pp['source_sentence'] = df_pp['source_sentence'].replace(\"\",np.nan)\n",
        "\n",
        "df_pp = df_pp.dropna()\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping nummeric entries from source text\")\n",
        "size = new_size"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567720 entries, 0 to 622965\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    567720 non-null object\n",
            "target_sentence    567720 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 331.8 MB\n",
            "\n",
            " 72(0.01 %) samples removed by dropping nummeric entries from source text\n",
            "CPU times: user 9.93 s, sys: 62 ms, total: 9.99 s\n",
            "Wall time: 10 s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DlVWfIVJQ_Tn",
        "colab_type": "code",
        "outputId": "db6c9bd0-23f1-4d85-aae4-58d3d8572e63",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 208
        }
      },
      "source": [
        "%%time\n",
        "##  Preprocessing - Step 3b : Remove all numeric entries - Target text\n",
        "\n",
        "df_pp['target_sentence'] = df_pp['target_sentence'].str.replace(r,\"\")\n",
        "df_pp['target_sentence'] = df_pp['target_sentence'].replace(\"\",np.nan)\n",
        "\n",
        "df_pp = df_pp.dropna()\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping nummeric entries from target text\")\n",
        "size = new_size"
      ],
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567699 entries, 0 to 622965\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    567699 non-null object\n",
            "target_sentence    567699 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 271.9 MB\n",
            "\n",
            " 21(0.00 %) samples removed by dropping nummeric entries from target text\n",
            "CPU times: user 11.9 s, sys: 99.8 ms, total: 12 s\n",
            "Wall time: 12 s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4dZI2WM78oCO",
        "colab_type": "text"
      },
      "source": [
        "#### Preprocessing - Step 4 :Get length of sentences and then drop really short sentences\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab_type": "code",
        "outputId": "28086ea5-6fe9-44de-bc81-78e3aeeb0ef4",
        "id": "zb6yGGDJAZ5H",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 243
        }
      },
      "source": [
        "%%time\n",
        "# add length columns\n",
        "\n",
        "\n",
        "df_pp['source_ch_len'] = df_pp['source_sentence'].str.len()\n",
        "df_pp['source_w_len'] = [len(text.split()) for text in df_pp['source_sentence']] \n",
        "df_pp['target_ch_len'] = df_pp['target_sentence'].str.len()\n",
        "df_pp['target_w_len'] = [len(text.split()) for text in df_pp['target_sentence']] \n",
        "df_pp.info(memory_usage='deep')"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567699 entries, 0 to 622965\n",
            "Data columns (total 6 columns):\n",
            "source_sentence    567699 non-null object\n",
            "target_sentence    567699 non-null object\n",
            "source_ch_len      567699 non-null int64\n",
            "source_w_len       567699 non-null int64\n",
            "target_ch_len      567699 non-null int64\n",
            "target_w_len       567699 non-null int64\n",
            "dtypes: int64(4), object(2)\n",
            "memory usage: 289.2 MB\n",
            "CPU times: user 3.07 s, sys: 22.3 ms, total: 3.09 s\n",
            "Wall time: 3.09 s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "M6SecEMNBkC7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# # character len distrn - source text - \n",
        "# df_pp['source_ch_len'].value_counts().sort_index()"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "A9TFizHyVWKO",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# # character len distrn - target text\n",
        "# df_pp['target_ch_len'].value_counts().sort_index()"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "9ArLyuzIwtLq",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "## how many rows with source text <=2chars and what do they look like ?"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "t-e7zGtV-eyq",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# # how many single character sentences from source ?\n",
        "# f\"{df_pp['source_ch_len'].value_counts()[1]} single character source sentences\"\n",
        "\n",
        "# df_pp[df_pp['source_ch_len']<=1]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qDe_eeocuBDw",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# # how many 2-character sentences from source ?\n",
        "# f\"{df_pp['source_ch_len'].value_counts()[2]} 2-character source sentences\"\n",
        "\n",
        "# df_pp[df_pp['source_ch_len']==2]"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "agiL0pRVyOEz",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "sPTL3nKqyWjv",
        "colab_type": "code",
        "outputId": "73e4484e-2117-4e60-a017-769a5b26d41d",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 243
        }
      },
      "source": [
        "##  Preprocessing - Step 4a :  drop everything where the ch_len <=2 in source text\n",
        "\n",
        "df_pp = df_pp[~(df_pp['source_ch_len'] <=2) ]\n",
        "\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with source sentences <= 2 characters\")\n",
        "size = new_size"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567486 entries, 0 to 622965\n",
            "Data columns (total 6 columns):\n",
            "source_sentence    567486 non-null object\n",
            "target_sentence    567486 non-null object\n",
            "source_ch_len      567486 non-null int64\n",
            "source_w_len       567486 non-null int64\n",
            "target_ch_len      567486 non-null int64\n",
            "target_w_len       567486 non-null int64\n",
            "dtypes: int64(4), object(2)\n",
            "memory usage: 289.2 MB\n",
            "\n",
            " 213(0.04 %) samples removed by dropping rows with source sentences <= 2 characters\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_gnkwkS11rHW",
        "colab_type": "code",
        "outputId": "d274e25a-68df-4b85-e405-8a8e37f8349e",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 243
        }
      },
      "source": [
        "##  Preprocessing - Step 4b :  drop everything where the ch_len <=2 in target text\n",
        "\n",
        "df_pp = df_pp[~(df_pp['target_ch_len'] <=2) ]\n",
        "\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with target sentences <= 2 characters\")\n",
        "size = new_size"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 567470 entries, 0 to 622965\n",
            "Data columns (total 6 columns):\n",
            "source_sentence    567470 non-null object\n",
            "target_sentence    567470 non-null object\n",
            "source_ch_len      567470 non-null int64\n",
            "source_w_len       567470 non-null int64\n",
            "target_ch_len      567470 non-null int64\n",
            "target_w_len       567470 non-null int64\n",
            "dtypes: int64(4), object(2)\n",
            "memory usage: 289.2 MB\n",
            "\n",
            " 16(0.00 %) samples removed by dropping rows with target sentences <= 2 characters\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tYgL_BspMu8t",
        "colab_type": "code",
        "outputId": "69c61591-2950-4c1b-c80e-531ebb7092ea",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 278
        }
      },
      "source": [
        "%%time\n",
        "##  Preprocessing - Step 5 :  remove text from test set\n",
        "\n",
        "with open(f\"{gdrive_path}/test.en-any.en\") as f:\n",
        "    rows = f.readlines()\n",
        "test_set_en = [row.strip() for row in rows]\n",
        "\n",
        "\n",
        "df_pp = df_pp[~df_pp['source_sentence'].str.strip().isin(test_set_en)]\n",
        "\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows from test set\")\n",
        "size = new_size"
      ],
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 566404 entries, 0 to 622965\n",
            "Data columns (total 6 columns):\n",
            "source_sentence    566404 non-null object\n",
            "target_sentence    566404 non-null object\n",
            "source_ch_len      566404 non-null int64\n",
            "source_w_len       566404 non-null int64\n",
            "target_ch_len      566404 non-null int64\n",
            "target_w_len       566404 non-null int64\n",
            "dtypes: int64(4), object(2)\n",
            "memory usage: 288.7 MB\n",
            "\n",
            " 1066(0.19 %) samples removed by dropping rows from test set\n",
            "CPU times: user 1.36 s, sys: 34 ms, total: 1.39 s\n",
            "Wall time: 2.05 s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6IvLGPZg--pK",
        "colab_type": "code",
        "outputId": "a7c8053f-0561-46e4-8f5d-b4fe11152f79",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 278
        }
      },
      "source": [
        "%%time\n",
        "##  Preprocessing - Step 6 :  remove the extra \"\n",
        "df_pp['source_sentence'] = df_pp['source_sentence'].map(lambda x: x.lstrip('\"').rstrip('\"'))\n",
        "df_pp['target_sentence'] = df_pp['target_sentence'].map(lambda x: x.lstrip('\"').rstrip('\"'))\n",
        "\n",
        "\n",
        "df_pp.info(memory_usage='deep')\n",
        "new_size = len(df_pp)\n",
        "print(f\"\\n {size-new_size}({100*(size-new_size)/size :.2f} %) samples removed by dropping rows with extra quotes\")\n",
        "size = new_size"
      ],
      "execution_count": 20,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "Int64Index: 566404 entries, 0 to 622965\n",
            "Data columns (total 6 columns):\n",
            "source_sentence    566404 non-null object\n",
            "target_sentence    566404 non-null object\n",
            "source_ch_len      566404 non-null int64\n",
            "source_w_len       566404 non-null int64\n",
            "target_ch_len      566404 non-null int64\n",
            "target_w_len       566404 non-null int64\n",
            "dtypes: int64(4), object(2)\n",
            "memory usage: 288.7 MB\n",
            "\n",
            " 0(0.00 %) samples removed by dropping rows with extra quotes\n",
            "CPU times: user 1.34 s, sys: 3.74 ms, total: 1.35 s\n",
            "Wall time: 1.35 s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RWj_Eh9W5IbD",
        "colab_type": "text"
      },
      "source": [
        "## create dev df "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "V30zP0cCNn5Y",
        "colab_type": "code",
        "outputId": "095543ed-6f90-4e13-9ef7-62c18f301b51",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 139
        }
      },
      "source": [
        "df_dev = df_pp[['source_sentence', 'target_sentence']]\n",
        "# Shuffle the data to remove bias in dev set selection.\n",
        "seed=42\n",
        "df_dev = df_dev.sample(frac=1, random_state=seed).reset_index(drop=True)\n",
        "df_dev.info()"
      ],
      "execution_count": 21,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "<class 'pandas.core.frame.DataFrame'>\n",
            "RangeIndex: 566404 entries, 0 to 566403\n",
            "Data columns (total 2 columns):\n",
            "source_sentence    566404 non-null object\n",
            "target_sentence    566404 non-null object\n",
            "dtypes: object(2)\n",
            "memory usage: 8.6+ MB\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rMdFKCgBq-Hp",
        "colab_type": "text"
      },
      "source": [
        "## Create train and dev sets"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "k5ddIOazEJlF",
        "colab_type": "code",
        "outputId": "677c5087-07fc-4ea3-9c36-25e3217b4cbd",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "source": [
        "%%time\n",
        "# This section does the split between train/dev for the parallel corpora then saves them as separate files\n",
        "# We use 1000 dev test and the given test set.\n",
        "\n",
        "# Do the split between dev/train and create parallel corpora\n",
        "num_dev_patterns = 1000\n",
        "\n",
        "# Optional: lower case the corpora - this will make it easier to generalize, but without proper casing.\n",
        "if lc:  # Julia: making lowercasing optional\n",
        "    df_dev[\"source_sentence\"] = df_dev[\"source_sentence\"].str.lower()\n",
        "    df_dev[\"target_sentence\"] = df_dev[\"target_sentence\"].str.lower()\n",
        "\n",
        "# Julia: test sets are already generated\n",
        "dev = df_dev.tail(num_dev_patterns) # Herman: Error in original\n",
        "stripped = df_dev.drop(df_dev.tail(num_dev_patterns).index)\n",
        "\n",
        "with open(f\"{gdrive_path}/train.\"+source_language, \"w\") as src_file, open(f\"{gdrive_path}/train.\"+target_language, \"w\") as trg_file:\n",
        "  for index, row in stripped.iterrows():\n",
        "    src_file.write(row[\"source_sentence\"]+\"\\n\")\n",
        "    trg_file.write(row[\"target_sentence\"]+\"\\n\")\n",
        "    \n",
        "with open(f\"{gdrive_path}/dev.\"+source_language, \"w\") as src_file, open(f\"{gdrive_path}/dev.\"+target_language, \"w\") as trg_file:\n",
        "  for index, row in dev.iterrows():\n",
        "    src_file.write(row[\"source_sentence\"]+\"\\n\")\n",
        "    trg_file.write(row[\"target_sentence\"]+\"\\n\")"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "CPU times: user 1min 26s, sys: 284 ms, total: 1min 26s\n",
            "Wall time: 1min 27s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3YuVeEAY-Pzk",
        "colab_type": "code",
        "outputId": "53c9f643-4863-4cb7-fea3-b6f24a737e65",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 593
        }
      },
      "source": [
        "# Doublecheck the format below. There should be no extra quotation marks or weird characters.\n",
        "! head \"$gdrive_path/train.$src\"\n",
        "! echo \"=================================\"\n",
        "! head \"$gdrive_path/dev.$src\"\n",
        "! echo \"=================================\"\n",
        "! head \"$gdrive_path/test.$src\" "
      ],
      "execution_count": 22,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "name some of god’s gifts that we can enjoy while awaiting future blessings \n",
            "mark states that soldiers “ would hit him on the head with a reed and spit upon him and , bending their knees [ in mockery ] , they would do obeisance to him  ”\n",
            "instead , our faith will be strengthened if we rely on god , show love for him , and keep his commandments \n",
            "another person decides that all days are the same \n",
            "there were mice and cockroaches to keep us company at night \n",
            "my feelings of failure were such that it was often too depressing for me to read the life - story articles , which often recount extraordinary accomplishments of jehovah’s people \n",
            "nevertheless , jesus said those surprising words for good reason \n",
            "especially where children are involved , many parents prefer to use the services of a professional who is not adversarial \n",
            "why has the number of children adopted in britain dropped drastically during the last  years ?\n",
            "how important it is to recognize that satan and his demons want us to feel that what we do is not good enough for god !\n",
            "=================================\n",
            "a $  - ​ million contract is signed by a leading hockey player for six years \n",
            "meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher \n",
            " :  ​ — what vow did paul make ?\n",
            "christian wives too can make their feelings known \n",
            "jehovah had already foretold that pharaoh’s heart would be obstinate \n",
            "he squints into the setting sun and then smiles broadly as he recognizes us , the light glinting off the fashionable gold facings on his front teeth \n",
            "unlike those faithless israelites , jesus christ lived up to his dedication to the finish \n",
            "the watchtower , december  ,  , pages  -  \n",
            "the churches add to the confusion by promoting the use of bible translations that omit god’s personal name , jehovah , from the text \n",
            "these divinely inspired words made sense to the lady , who said that everyone was in mourning \n",
            "=================================\n",
            "Jesus said : “ You must love your neighbor as yourself . ”\n",
            "For day and night your hand was heavy upon me . ”\n",
            "Some of the names in this article have been changed .\n",
            "Some names in this article have been changed .\n",
            "This is the greatest and first commandment . ”\n",
            "Published by Jehovah’s Witnesses but now out of print .\n",
            "( Look under BIBLE TEACHINGS > BIBLE QUESTIONS ANSWERED )\n",
            "Jehovah is the name of God as revealed in the Bible .\n",
            "\"Let your will take place , as in heaven , also on earth . ”\"\n",
            "The Bible says that “ foolishness is bound up in the heart of a child . ”\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Ypai27iMCoJS",
        "colab_type": "code",
        "outputId": "15421dd0-5dea-4d66-fe82-44bb8ce72e14",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 593
        }
      },
      "source": [
        "! head \"$gdrive_path/train.$trg\"\n",
        "! echo \"=================================\"\n",
        "! head \"$gdrive_path/dev.$trg\"\n",
        "! echo \"=================================\"\n",
        "! head \"$gdrive_path/test.$trg\""
      ],
      "execution_count": 23,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "hlalosa dimpho tše dingwe tša modimo tšeo re ka di thabelago ge re dutše re letetše ditšhegofatšo tša nakong e tlago \n",
            "mareka o bolela gore bahlabani “ ba be ba mo itia hlogo ka lehlaka , ba mo tshwela ka mare gomme ba [ mo kwera ka go ] thinya matolo pele ga gagwe ba mo khunamela  ”\n",
            "go e na le moo , tumelo ya rena e tla matlafala ge e ba re ithekga ka modimo , re bontšha gore re a mo rata e bile re boloka melao ya gagwe \n",
            "motho yo mongwe o phetha ka gore matšatši ka moka a a swana \n",
            "go be go e - na le magotlo le maphene a go re tloša bodutu bošego \n",
            "go ikwa ga - ka ke paletšwe gantši go be go ntira gore ke nyame kudu ge ke bala diphihlelo , tšeo gantši di bego di hlalosa dilo tše di makatšago tšeo di fihleletšwego ke batho ba jehofa \n",
            "lega go le bjalo , go na le lebaka le le kwagalago leo le dirilego gore jesu a bolele mantšu ao a makatšago \n",
            "batswadi ba bantši ba kgetha go diriša ditirelo tša setsebi seo se sa tšeego lehlakore , kudu - kudu moo bana ba akaretšwago \n",
            "ke ka baka la’ng palo ya bana bao ba thwalwago kua brithania e ile ya fokotšega ka lebelo nywageng e  e fetilego ?\n",
            "ruri e tloga e le gabohlokwa go lemoga gore sathane le batemona ba gagwe ba nyaka gore re nagane gore ga go na selo seo re ka se dirago seo se ka kgahlago modimo !\n",
            "=================================\n",
            "sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše  bakeng sa go bapala ka nywaga e tshelelago \n",
            "go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago \n",
            " :  — ke keno efe yeo e dirilwego ke paulo ?\n",
            "basadi ba bakriste le bona ba ka bolela maikwelo a bona \n",
            "jehofa o be a šetše a boletše e sa le pele gore pelo ya farao e be e tla thatafala \n",
            "o a bodulala ge a lebane le letšatši leo le dikelago ke moka o myemyela ge a bona gore ke rena , seetša se dira gore gauta e botse yeo e lego menong a gagwe a ka pele e phadime \n",
            "ka go se swane le ba - isiraele bao ba bego ba hloka tumelo , jesu kriste o ile a phelela boineelo bja gagwe go fihla mafelelong \n",
            "morokami wa january  ,  , matlakala  -  \n",
            "dikereke di hlakahlakanya batho le go feta ka go kgothaletša go diriša diphetolelo tša beibele tšeo di ntšhitšego leina la modimo e lego jehofa ka mangwalong \n",
            "mantšu a a buduletšwego ke modimo a ile a kwagala a e - na le tlhaologanyo go mosadi yoo a ilego a bolela gore yo mongwe le yo mongwe o be a nyamile \n",
            "=================================\n",
            "Jesu o itše : “ Wa xeno O mo ratê ka mokxwa wo O ithataxo ka wôna . ”\n",
            "Ka xo imêlwa ke ’ atla sa xaxo mosexare le bošexo . ”\n",
            "A mangwe a maina sehlogong se a fetotšwe .\n",
            "Maina a mangwe a dirišitšwego sehlogong se a fetotšwe .\n",
            "\"Ké yôna taêlô ya pele , yôna e kxolo . ”\"\n",
            "E gatišitšwe ke Dihlatse tša Jehofa eupša ga bjale ga e sa gatišwa .\n",
            "( Lebelela ka tlase ga DITHUTO TŠA BEIBELE > DIPOTŠIŠO TŠA BEIBELE DI A ARABJA )\n",
            "Jehofa ke leina la Modimo bjalo ka ge le utolotšwe ka Beibeleng .\n",
            "Thato ya gago a e direge le mo lefaseng bjalo ka ge e direga legodimong . ”\n",
            "\"Beibele e re , “ bošilo bo kgokeletšwe pelong ya mošemane [ goba ngwana ] . ”\"\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bWV-5a34rdsK",
        "colab_type": "text"
      },
      "source": [
        "## Preprocessing the Data into Subword BPE Tokens\n",
        "\n",
        "- One of the most powerful improvements for agglutinative languages (a feature of most Bantu languages) is using BPE tokenization [ (Sennrich, 2015) ](https://arxiv.org/abs/1508.07909).\n",
        "\n",
        "- It was also shown that by optimizing the umber of BPE codes we significantly improve results for low-resourced languages [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021) [(Martinus, 2019)](https://arxiv.org/abs/1906.05685)\n",
        "\n",
        "- Below we have the scripts for doing BPE tokenization of our data. We use 4000 tokens as recommended by [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021). You do not need to change anything. Simply running the below will be suitable. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Bi5fyp1LsLv7",
        "colab_type": "code",
        "outputId": "e730151b-4552-40dc-ef1b-7f0df5fd6c87",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "source": [
        "%%time\n",
        "! subword-nmt learn-joint-bpe-and-vocab --input  \"$gdrive_path\"train.$src  \"$gdrive_path\"train.$trg -s $vocab_size -o  \"$gdrive_path\"bpe.codes.$vocab_size --write-vocabulary  \"$gdrive_path\"vocab.$src  \"$gdrive_path\"vocab.$trg\n",
        "\n",
        "# Apply BPE splits to the train, development and test data.\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"train.$src > \"$gdrive_path\"train.bpe.$src\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"train.$trg > \"$gdrive_path\"train.bpe.$trg\n",
        "\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"dev.$src > \"$gdrive_path\"dev.bpe.$src\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"dev.$trg > \"$gdrive_path\"dev.bpe.$trg\n",
        "\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$src < \"$gdrive_path\"test.$src > \"$gdrive_path\"test.bpe.$src\n",
        "! subword-nmt apply-bpe -c \"$gdrive_path\"bpe.codes.$vocab_size --vocabulary \"$gdrive_path\"vocab.$trg < \"$gdrive_path\"test.$trg > \"$gdrive_path\"test.bpe.$trg\n"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "CPU times: user 1.27 s, sys: 231 ms, total: 1.5 s\n",
            "Wall time: 3min 27s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jCmdlJLPMiv7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Create that vocab using build_vocab\n",
        "! sudo chmod 777 joeynmt/scripts/build_vocab.py\n",
        "! joeynmt/scripts/build_vocab.py \"$gdrive_path\"train.bpe.\"$src\" \"$gdrive_path\"train.bpe.\"$trg\" --output_path \"$gdrive_path\"vocab.txt"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lm1CNAQvGZGy",
        "colab_type": "code",
        "outputId": "a9ec9d03-1c9c-4d6e-ce32-d94cec8acee2",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 350
        }
      },
      "source": [
        "\n",
        "# Some output\n",
        "! echo \"BPE Sotho Sentences\"\n",
        "! tail -n 5 \"$gdrive_path\"test.bpe.$trg\n",
        "! echo \"===========================================================================\"\n",
        "! echo \"Combined BPE Vocab\"\n",
        "! tail -n 10 \"$gdrive_path\"vocab.txt  # Herman\n",
        "\n",
        "# !cp joeynmt/data/$src$tgt$vocab_size/vocab.txt \"$gdrive_path\""
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "BPE Sotho Sentences\n",
            "M@@ a@@ fe@@ lelong ke ile ka tu@@ ma ka go se bote@@ ge .\n",
            "\"@@ K@@ a morago ga gore ke ithu@@ te therešo , ke ile ka gana go tšwela pele ke dira seo , gaešita le ge mošomo woo o be o le@@ fa gabotse .@@ \"\n",
            "\"@@ K@@ e mohlala o mobotse go barwa ba ka ba babedi , e bile ke ne@@ ilwe di@@ tokelo ka phuthegong .@@ \"\n",
            "G@@ ona bjale ke tu@@ mile ka go botega gare ga ba@@ hlahlo@@ bi ba ma@@ kgetho le bao ke dirago kgwebo le bona . ”\n",
            "\"@@ R@@ u@@ the o ile a hudu@@ gela I@@ si@@ rae@@ le , moo a bego a ka rapela M@@ o@@ dimo wa therešo .@@ \"\n",
            "===========================================================================\n",
            "Combined BPE Vocab\n",
            "swantšho\n",
            "̀@@\n",
            \n",
            "▲\n",
            "ể@@\n",
            "kots@@\n",
            "̱@@\n",
            "heber@@\n",
            \n",
            "]@@\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0P_JpDK7v2e8",
        "colab_type": "text"
      },
      "source": [
        "## Creating the JoeyNMT Config\n",
        "\n",
        "JoeyNMT requires a yaml config. We provide a template below. We've also set a number of defaults with it, that you may play with!\n",
        "\n",
        "- We used Transformer architecture \n",
        "- We set our dropout to reasonably high: 0.3 (recommended in  [(Sennrich, 2019)](https://www.aclweb.org/anthology/P19-1021))\n",
        "\n",
        "Things worth playing with:\n",
        "- The batch size (also recommended to change for low-resourced languages)\n",
        "- The number of epochs (we've set it at 30 just so it runs in about an hour, for testing purposes)\n",
        "- The decoder options (beam_size, alpha)\n",
        "- Evaluation metrics (BLEU versus Crhf4)"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "4G_GWs_E0N1v",
        "colab_type": "code",
        "outputId": "b9e610f3-185d-4d85-f168-dc2a8a6ea502",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "name = '%s%s%s%s' % (source_language, target_language, str(vocab_size),tag)\n",
        "name"
      ],
      "execution_count": 24,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'ennso4000baseline'"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 24
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "o-7TTovtKnF7",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Create this dir before we run for the first time so we store check points\n",
        "# !mkdir -p \"$gdrive_path/pretrained/$src$trg$vocab_size$tag/\" # Herman"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nVq7B1IYv2hd",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "b7bb2076-42d5-42ab-e778-d34813104288"
      },
      "source": [
        "# This creates the config file for our JoeyNMT system. It might seem overwhelming so we've provided a couple of useful parameters you'll need to update\n",
        "# (You can of course play with all the parameters if you'd like!)\n",
        "\n",
        "name = '%s%s%s%s' % (source_language, target_language, str(vocab_size),tag)\n",
        "gdrive_path = os.environ[\"gdrive_path\"]\n",
        "\n",
        "# Create the config\n",
        "config = \"\"\"\n",
        "name: \"{name}\"\n",
        "\n",
        "data:\n",
        "    src: \"{source_language}\"\n",
        "    trg: \"{target_language}\"\n",
        "    train: \"{gdrive_path}train.bpe\"\n",
        "    dev:   \"{gdrive_path}dev.bpe\"\n",
        "    test:  \"{gdrive_path}test.bpe\"\n",
        "    level: \"bpe\"\n",
        "    lowercase: False\n",
        "    max_sent_length: 100\n",
        "    src_vocab: \"{gdrive_path}vocab.txt\"\n",
        "    trg_vocab: \"{gdrive_path}vocab.txt\"\n",
        "\n",
        "testing:\n",
        "    beam_size: 5\n",
        "    alpha: 1.0\n",
        "\n",
        "training:\n",
        "    load_model: \"{gdrive_path}pretrained/{name}/best.ckpt\" # if uncommented, load a pre-trained model from this checkpoint\n",
        "    random_seed: 42\n",
        "    optimizer: \"adam\"\n",
        "    normalization: \"tokens\"\n",
        "    adam_betas: [0.9, 0.999] \n",
        "    scheduling: \"plateau\"           # TODO: try switching from plateau to Noam scheduling\n",
        "    patience: 5                     # For plateau: decrease learning rate by decrease_factor if validation score has not improved for this many validation rounds.\n",
        "    learning_rate_factor: 0.5       # factor for Noam scheduler (used with Transformer)\n",
        "    learning_rate_warmup: 1000      # warmup steps for Noam scheduler (used with Transformer)\n",
        "    decrease_factor: 0.7\n",
        "    loss: \"crossentropy\"\n",
        "    learning_rate: 0.0003\n",
        "    learning_rate_min: 0.00000001\n",
        "    weight_decay: 0.0\n",
        "    label_smoothing: 0.1\n",
        "    batch_size: 4096\n",
        "    batch_type: \"token\"\n",
        "    eval_batch_size: 3600\n",
        "    eval_batch_type: \"token\"\n",
        "    batch_multiplier: 1\n",
        "    early_stopping_metric: \"ppl\"\n",
        "    epochs: 10                     # TODO: Decrease for when playing around and checking of working. Around 30 is sufficient to check if its working at all\n",
        "    validation_freq: 1000          # TODO: Set to at least once per epoch.\n",
        "    logging_freq: 100\n",
        "    eval_metric: \"bleu\"\n",
        "    model_dir: \"models/{name}_transformer\"\n",
        "    overwrite: True               # TODO: Set to True if you want to overwrite possibly existing models. \n",
        "    shuffle: True\n",
        "    use_cuda: True\n",
        "    max_output_length: 100\n",
        "    print_valid_sents: [0, 1, 2, 3]\n",
        "    keep_last_ckpts: 3\n",
        "\n",
        "model:\n",
        "    initializer: \"xavier\"\n",
        "    bias_initializer: \"zeros\"\n",
        "    init_gain: 1.0\n",
        "    embed_initializer: \"xavier\"\n",
        "    embed_init_gain: 1.0\n",
        "    tied_embeddings: True\n",
        "    tied_softmax: True\n",
        "    encoder:\n",
        "        type: \"transformer\"\n",
        "        num_layers: 6\n",
        "        num_heads: 4             # TODO: Increase to 8 for larger data.\n",
        "        embeddings:\n",
        "            embedding_dim: 256   # TODO: Increase to 512 for larger data.\n",
        "            scale: True\n",
        "            dropout: 0.3\n",
        "        # typically ff_size = 4 x hidden_size\n",
        "        hidden_size: 256         # TODO: Increase to 512 for larger data.\n",
        "        ff_size: 1024            # TODO: Increase to 2048 for larger data.\n",
        "        dropout: 0.4\n",
        "    decoder:\n",
        "        type: \"transformer\"\n",
        "        num_layers: 6\n",
        "        num_heads: 8              # TODO: Increase to 8 for larger data.\n",
        "        embeddings:\n",
        "            embedding_dim: 256    # TODO: Increase to 512 for larger data.\n",
        "            scale: True\n",
        "            dropout: 0.3\n",
        "        # typically ff_size = 4 x hidden_size\n",
        "        hidden_size: 256         # TODO: Increase to 512 for larger data.\n",
        "        ff_size: 1024            # TODO: Increase to 2048 for larger data.\n",
        "        dropout: 0.4\n",
        "\"\"\".format(name=name,\n",
        "           gdrive_path=os.environ[\"gdrive_path\"],\n",
        "           source_language=source_language,\n",
        "           target_language=target_language\n",
        "          )\n",
        "\n",
        "with open(\"joeynmt/configs/transformer_{name}.yaml\".format(name=name),'w') as f:\n",
        "    f.write(config)"
      ],
      "execution_count": 25,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "3308"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 25
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "nr9b-FiGv2j9",
        "colab_type": "text"
      },
      "source": [
        "# Train the Model\n",
        "\n",
        "This single line of joeynmt runs the training using the config we made above"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "NfW_lJhwe6gD",
        "colab_type": "code",
        "outputId": "4da52cae-a1c5-47a0-b1b5-349815796db4",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 173
        }
      },
      "source": [
        "! cd joeynmt/configs; ls\n",
        "! cp joeynmt/configs/transformer_$src$trg$vocab_size$tag.yaml \"$gdrive_path/\""
      ],
      "execution_count": 26,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "iwslt14_deen_bpe.yaml\t\t    transformer_reverse.yaml\n",
            "iwslt_deen_bahdanau.yaml\t    transformer_small.yaml\n",
            "iwslt_envi_luong.yaml\t\t    transformer_wmt17_ende.yaml\n",
            "iwslt_envi_xnmt.yaml\t\t    transformer_wmt17_lven.yaml\n",
            "reverse.yaml\t\t\t    wmt_ende_best.yaml\n",
            "small.yaml\t\t\t    wmt_ende_default.yaml\n",
            "transformer_copy.yaml\t\t    wmt_lven_best.yaml\n",
            "transformer_ennso4000baseline.yaml  wmt_lven_default.yaml\n",
            "transformer_iwslt14_deen_bpe.yaml\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "WiwUQaqPv2mz",
        "colab_type": "code",
        "outputId": "ac8310a5-84ad-4d8d-b6b5-12951a2f51d2",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "%%time\n",
        "# Train the model\n",
        "# You can press Ctrl-C to stop. And then run the next cell to save your checkpoints! \n",
        "! cd joeynmt; python3 -m joeynmt train configs/transformer_$src$trg$vocab_size$tag.yaml"
      ],
      "execution_count": 27,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "2020-02-14 09:06:08,970 Hello! This is Joey-NMT.\n",
            "2020-02-14 09:06:10,079 Total params: 12158720\n",
            "2020-02-14 09:06:10,081 Trainable parameters: ['decoder.layer_norm.bias', 'decoder.layer_norm.weight', 'decoder.layers.0.dec_layer_norm.bias', 'decoder.layers.0.dec_layer_norm.weight', 'decoder.layers.0.feed_forward.layer_norm.bias', 'decoder.layers.0.feed_forward.layer_norm.weight', 'decoder.layers.0.feed_forward.pwff_layer.0.bias', 'decoder.layers.0.feed_forward.pwff_layer.0.weight', 'decoder.layers.0.feed_forward.pwff_layer.3.bias', 'decoder.layers.0.feed_forward.pwff_layer.3.weight', 'decoder.layers.0.src_trg_att.k_layer.bias', 'decoder.layers.0.src_trg_att.k_layer.weight', 'decoder.layers.0.src_trg_att.output_layer.bias', 'decoder.layers.0.src_trg_att.output_layer.weight', 'decoder.layers.0.src_trg_att.q_layer.bias', 'decoder.layers.0.src_trg_att.q_layer.weight', 'decoder.layers.0.src_trg_att.v_layer.bias', 'decoder.layers.0.src_trg_att.v_layer.weight', 'decoder.layers.0.trg_trg_att.k_layer.bias', 'decoder.layers.0.trg_trg_att.k_layer.weight', 'decoder.layers.0.trg_trg_att.output_layer.bias', 'decoder.layers.0.trg_trg_att.output_layer.weight', 'decoder.layers.0.trg_trg_att.q_layer.bias', 'decoder.layers.0.trg_trg_att.q_layer.weight', 'decoder.layers.0.trg_trg_att.v_layer.bias', 'decoder.layers.0.trg_trg_att.v_layer.weight', 'decoder.layers.0.x_layer_norm.bias', 'decoder.layers.0.x_layer_norm.weight', 'decoder.layers.1.dec_layer_norm.bias', 'decoder.layers.1.dec_layer_norm.weight', 'decoder.layers.1.feed_forward.layer_norm.bias', 'decoder.layers.1.feed_forward.layer_norm.weight', 'decoder.layers.1.feed_forward.pwff_layer.0.bias', 'decoder.layers.1.feed_forward.pwff_layer.0.weight', 'decoder.layers.1.feed_forward.pwff_layer.3.bias', 'decoder.layers.1.feed_forward.pwff_layer.3.weight', 'decoder.layers.1.src_trg_att.k_layer.bias', 'decoder.layers.1.src_trg_att.k_layer.weight', 'decoder.layers.1.src_trg_att.output_layer.bias', 'decoder.layers.1.src_trg_att.output_layer.weight', 'decoder.layers.1.src_trg_att.q_layer.bias', 'decoder.layers.1.src_trg_att.q_layer.weight', 'decoder.layers.1.src_trg_att.v_layer.bias', 'decoder.layers.1.src_trg_att.v_layer.weight', 'decoder.layers.1.trg_trg_att.k_layer.bias', 'decoder.layers.1.trg_trg_att.k_layer.weight', 'decoder.layers.1.trg_trg_att.output_layer.bias', 'decoder.layers.1.trg_trg_att.output_layer.weight', 'decoder.layers.1.trg_trg_att.q_layer.bias', 'decoder.layers.1.trg_trg_att.q_layer.weight', 'decoder.layers.1.trg_trg_att.v_layer.bias', 'decoder.layers.1.trg_trg_att.v_layer.weight', 'decoder.layers.1.x_layer_norm.bias', 'decoder.layers.1.x_layer_norm.weight', 'decoder.layers.2.dec_layer_norm.bias', 'decoder.layers.2.dec_layer_norm.weight', 'decoder.layers.2.feed_forward.layer_norm.bias', 'decoder.layers.2.feed_forward.layer_norm.weight', 'decoder.layers.2.feed_forward.pwff_layer.0.bias', 'decoder.layers.2.feed_forward.pwff_layer.0.weight', 'decoder.layers.2.feed_forward.pwff_layer.3.bias', 'decoder.layers.2.feed_forward.pwff_layer.3.weight', 'decoder.layers.2.src_trg_att.k_layer.bias', 'decoder.layers.2.src_trg_att.k_layer.weight', 'decoder.layers.2.src_trg_att.output_layer.bias', 'decoder.layers.2.src_trg_att.output_layer.weight', 'decoder.layers.2.src_trg_att.q_layer.bias', 'decoder.layers.2.src_trg_att.q_layer.weight', 'decoder.layers.2.src_trg_att.v_layer.bias', 'decoder.layers.2.src_trg_att.v_layer.weight', 'decoder.layers.2.trg_trg_att.k_layer.bias', 'decoder.layers.2.trg_trg_att.k_layer.weight', 'decoder.layers.2.trg_trg_att.output_layer.bias', 'decoder.layers.2.trg_trg_att.output_layer.weight', 'decoder.layers.2.trg_trg_att.q_layer.bias', 'decoder.layers.2.trg_trg_att.q_layer.weight', 'decoder.layers.2.trg_trg_att.v_layer.bias', 'decoder.layers.2.trg_trg_att.v_layer.weight', 'decoder.layers.2.x_layer_norm.bias', 'decoder.layers.2.x_layer_norm.weight', 'decoder.layers.3.dec_layer_norm.bias', 'decoder.layers.3.dec_layer_norm.weight', 'decoder.layers.3.feed_forward.layer_norm.bias', 'decoder.layers.3.feed_forward.layer_norm.weight', 'decoder.layers.3.feed_forward.pwff_layer.0.bias', 'decoder.layers.3.feed_forward.pwff_layer.0.weight', 'decoder.layers.3.feed_forward.pwff_layer.3.bias', 'decoder.layers.3.feed_forward.pwff_layer.3.weight', 'decoder.layers.3.src_trg_att.k_layer.bias', 'decoder.layers.3.src_trg_att.k_layer.weight', 'decoder.layers.3.src_trg_att.output_layer.bias', 'decoder.layers.3.src_trg_att.output_layer.weight', 'decoder.layers.3.src_trg_att.q_layer.bias', 'decoder.layers.3.src_trg_att.q_layer.weight', 'decoder.layers.3.src_trg_att.v_layer.bias', 'decoder.layers.3.src_trg_att.v_layer.weight', 'decoder.layers.3.trg_trg_att.k_layer.bias', 'decoder.layers.3.trg_trg_att.k_layer.weight', 'decoder.layers.3.trg_trg_att.output_layer.bias', 'decoder.layers.3.trg_trg_att.output_layer.weight', 'decoder.layers.3.trg_trg_att.q_layer.bias', 'decoder.layers.3.trg_trg_att.q_layer.weight', 'decoder.layers.3.trg_trg_att.v_layer.bias', 'decoder.layers.3.trg_trg_att.v_layer.weight', 'decoder.layers.3.x_layer_norm.bias', 'decoder.layers.3.x_layer_norm.weight', 'decoder.layers.4.dec_layer_norm.bias', 'decoder.layers.4.dec_layer_norm.weight', 'decoder.layers.4.feed_forward.layer_norm.bias', 'decoder.layers.4.feed_forward.layer_norm.weight', 'decoder.layers.4.feed_forward.pwff_layer.0.bias', 'decoder.layers.4.feed_forward.pwff_layer.0.weight', 'decoder.layers.4.feed_forward.pwff_layer.3.bias', 'decoder.layers.4.feed_forward.pwff_layer.3.weight', 'decoder.layers.4.src_trg_att.k_layer.bias', 'decoder.layers.4.src_trg_att.k_layer.weight', 'decoder.layers.4.src_trg_att.output_layer.bias', 'decoder.layers.4.src_trg_att.output_layer.weight', 'decoder.layers.4.src_trg_att.q_layer.bias', 'decoder.layers.4.src_trg_att.q_layer.weight', 'decoder.layers.4.src_trg_att.v_layer.bias', 'decoder.layers.4.src_trg_att.v_layer.weight', 'decoder.layers.4.trg_trg_att.k_layer.bias', 'decoder.layers.4.trg_trg_att.k_layer.weight', 'decoder.layers.4.trg_trg_att.output_layer.bias', 'decoder.layers.4.trg_trg_att.output_layer.weight', 'decoder.layers.4.trg_trg_att.q_layer.bias', 'decoder.layers.4.trg_trg_att.q_layer.weight', 'decoder.layers.4.trg_trg_att.v_layer.bias', 'decoder.layers.4.trg_trg_att.v_layer.weight', 'decoder.layers.4.x_layer_norm.bias', 'decoder.layers.4.x_layer_norm.weight', 'decoder.layers.5.dec_layer_norm.bias', 'decoder.layers.5.dec_layer_norm.weight', 'decoder.layers.5.feed_forward.layer_norm.bias', 'decoder.layers.5.feed_forward.layer_norm.weight', 'decoder.layers.5.feed_forward.pwff_layer.0.bias', 'decoder.layers.5.feed_forward.pwff_layer.0.weight', 'decoder.layers.5.feed_forward.pwff_layer.3.bias', 'decoder.layers.5.feed_forward.pwff_layer.3.weight', 'decoder.layers.5.src_trg_att.k_layer.bias', 'decoder.layers.5.src_trg_att.k_layer.weight', 'decoder.layers.5.src_trg_att.output_layer.bias', 'decoder.layers.5.src_trg_att.output_layer.weight', 'decoder.layers.5.src_trg_att.q_layer.bias', 'decoder.layers.5.src_trg_att.q_layer.weight', 'decoder.layers.5.src_trg_att.v_layer.bias', 'decoder.layers.5.src_trg_att.v_layer.weight', 'decoder.layers.5.trg_trg_att.k_layer.bias', 'decoder.layers.5.trg_trg_att.k_layer.weight', 'decoder.layers.5.trg_trg_att.output_layer.bias', 'decoder.layers.5.trg_trg_att.output_layer.weight', 'decoder.layers.5.trg_trg_att.q_layer.bias', 'decoder.layers.5.trg_trg_att.q_layer.weight', 'decoder.layers.5.trg_trg_att.v_layer.bias', 'decoder.layers.5.trg_trg_att.v_layer.weight', 'decoder.layers.5.x_layer_norm.bias', 'decoder.layers.5.x_layer_norm.weight', 'encoder.layer_norm.bias', 'encoder.layer_norm.weight', 'encoder.layers.0.feed_forward.layer_norm.bias', 'encoder.layers.0.feed_forward.layer_norm.weight', 'encoder.layers.0.feed_forward.pwff_layer.0.bias', 'encoder.layers.0.feed_forward.pwff_layer.0.weight', 'encoder.layers.0.feed_forward.pwff_layer.3.bias', 'encoder.layers.0.feed_forward.pwff_layer.3.weight', 'encoder.layers.0.layer_norm.bias', 'encoder.layers.0.layer_norm.weight', 'encoder.layers.0.src_src_att.k_layer.bias', 'encoder.layers.0.src_src_att.k_layer.weight', 'encoder.layers.0.src_src_att.output_layer.bias', 'encoder.layers.0.src_src_att.output_layer.weight', 'encoder.layers.0.src_src_att.q_layer.bias', 'encoder.layers.0.src_src_att.q_layer.weight', 'encoder.layers.0.src_src_att.v_layer.bias', 'encoder.layers.0.src_src_att.v_layer.weight', 'encoder.layers.1.feed_forward.layer_norm.bias', 'encoder.layers.1.feed_forward.layer_norm.weight', 'encoder.layers.1.feed_forward.pwff_layer.0.bias', 'encoder.layers.1.feed_forward.pwff_layer.0.weight', 'encoder.layers.1.feed_forward.pwff_layer.3.bias', 'encoder.layers.1.feed_forward.pwff_layer.3.weight', 'encoder.layers.1.layer_norm.bias', 'encoder.layers.1.layer_norm.weight', 'encoder.layers.1.src_src_att.k_layer.bias', 'encoder.layers.1.src_src_att.k_layer.weight', 'encoder.layers.1.src_src_att.output_layer.bias', 'encoder.layers.1.src_src_att.output_layer.weight', 'encoder.layers.1.src_src_att.q_layer.bias', 'encoder.layers.1.src_src_att.q_layer.weight', 'encoder.layers.1.src_src_att.v_layer.bias', 'encoder.layers.1.src_src_att.v_layer.weight', 'encoder.layers.2.feed_forward.layer_norm.bias', 'encoder.layers.2.feed_forward.layer_norm.weight', 'encoder.layers.2.feed_forward.pwff_layer.0.bias', 'encoder.layers.2.feed_forward.pwff_layer.0.weight', 'encoder.layers.2.feed_forward.pwff_layer.3.bias', 'encoder.layers.2.feed_forward.pwff_layer.3.weight', 'encoder.layers.2.layer_norm.bias', 'encoder.layers.2.layer_norm.weight', 'encoder.layers.2.src_src_att.k_layer.bias', 'encoder.layers.2.src_src_att.k_layer.weight', 'encoder.layers.2.src_src_att.output_layer.bias', 'encoder.layers.2.src_src_att.output_layer.weight', 'encoder.layers.2.src_src_att.q_layer.bias', 'encoder.layers.2.src_src_att.q_layer.weight', 'encoder.layers.2.src_src_att.v_layer.bias', 'encoder.layers.2.src_src_att.v_layer.weight', 'encoder.layers.3.feed_forward.layer_norm.bias', 'encoder.layers.3.feed_forward.layer_norm.weight', 'encoder.layers.3.feed_forward.pwff_layer.0.bias', 'encoder.layers.3.feed_forward.pwff_layer.0.weight', 'encoder.layers.3.feed_forward.pwff_layer.3.bias', 'encoder.layers.3.feed_forward.pwff_layer.3.weight', 'encoder.layers.3.layer_norm.bias', 'encoder.layers.3.layer_norm.weight', 'encoder.layers.3.src_src_att.k_layer.bias', 'encoder.layers.3.src_src_att.k_layer.weight', 'encoder.layers.3.src_src_att.output_layer.bias', 'encoder.layers.3.src_src_att.output_layer.weight', 'encoder.layers.3.src_src_att.q_layer.bias', 'encoder.layers.3.src_src_att.q_layer.weight', 'encoder.layers.3.src_src_att.v_layer.bias', 'encoder.layers.3.src_src_att.v_layer.weight', 'encoder.layers.4.feed_forward.layer_norm.bias', 'encoder.layers.4.feed_forward.layer_norm.weight', 'encoder.layers.4.feed_forward.pwff_layer.0.bias', 'encoder.layers.4.feed_forward.pwff_layer.0.weight', 'encoder.layers.4.feed_forward.pwff_layer.3.bias', 'encoder.layers.4.feed_forward.pwff_layer.3.weight', 'encoder.layers.4.layer_norm.bias', 'encoder.layers.4.layer_norm.weight', 'encoder.layers.4.src_src_att.k_layer.bias', 'encoder.layers.4.src_src_att.k_layer.weight', 'encoder.layers.4.src_src_att.output_layer.bias', 'encoder.layers.4.src_src_att.output_layer.weight', 'encoder.layers.4.src_src_att.q_layer.bias', 'encoder.layers.4.src_src_att.q_layer.weight', 'encoder.layers.4.src_src_att.v_layer.bias', 'encoder.layers.4.src_src_att.v_layer.weight', 'encoder.layers.5.feed_forward.layer_norm.bias', 'encoder.layers.5.feed_forward.layer_norm.weight', 'encoder.layers.5.feed_forward.pwff_layer.0.bias', 'encoder.layers.5.feed_forward.pwff_layer.0.weight', 'encoder.layers.5.feed_forward.pwff_layer.3.bias', 'encoder.layers.5.feed_forward.pwff_layer.3.weight', 'encoder.layers.5.layer_norm.bias', 'encoder.layers.5.layer_norm.weight', 'encoder.layers.5.src_src_att.k_layer.bias', 'encoder.layers.5.src_src_att.k_layer.weight', 'encoder.layers.5.src_src_att.output_layer.bias', 'encoder.layers.5.src_src_att.output_layer.weight', 'encoder.layers.5.src_src_att.q_layer.bias', 'encoder.layers.5.src_src_att.q_layer.weight', 'encoder.layers.5.src_src_att.v_layer.bias', 'encoder.layers.5.src_src_att.v_layer.weight', 'src_embed.lut.weight']\n",
            "2020-02-14 09:06:19,008 Loading model from /content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/best.ckpt\n",
            "2020-02-14 09:06:31,181 cfg.name                           : ennso4000baseline\n",
            "2020-02-14 09:06:31,181 cfg.data.src                       : en\n",
            "2020-02-14 09:06:31,181 cfg.data.trg                       : nso\n",
            "2020-02-14 09:06:31,181 cfg.data.train                     : /content/drive/My Drive/masakhane/en-nso-baseline/train.bpe\n",
            "2020-02-14 09:06:31,181 cfg.data.dev                       : /content/drive/My Drive/masakhane/en-nso-baseline/dev.bpe\n",
            "2020-02-14 09:06:31,181 cfg.data.test                      : /content/drive/My Drive/masakhane/en-nso-baseline/test.bpe\n",
            "2020-02-14 09:06:31,181 cfg.data.level                     : bpe\n",
            "2020-02-14 09:06:31,181 cfg.data.lowercase                 : False\n",
            "2020-02-14 09:06:31,181 cfg.data.max_sent_length           : 100\n",
            "2020-02-14 09:06:31,182 cfg.data.src_vocab                 : /content/drive/My Drive/masakhane/en-nso-baseline/vocab.txt\n",
            "2020-02-14 09:06:31,182 cfg.data.trg_vocab                 : /content/drive/My Drive/masakhane/en-nso-baseline/vocab.txt\n",
            "2020-02-14 09:06:31,182 cfg.testing.beam_size              : 5\n",
            "2020-02-14 09:06:31,182 cfg.testing.alpha                  : 1.0\n",
            "2020-02-14 09:06:31,182 cfg.training.load_model            : /content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/best.ckpt\n",
            "2020-02-14 09:06:31,182 cfg.training.random_seed           : 42\n",
            "2020-02-14 09:06:31,182 cfg.training.optimizer             : adam\n",
            "2020-02-14 09:06:31,182 cfg.training.normalization         : tokens\n",
            "2020-02-14 09:06:31,182 cfg.training.adam_betas            : [0.9, 0.999]\n",
            "2020-02-14 09:06:31,182 cfg.training.scheduling            : plateau\n",
            "2020-02-14 09:06:31,182 cfg.training.patience              : 5\n",
            "2020-02-14 09:06:31,182 cfg.training.learning_rate_factor  : 0.5\n",
            "2020-02-14 09:06:31,182 cfg.training.learning_rate_warmup  : 1000\n",
            "2020-02-14 09:06:31,182 cfg.training.decrease_factor       : 0.7\n",
            "2020-02-14 09:06:31,182 cfg.training.loss                  : crossentropy\n",
            "2020-02-14 09:06:31,182 cfg.training.learning_rate         : 0.0003\n",
            "2020-02-14 09:06:31,182 cfg.training.learning_rate_min     : 1e-08\n",
            "2020-02-14 09:06:31,182 cfg.training.weight_decay          : 0.0\n",
            "2020-02-14 09:06:31,182 cfg.training.label_smoothing       : 0.1\n",
            "2020-02-14 09:06:31,182 cfg.training.batch_size            : 4096\n",
            "2020-02-14 09:06:31,182 cfg.training.batch_type            : token\n",
            "2020-02-14 09:06:31,182 cfg.training.eval_batch_size       : 3600\n",
            "2020-02-14 09:06:31,182 cfg.training.eval_batch_type       : token\n",
            "2020-02-14 09:06:31,182 cfg.training.batch_multiplier      : 1\n",
            "2020-02-14 09:06:31,182 cfg.training.early_stopping_metric : ppl\n",
            "2020-02-14 09:06:31,182 cfg.training.epochs                : 10\n",
            "2020-02-14 09:06:31,182 cfg.training.validation_freq       : 1000\n",
            "2020-02-14 09:06:31,182 cfg.training.logging_freq          : 100\n",
            "2020-02-14 09:06:31,182 cfg.training.eval_metric           : bleu\n",
            "2020-02-14 09:06:31,183 cfg.training.model_dir             : models/ennso4000baseline_transformer\n",
            "2020-02-14 09:06:31,183 cfg.training.overwrite             : True\n",
            "2020-02-14 09:06:31,183 cfg.training.shuffle               : True\n",
            "2020-02-14 09:06:31,183 cfg.training.use_cuda              : True\n",
            "2020-02-14 09:06:31,183 cfg.training.max_output_length     : 100\n",
            "2020-02-14 09:06:31,183 cfg.training.print_valid_sents     : [0, 1, 2, 3]\n",
            "2020-02-14 09:06:31,183 cfg.training.keep_last_ckpts       : 3\n",
            "2020-02-14 09:06:31,183 cfg.model.initializer              : xavier\n",
            "2020-02-14 09:06:31,183 cfg.model.bias_initializer         : zeros\n",
            "2020-02-14 09:06:31,183 cfg.model.init_gain                : 1.0\n",
            "2020-02-14 09:06:31,183 cfg.model.embed_initializer        : xavier\n",
            "2020-02-14 09:06:31,183 cfg.model.embed_init_gain          : 1.0\n",
            "2020-02-14 09:06:31,183 cfg.model.tied_embeddings          : True\n",
            "2020-02-14 09:06:31,183 cfg.model.tied_softmax             : True\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.type             : transformer\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.num_layers       : 6\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.num_heads        : 4\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.embedding_dim : 256\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.scale : True\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.embeddings.dropout : 0.3\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.hidden_size      : 256\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.ff_size          : 1024\n",
            "2020-02-14 09:06:31,183 cfg.model.encoder.dropout          : 0.4\n",
            "2020-02-14 09:06:31,183 cfg.model.decoder.type             : transformer\n",
            "2020-02-14 09:06:31,183 cfg.model.decoder.num_layers       : 6\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.num_heads        : 8\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.embedding_dim : 256\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.scale : True\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.embeddings.dropout : 0.3\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.hidden_size      : 256\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.ff_size          : 1024\n",
            "2020-02-14 09:06:31,184 cfg.model.decoder.dropout          : 0.4\n",
            "2020-02-14 09:06:31,184 Data set sizes: \n",
            "\ttrain 563849,\n",
            "\tvalid 1000,\n",
            "\ttest 2705\n",
            "2020-02-14 09:06:31,184 First training example:\n",
            "\t[SRC] name some of god’s gi@@ f@@ ts that we can enjoy while awa@@ iting future blessings\n",
            "\t[TRG] hlalosa di@@ mpho tše dingwe tša modimo tšeo re ka di thabe@@ lago ge re dutše re lete@@ tše ditšhegofatšo tša nakong e tlago\n",
            "2020-02-14 09:06:31,184 First 10 words (src): (0) <unk> (1) <pad> (2) <s> (3) </s> (4) , (5) a (6) go (7) le (8) ka (9) ba\n",
            "2020-02-14 09:06:31,184 First 10 words (trg): (0) <unk> (1) <pad> (2) <s> (3) </s> (4) , (5) a (6) go (7) le (8) ka (9) ba\n",
            "2020-02-14 09:06:31,184 Number of Src words (types): 4291\n",
            "2020-02-14 09:06:31,184 Number of Trg words (types): 4291\n",
            "2020-02-14 09:06:31,184 Model(\n",
            "\tencoder=TransformerEncoder(num_layers=6, num_heads=4),\n",
            "\tdecoder=TransformerDecoder(num_layers=6, num_heads=8),\n",
            "\tsrc_embed=Embeddings(embedding_dim=256, vocab_size=4291),\n",
            "\ttrg_embed=Embeddings(embedding_dim=256, vocab_size=4291))\n",
            "2020-02-14 09:06:31,188 EPOCH 1\n",
            "2020-02-14 09:06:43,691 Epoch   1 Step:   177100 Batch Loss:     1.554556 Tokens per Sec:    19776, Lr: 0.000300\n",
            "2020-02-14 09:06:55,166 Epoch   1 Step:   177200 Batch Loss:     1.402975 Tokens per Sec:    21350, Lr: 0.000300\n",
            "2020-02-14 09:07:06,709 Epoch   1 Step:   177300 Batch Loss:     1.653110 Tokens per Sec:    21384, Lr: 0.000300\n",
            "2020-02-14 09:07:18,071 Epoch   1 Step:   177400 Batch Loss:     1.119401 Tokens per Sec:    22436, Lr: 0.000300\n",
            "2020-02-14 09:07:29,449 Epoch   1 Step:   177500 Batch Loss:     1.342238 Tokens per Sec:    21814, Lr: 0.000300\n",
            "2020-02-14 09:07:40,775 Epoch   1 Step:   177600 Batch Loss:     1.005374 Tokens per Sec:    22137, Lr: 0.000300\n",
            "2020-02-14 09:07:52,247 Epoch   1 Step:   177700 Batch Loss:     1.039695 Tokens per Sec:    21775, Lr: 0.000300\n",
            "2020-02-14 09:08:03,578 Epoch   1 Step:   177800 Batch Loss:     1.083479 Tokens per Sec:    21844, Lr: 0.000300\n",
            "2020-02-14 09:08:15,032 Epoch   1 Step:   177900 Batch Loss:     0.867756 Tokens per Sec:    21840, Lr: 0.000300\n",
            "2020-02-14 09:08:26,289 Epoch   1 Step:   178000 Batch Loss:     0.963311 Tokens per Sec:    21865, Lr: 0.000300\n",
            "2020-02-14 09:08:45,948 Example #0\n",
            "2020-02-14 09:08:45,950 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:08:45,950 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:08:45,950 \tHypothesis: konteraka ya diranta tše dimilione tše , e saenwa ke sebapadi se se išago gae ka nywaga e tshelelago\n",
            "2020-02-14 09:08:45,950 Example #1\n",
            "2020-02-14 09:08:45,950 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:08:45,950 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:08:45,950 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:08:45,950 Example #2\n",
            "2020-02-14 09:08:45,951 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:08:45,951 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:08:45,951 \tHypothesis: : — paulo o ile a dira keno efe ?\n",
            "2020-02-14 09:08:45,951 Example #3\n",
            "2020-02-14 09:08:45,951 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:08:45,951 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:08:45,951 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:08:45,951 Validation result (greedy) at epoch   1, step   178000: bleu:  44.47, loss: 28279.8086, ppl:   2.6200, duration: 19.6613s\n",
            "2020-02-14 09:08:57,396 Epoch   1 Step:   178100 Batch Loss:     1.112401 Tokens per Sec:    21992, Lr: 0.000300\n",
            "2020-02-14 09:09:08,812 Epoch   1 Step:   178200 Batch Loss:     1.278881 Tokens per Sec:    21910, Lr: 0.000300\n",
            "2020-02-14 09:09:20,012 Epoch   1 Step:   178300 Batch Loss:     1.090895 Tokens per Sec:    21676, Lr: 0.000300\n",
            "2020-02-14 09:09:31,492 Epoch   1 Step:   178400 Batch Loss:     1.226156 Tokens per Sec:    21744, Lr: 0.000300\n",
            "2020-02-14 09:09:43,081 Epoch   1 Step:   178500 Batch Loss:     1.531641 Tokens per Sec:    22043, Lr: 0.000300\n",
            "2020-02-14 09:09:54,564 Epoch   1 Step:   178600 Batch Loss:     1.068074 Tokens per Sec:    21602, Lr: 0.000300\n",
            "2020-02-14 09:10:05,926 Epoch   1 Step:   178700 Batch Loss:     1.207614 Tokens per Sec:    21339, Lr: 0.000300\n",
            "2020-02-14 09:10:17,262 Epoch   1 Step:   178800 Batch Loss:     1.301371 Tokens per Sec:    22283, Lr: 0.000300\n",
            "2020-02-14 09:10:28,581 Epoch   1 Step:   178900 Batch Loss:     1.306410 Tokens per Sec:    21812, Lr: 0.000300\n",
            "2020-02-14 09:10:39,891 Epoch   1 Step:   179000 Batch Loss:     1.399729 Tokens per Sec:    22232, Lr: 0.000300\n",
            "2020-02-14 09:10:58,367 Example #0\n",
            "2020-02-14 09:10:58,367 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:10:58,367 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:10:58,367 \tHypothesis: konteraka ya diranta tše dimilione tše , e saenwa ke molaodi wa hockey ka nywaga e tshelelago\n",
            "2020-02-14 09:10:58,367 Example #1\n",
            "2020-02-14 09:10:58,367 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:10:58,367 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:10:58,367 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme a ba mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:10:58,367 Example #2\n",
            "2020-02-14 09:10:58,367 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:10:58,368 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:10:58,368 \tHypothesis: : — paulo o dirile keno efe ?\n",
            "2020-02-14 09:10:58,368 Example #3\n",
            "2020-02-14 09:10:58,368 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:10:58,368 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:10:58,368 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:10:58,368 Validation result (greedy) at epoch   1, step   179000: bleu:  44.50, loss: 28167.1602, ppl:   2.6100, duration: 18.4767s\n",
            "2020-02-14 09:11:09,852 Epoch   1 Step:   179100 Batch Loss:     1.129381 Tokens per Sec:    21899, Lr: 0.000300\n",
            "2020-02-14 09:11:21,217 Epoch   1 Step:   179200 Batch Loss:     1.389105 Tokens per Sec:    22531, Lr: 0.000300\n",
            "2020-02-14 09:11:32,553 Epoch   1 Step:   179300 Batch Loss:     1.237211 Tokens per Sec:    21578, Lr: 0.000300\n",
            "2020-02-14 09:11:44,079 Epoch   1 Step:   179400 Batch Loss:     1.298432 Tokens per Sec:    21921, Lr: 0.000300\n",
            "2020-02-14 09:11:55,498 Epoch   1 Step:   179500 Batch Loss:     1.340777 Tokens per Sec:    21460, Lr: 0.000300\n",
            "2020-02-14 09:12:06,984 Epoch   1 Step:   179600 Batch Loss:     1.040521 Tokens per Sec:    21952, Lr: 0.000300\n",
            "2020-02-14 09:12:18,255 Epoch   1 Step:   179700 Batch Loss:     1.265535 Tokens per Sec:    21871, Lr: 0.000300\n",
            "2020-02-14 09:12:29,780 Epoch   1 Step:   179800 Batch Loss:     1.098928 Tokens per Sec:    22026, Lr: 0.000300\n",
            "2020-02-14 09:12:41,191 Epoch   1 Step:   179900 Batch Loss:     1.009815 Tokens per Sec:    21883, Lr: 0.000300\n",
            "2020-02-14 09:12:52,558 Epoch   1 Step:   180000 Batch Loss:     1.302110 Tokens per Sec:    21565, Lr: 0.000300\n",
            "2020-02-14 09:13:11,606 Example #0\n",
            "2020-02-14 09:13:11,606 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:13:11,606 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:13:11,606 \tHypothesis: konteraka ya diranta tše dimilione tše e saenwa ke molaodi wa hockey ka nywaga e tshela\n",
            "2020-02-14 09:13:11,606 Example #1\n",
            "2020-02-14 09:13:11,607 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:13:11,607 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:13:11,607 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:13:11,607 Example #2\n",
            "2020-02-14 09:13:11,607 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:13:11,607 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:13:11,607 \tHypothesis: : — paulo o ile a dira keno efe ?\n",
            "2020-02-14 09:13:11,607 Example #3\n",
            "2020-02-14 09:13:11,607 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:13:11,607 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:13:11,607 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:13:11,607 Validation result (greedy) at epoch   1, step   180000: bleu:  44.55, loss: 28018.4434, ppl:   2.5968, duration: 19.0487s\n",
            "2020-02-14 09:13:23,021 Epoch   1 Step:   180100 Batch Loss:     0.914520 Tokens per Sec:    22192, Lr: 0.000300\n",
            "2020-02-14 09:13:34,476 Epoch   1 Step:   180200 Batch Loss:     1.122637 Tokens per Sec:    22254, Lr: 0.000300\n",
            "2020-02-14 09:13:45,941 Epoch   1 Step:   180300 Batch Loss:     1.204203 Tokens per Sec:    21537, Lr: 0.000300\n",
            "2020-02-14 09:13:57,253 Epoch   1 Step:   180400 Batch Loss:     1.120760 Tokens per Sec:    21585, Lr: 0.000300\n",
            "2020-02-14 09:14:08,787 Epoch   1 Step:   180500 Batch Loss:     1.044424 Tokens per Sec:    21421, Lr: 0.000300\n",
            "2020-02-14 09:14:20,074 Epoch   1 Step:   180600 Batch Loss:     1.145219 Tokens per Sec:    21999, Lr: 0.000300\n",
            "2020-02-14 09:14:31,628 Epoch   1 Step:   180700 Batch Loss:     1.191535 Tokens per Sec:    21569, Lr: 0.000300\n",
            "2020-02-14 09:14:43,038 Epoch   1 Step:   180800 Batch Loss:     1.038063 Tokens per Sec:    21578, Lr: 0.000300\n",
            "2020-02-14 09:14:54,427 Epoch   1 Step:   180900 Batch Loss:     1.098899 Tokens per Sec:    21418, Lr: 0.000300\n",
            "2020-02-14 09:15:05,954 Epoch   1 Step:   181000 Batch Loss:     1.252185 Tokens per Sec:    22024, Lr: 0.000300\n",
            "2020-02-14 09:15:24,396 Example #0\n",
            "2020-02-14 09:15:24,397 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:15:24,397 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:15:24,397 \tHypothesis: konteraka ya diranta tše dimilione tše e hlamilwe ke morekiši yo a etelelago pele wa hockey ka nywaga e tshelelago\n",
            "2020-02-14 09:15:24,397 Example #1\n",
            "2020-02-14 09:15:24,397 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:15:24,397 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:15:24,397 \tHypothesis: go sa dutše go le bjalo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:15:24,397 Example #2\n",
            "2020-02-14 09:15:24,397 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:15:24,397 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:15:24,397 \tHypothesis: : — paulo o ile a dira keno efe ?\n",
            "2020-02-14 09:15:24,397 Example #3\n",
            "2020-02-14 09:15:24,397 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:15:24,398 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:15:24,398 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:15:24,398 Validation result (greedy) at epoch   1, step   181000: bleu:  44.40, loss: 28150.8887, ppl:   2.6085, duration: 18.4431s\n",
            "2020-02-14 09:15:35,872 Epoch   1 Step:   181100 Batch Loss:     1.101133 Tokens per Sec:    22088, Lr: 0.000300\n",
            "2020-02-14 09:15:47,473 Epoch   1 Step:   181200 Batch Loss:     0.925666 Tokens per Sec:    21603, Lr: 0.000300\n",
            "2020-02-14 09:15:58,986 Epoch   1 Step:   181300 Batch Loss:     1.190559 Tokens per Sec:    22333, Lr: 0.000300\n",
            "2020-02-14 09:16:10,460 Epoch   1 Step:   181400 Batch Loss:     1.071086 Tokens per Sec:    21886, Lr: 0.000300\n",
            "2020-02-14 09:16:21,860 Epoch   1 Step:   181500 Batch Loss:     1.023793 Tokens per Sec:    21589, Lr: 0.000300\n",
            "2020-02-14 09:16:33,330 Epoch   1 Step:   181600 Batch Loss:     1.284564 Tokens per Sec:    21820, Lr: 0.000300\n",
            "2020-02-14 09:16:44,830 Epoch   1 Step:   181700 Batch Loss:     1.678303 Tokens per Sec:    21612, Lr: 0.000300\n",
            "2020-02-14 09:16:56,234 Epoch   1 Step:   181800 Batch Loss:     1.165438 Tokens per Sec:    21669, Lr: 0.000300\n",
            "2020-02-14 09:17:07,638 Epoch   1 Step:   181900 Batch Loss:     1.083315 Tokens per Sec:    21741, Lr: 0.000300\n",
            "2020-02-14 09:17:18,956 Epoch   1 Step:   182000 Batch Loss:     1.040282 Tokens per Sec:    22058, Lr: 0.000300\n",
            "2020-02-14 09:17:37,373 Example #0\n",
            "2020-02-14 09:17:37,374 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:17:37,374 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:17:37,374 \tHypothesis: tumelelano ya diranta tše dimilione tše e hlamilwe ke molaodi yo a etelelago pele wa hockey ka nywaga e tshelelago\n",
            "2020-02-14 09:17:37,374 Example #1\n",
            "2020-02-14 09:17:37,374 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:17:37,374 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:17:37,374 \tHypothesis: ka nako yeo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o be a fetogile mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:17:37,374 Example #2\n",
            "2020-02-14 09:17:37,375 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:17:37,375 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:17:37,375 \tHypothesis: : — paulo o ile a dira keno efe ?\n",
            "2020-02-14 09:17:37,375 Example #3\n",
            "2020-02-14 09:17:37,375 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:17:37,375 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:17:37,375 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:17:37,375 Validation result (greedy) at epoch   1, step   182000: bleu:  44.51, loss: 27877.4551, ppl:   2.5843, duration: 18.4183s\n",
            "2020-02-14 09:17:48,878 Epoch   1 Step:   182100 Batch Loss:     1.658979 Tokens per Sec:    21147, Lr: 0.000300\n",
            "2020-02-14 09:18:00,337 Epoch   1 Step:   182200 Batch Loss:     1.074214 Tokens per Sec:    22047, Lr: 0.000300\n",
            "2020-02-14 09:18:11,786 Epoch   1 Step:   182300 Batch Loss:     1.030178 Tokens per Sec:    21561, Lr: 0.000300\n",
            "2020-02-14 09:18:23,139 Epoch   1 Step:   182400 Batch Loss:     1.033017 Tokens per Sec:    21445, Lr: 0.000300\n",
            "2020-02-14 09:18:34,574 Epoch   1 Step:   182500 Batch Loss:     1.106261 Tokens per Sec:    21178, Lr: 0.000300\n",
            "2020-02-14 09:18:46,055 Epoch   1 Step:   182600 Batch Loss:     1.240107 Tokens per Sec:    21443, Lr: 0.000300\n",
            "2020-02-14 09:18:57,477 Epoch   1 Step:   182700 Batch Loss:     1.132737 Tokens per Sec:    22105, Lr: 0.000300\n",
            "2020-02-14 09:19:09,169 Epoch   1 Step:   182800 Batch Loss:     1.024013 Tokens per Sec:    21172, Lr: 0.000300\n",
            "2020-02-14 09:19:20,582 Epoch   1 Step:   182900 Batch Loss:     1.141237 Tokens per Sec:    21745, Lr: 0.000300\n",
            "2020-02-14 09:19:31,839 Epoch   1 Step:   183000 Batch Loss:     1.113522 Tokens per Sec:    21353, Lr: 0.000300\n",
            "2020-02-14 09:19:50,302 Example #0\n",
            "2020-02-14 09:19:50,302 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:19:50,302 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:19:50,302 \tHypothesis: konteraka ya diranta tše dimilione tše e hlamilwe ke morekiši yo a etelelago pele wa hockey ka nywaga e tshelelago\n",
            "2020-02-14 09:19:50,302 Example #1\n",
            "2020-02-14 09:19:50,302 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:19:50,302 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:19:50,303 \tHypothesis: ka nako e swanago , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme o bile mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:19:50,303 Example #2\n",
            "2020-02-14 09:19:50,303 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:19:50,303 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:19:50,303 \tHypothesis: : — paulo o dirile keno efe ?\n",
            "2020-02-14 09:19:50,303 Example #3\n",
            "2020-02-14 09:19:50,303 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:19:50,303 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:19:50,303 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:19:50,303 Validation result (greedy) at epoch   1, step   183000: bleu:  44.49, loss: 27877.2988, ppl:   2.5843, duration: 18.4640s\n",
            "2020-02-14 09:20:01,618 Epoch   1 Step:   183100 Batch Loss:     1.130584 Tokens per Sec:    21325, Lr: 0.000210\n",
            "2020-02-14 09:20:13,197 Epoch   1 Step:   183200 Batch Loss:     1.291446 Tokens per Sec:    21131, Lr: 0.000210\n",
            "2020-02-14 09:20:24,581 Epoch   1 Step:   183300 Batch Loss:     1.460803 Tokens per Sec:    22206, Lr: 0.000210\n",
            "2020-02-14 09:20:35,873 Epoch   1 Step:   183400 Batch Loss:     1.178174 Tokens per Sec:    21599, Lr: 0.000210\n",
            "2020-02-14 09:20:47,458 Epoch   1 Step:   183500 Batch Loss:     0.976318 Tokens per Sec:    21957, Lr: 0.000210\n",
            "2020-02-14 09:20:49,345 Epoch   1: total training loss 7535.66\n",
            "2020-02-14 09:20:49,345 EPOCH 2\n",
            "2020-02-14 09:20:59,477 Epoch   2 Step:   183600 Batch Loss:     0.988506 Tokens per Sec:    20447, Lr: 0.000210\n",
            "2020-02-14 09:21:10,938 Epoch   2 Step:   183700 Batch Loss:     1.338627 Tokens per Sec:    21641, Lr: 0.000210\n",
            "2020-02-14 09:21:22,338 Epoch   2 Step:   183800 Batch Loss:     0.985906 Tokens per Sec:    22275, Lr: 0.000210\n",
            "2020-02-14 09:21:33,631 Epoch   2 Step:   183900 Batch Loss:     0.931342 Tokens per Sec:    21354, Lr: 0.000210\n",
            "2020-02-14 09:21:45,179 Epoch   2 Step:   184000 Batch Loss:     1.144215 Tokens per Sec:    21685, Lr: 0.000210\n",
            "2020-02-14 09:22:03,891 Example #0\n",
            "2020-02-14 09:22:03,891 \tSource:     a $ - ​ million contract is signed by a leading hockey player for six years\n",
            "2020-02-14 09:22:03,891 \tReference:  sebapadi sa maemo a godimo sa hockey se saenetše tumelelano ya ditolara tše dimilione tše bakeng sa go bapala ka nywaga e tshelelago\n",
            "2020-02-14 09:22:03,891 \tHypothesis: konteraka ya milione e saentšwe ke sebapadi se se etelelago pele sa go hloma magae ka nywaga e tshelelago\n",
            "2020-02-14 09:22:03,891 Example #1\n",
            "2020-02-14 09:22:03,892 \tSource:     meanwhile , he had given two talks in the theocratic ministry school and had become an unbaptized publisher\n",
            "2020-02-14 09:22:03,892 \tReference:  go sa dutše go le bjalo , o be a šetše a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo e bile e le mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:22:03,892 \tHypothesis: ka nako yeo , o be a neile dipolelo tše pedi sekolong sa bodiredi sa pušo ya modimo gomme a ba mogoeledi yo a sa kolobetšwago\n",
            "2020-02-14 09:22:03,892 Example #2\n",
            "2020-02-14 09:22:03,892 \tSource:     : ​ — what vow did paul make ?\n",
            "2020-02-14 09:22:03,892 \tReference:  : — ke keno efe yeo e dirilwego ke paulo ?\n",
            "2020-02-14 09:22:03,892 \tHypothesis: : — paulo o ile a dira keno efe ?\n",
            "2020-02-14 09:22:03,892 Example #3\n",
            "2020-02-14 09:22:03,892 \tSource:     christian wives too can make their feelings known\n",
            "2020-02-14 09:22:03,892 \tReference:  basadi ba bakriste le bona ba ka bolela maikwelo a bona\n",
            "2020-02-14 09:22:03,892 \tHypothesis: basadi ba bakriste le bona ba ka dira gore maikwelo a bona a tsebje\n",
            "2020-02-14 09:22:03,892 Validation result (greedy) at epoch   2, step   184000: bleu:  44.62, loss: 27950.6074, ppl:   2.5908, duration: 18.7134s\n",
            "2020-02-14 09:22:15,249 Epoch   2 Step:   184100 Batch Loss:     1.069055 Tokens per Sec:    21314, Lr: 0.000210\n",
            "2020-02-14 09:22:26,663 Epoch   2 Step:   184200 Batch Loss:     0.996049 Tokens per Sec:    22156, Lr: 0.000210\n",
            "2020-02-14 09:22:38,107 Epoch   2 Step:   184300 Batch Loss:     1.425717 Tokens per Sec:    21802, Lr: 0.000210\n",
            "Traceback (most recent call last):\n",
            "  File \"/usr/lib/python3.6/runpy.py\", line 193, in _run_module_as_main\n",
            "    \"__main__\", mod_spec)\n",
            "  File \"/usr/lib/python3.6/runpy.py\", line 85, in _run_code\n",
            "    exec(code, run_globals)\n",
            "  File \"/content/joeynmt/joeynmt/__main__.py\", line 41, in <module>\n",
            "    main()\n",
            "  File \"/content/joeynmt/joeynmt/__main__.py\", line 29, in main\n",
            "    train(cfg_file=args.config_path)\n",
            "  File \"/content/joeynmt/joeynmt/training.py\", line 650, in train\n",
            "    trainer.train_and_validate(train_data=train_data, valid_data=dev_data)\n",
            "  File \"/content/joeynmt/joeynmt/training.py\", line 326, in train_and_validate\n",
            "    batch, update=update, count=count)\n",
            "  File \"/content/joeynmt/joeynmt/training.py\", line 500, in _train_batch\n",
            "    norm_batch_loss.backward()\n",
            "  File \"/usr/local/lib/python3.6/dist-packages/torch/tensor.py\", line 195, in backward\n",
            "    torch.autograd.backward(self, gradient, retain_graph, create_graph)\n",
            "  File \"/usr/local/lib/python3.6/dist-packages/torch/autograd/__init__.py\", line 99, in backward\n",
            "    allow_unreachable=True)  # allow_unreachable flag\n",
            "KeyboardInterrupt\n",
            "CPU times: user 2.47 s, sys: 336 ms, total: 2.81 s\n",
            "Wall time: 17min 3s\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "WSnJkoDCRtTY",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "UPMK6siVv2pt",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# Copy the created models from the notebook storage to google drive for persistant storage \n",
        "# !cp  -r joeynmt/models/${src}${trg}${vocab_size}${tag}_transformer/* \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/\"\n",
        "!cp  joeynmt/models/${src}${trg}${vocab_size}${tag}_transformer/*.ckpt \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "f38OFR8rJgUb",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# copy across the config file\n",
        "!cp  joeynmt/configs/transformer_${src}${trg}${vocab_size}${tag}.yaml \"$gdrive_path\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Tqc7ELUUyrMk",
        "colab_type": "code",
        "outputId": "f9db0597-2f1e-49c0-90d8-f51df6061a10",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        }
      },
      "source": [
        "!ls joeynmt/models"
      ],
      "execution_count": 35,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "ennso4000baseline_transformer\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "a7Xj4vk2yKvz",
        "colab_type": "code",
        "outputId": "0ba26359-199f-4ed7-c432-0ced593f2e95",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        }
      },
      "source": [
        "# Test our model\n",
        "# ! cd joeynmt; python3 -m joeynmt test \"$gdrive_path\"\"transformer_${src}${trg}${vocab_size}${tag}.yaml\"\n",
        "! cd joeynmt; python3 -m joeynmt test \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config.yaml\""
      ],
      "execution_count": 38,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "2020-02-14 09:31:35,938 Hello! This is Joey-NMT.\n",
            "2020-02-14 09:32:14,148  dev bleu:  44.43 [Beam search decoding with beam size = 5 and alpha = 1.0]\n",
            "2020-02-14 09:33:21,929 test bleu:  15.40 [Beam search decoding with beam size = 5 and alpha = 1.0]\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "HBQ0vkOuLmCo",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# plot losses\n",
        "# ! cd joeynmt; python3 scripts/plot_validations.py \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/\" --plot_values bleu PPL  --output bleu2-ppl.png"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "nep_QVw9iwmo",
        "colab_type": "code",
        "outputId": "6339b68c-a0aa-49f2-e61a-e6773debcc4b",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 54
        }
      },
      "source": [
        "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config5_tok.yaml\""
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "cat: '/content/drive/My Drive/masakhane/en-nso-baseline/pretrained/ennso4000baseline/config5_tok.yaml': No such file or directory\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3Ms5xKfbv2tc",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "KBXt6BKvfOAE",
        "colab_type": "code",
        "outputId": "b8ffcaf7-3750-423a-92d0-5774b18d5887",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 245
        }
      },
      "source": [
        "# Translate mode is mopre interactive but almsot the same as running in test mode\n",
        "! cd joeynmt; python3 -m joeynmt translate \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config_5sent.yaml\""
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\n",
            "Please enter a source sentence (pre-processed): \n",
            " J@@ e@@ sus said : \" Y@@ o@@ u must love your neighbo@@ r as yourself . \n",
            "JoeyNMT: ▶ esus o itše : seou se swanetše go rata moagišani wa gago bjalo ka ge o ithata\n",
            "\n",
            "Please enter a source sentence (pre-processed): \n",
            " J@@ e@@ sus said : \" Y@@ o@@ u must love your neighbo@@ r as yourself . \n",
            "JoeyNMT: ▶ esus o itše : seou se swanetše go rata moagišani wa gago bjalo ka ge o ithata\n",
            "\n",
            "Please enter a source sentence (pre-processed): \n",
            "\n",
            "Bye.\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "puYoLngf4aCZ",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/config_5tok.yaml\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "rB9NAs2MhnVI",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# ! cat test.nso \n",
        "# ! echo \"=================================================\"\n",
        "# ! cat test.en"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Pc2xgodBv2ys",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!# Output our validation accuracy\n",
        "# /content/drive/My Drive/masakhane/en-nso-baseline/train.nso\n",
        "# ! cat \"$gdrive_path\"\"pretrained/$src$trg$vocab_size$tag/validations.txt\""
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "N4qv69Ec0D0v",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": 0,
      "outputs": []
    }
  ]
}