stas commited on
Commit
d68916b
1 Parent(s): 66fb784

add data files

Browse files
Files changed (5) hide show
  1. README.md +19 -0
  2. convert-to-jsonlines.py +22 -0
  3. test.json +3 -0
  4. train.json +3 -0
  5. val.json +3 -0
README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # WMT16 English-Romanian Translation Data w/ further preprocessing
2
+
3
+ The original instructions are [here](https://github.com/rsennrich/wmt16-scripts/tree/master/sample).
4
+
5
+ It was created by running:
6
+
7
+ ```
8
+ git clone https://github.com/rsennrich/wmt16-scripts
9
+ cd wmt16-scripts
10
+ cd sample
11
+ ./download_files.sh
12
+ ./preprocess.sh
13
+ ```
14
+ https://github.com/rsennrich/wmt16-scripts/tree/master/sample
15
+
16
+ It was originally used by `transformers` [`finetune_trainer.py`](https://github.com/huggingface/transformers/blob/641f418e102218c4bf16fcd3124bfebed6217ef6/examples/seq2seq/finetune_trainer.py)
17
+ and resided at https://cdn-datasets.huggingface.co/translation/wmt_en_ro.tar.gz
18
+
19
+ It was further converted to `jsonlines` with the included in this repository `convert-to-jsonlines.py` script so that it could be loaded by `datasets`.
convert-to-jsonlines.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # sacrebleu format to jsonlines
4
+
5
+ import io
6
+ import json
7
+ import re
8
+
9
+ src_lang, tgt_lang = ["en", "ro"]
10
+
11
+ for split in ["train", "val", "test"]:
12
+ recs = []
13
+ fout = f"{split}.json"
14
+ with io.open(fout, "w", encoding="utf-8") as f:
15
+ for type in ["source", "target"]:
16
+ fin = f"{split}.{type}"
17
+ recs.append([line.strip() for line in open(fin)])
18
+ for src, tgt in zip(*recs):
19
+ out = {"translation": { src_lang: src, tgt_lang: tgt } }
20
+ x = json.dumps(out, indent=0, ensure_ascii=False)
21
+ x = re.sub(r'\n', ' ', x, 0, re.M)
22
+ f.write(x + "\n")
test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:132df683c4c2008c60dc27c772acb1e5cbcf5f6d79f2fb6adb0b08bd896fbd0e
3
+ size 608194
train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9602761a4f8c56a5c7677fbd78e0a66987fdede826aaaffbb45b6faaf11cb651
3
+ size 209195474
val.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ebee4e57c65b2a06484e1de295b6f63a2646d1095a0b05ca0cf1854a3de955b
3
+ size 631127