bbaaaa commited on
Commit
0194af1
·
1 Parent(s): 8632929

iwslt14 with fairseq preprocess

Browse files
Files changed (3) hide show
  1. README.md +46 -0
  2. data/de-en.zip +3 -0
  3. iwslt14-de-en.py +183 -0
README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - crowdsourced
4
+ language:
5
+ - de
6
+ - en
7
+ language_creators:
8
+ - expert-generated
9
+ license:
10
+ - cc-by-nc-nd-4.0
11
+ multilinguality:
12
+ - translation
13
+ pretty_name: IWSLT 2014
14
+ source_datasets:
15
+ - original
16
+ task_categories:
17
+ - translation
18
+ task_ids: []
19
+ paperswithcode_id: iwslt-2014
20
+ ---
21
+
22
+ # Dataset Card for IWSLT 2014
23
+
24
+
25
+
26
+ ## Dataset Description
27
+
28
+ - **Homepage:** [https://sites.google.com/site/iwsltevaluation2014](https://sites.google.com/site/iwsltevaluation2014)
29
+
30
+
31
+ dataset_info:
32
+ - config_name: de-en
33
+
34
+ features:
35
+ - name: translation
36
+ languages:
37
+ - de
38
+ - en
39
+
40
+ splits:
41
+ - name: train
42
+ num_examples: 171721
43
+ - name: test
44
+ num_examples: 4698
45
+ - name: validation
46
+ num_examples: 887
data/de-en.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97a032b73a0fb54a1bca10fe3168f3b568b158747f925ba926147302a16a6a03
3
+ size 13728035
iwslt14-de-en.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """IWSLT 2017 dataset """
16
+
17
+
18
+ import os
19
+
20
+ import datasets
21
+
22
+
23
+ _HOMEPAGE = "https://sites.google.com/site/iwsltevaluation2017/TED-tasks"
24
+
25
+ _DESCRIPTION = """\
26
+ The IWSLT 2017 Multilingual Task addresses text translation, including zero-shot translation, with a single MT system across all directions including English, German, Dutch, Italian and Romanian. As unofficial task, conventional bilingual text translation is offered between English and Arabic, French, Japanese, Chinese, German and Korean.
27
+ """
28
+
29
+ _CITATION = """\
30
+ @inproceedings{cettolo-etal-2017-overview,
31
+ title = "Overview of the {IWSLT} 2017 Evaluation Campaign",
32
+ author = {Cettolo, Mauro and
33
+ Federico, Marcello and
34
+ Bentivogli, Luisa and
35
+ Niehues, Jan and
36
+ St{\\"u}ker, Sebastian and
37
+ Sudoh, Katsuhito and
38
+ Yoshino, Koichiro and
39
+ Federmann, Christian},
40
+ booktitle = "Proceedings of the 14th International Conference on Spoken Language Translation",
41
+ month = dec # " 14-15",
42
+ year = "2017",
43
+ address = "Tokyo, Japan",
44
+ publisher = "International Workshop on Spoken Language Translation",
45
+ url = "https://aclanthology.org/2017.iwslt-1.1",
46
+ pages = "2--14",
47
+ }
48
+ """
49
+
50
+ REPO_URL = "https://huggingface.co/datasets/bbaaaa/iwslt14-de-en-preprocess/resolve/main/"
51
+ URL = REPO_URL + "data/de-en.zip"
52
+
53
+
54
+ class IWSLT2017Config(datasets.BuilderConfig):
55
+ """BuilderConfig for NewDataset"""
56
+
57
+ def __init__(self, pair, **kwargs):
58
+ """
59
+
60
+ Args:
61
+ pair: the language pair to consider
62
+ is_multilingual: Is this pair in the multilingual dataset (download source is different)
63
+ **kwargs: keyword arguments forwarded to super.
64
+ """
65
+ self.pair = pair
66
+ super().__init__(**kwargs)
67
+
68
+
69
+ class IWSLT2017(datasets.GeneratorBasedBuilder):
70
+ """The IWSLT 2017 Evaluation Campaign includes a multilingual TED Talks MT task."""
71
+
72
+ VERSION = datasets.Version("1.0.0")
73
+
74
+ # This is an example of a dataset with multiple configurations.
75
+ # If you don't want/need to define several sub-sets in your dataset,
76
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
77
+ BUILDER_CONFIG_CLASS = IWSLT2017Config
78
+ BUILDER_CONFIGS = [
79
+ IWSLT2017Config(
80
+ name="de-en",
81
+ description="A small dataset",
82
+ version=datasets.Version("1.0.0"),
83
+ pair='de-en',
84
+ )
85
+ ]
86
+
87
+ def _info(self):
88
+ return datasets.DatasetInfo(
89
+ description=_DESCRIPTION,
90
+ features=datasets.Features(
91
+ {"translation": datasets.features.Translation(languages=self.config.pair.split("-"))}
92
+ ),
93
+ homepage=_HOMEPAGE,
94
+ citation=_CITATION,
95
+ )
96
+
97
+ def _split_generators(self, dl_manager):
98
+ """Returns SplitGenerators."""
99
+ source, target = self.config.pair.split("-")
100
+ bi_url = URL
101
+ dl_dir = dl_manager.download_and_extract(bi_url)
102
+ data_dir = os.path.join(dl_dir, f"{source}-{target}")
103
+ return [
104
+ datasets.SplitGenerator(
105
+ name=datasets.Split.TRAIN,
106
+ gen_kwargs={
107
+ "source_files": [
108
+ os.path.join(
109
+ data_dir,
110
+ f"train.{source}",
111
+ )
112
+ ],
113
+ "target_files": [
114
+ os.path.join(
115
+ data_dir,
116
+ f"train.{target}",
117
+ )
118
+ ],
119
+ },
120
+ ),
121
+ datasets.SplitGenerator(
122
+ name=datasets.Split.TEST,
123
+ gen_kwargs={
124
+ "source_files": [
125
+ os.path.join(
126
+ data_dir,
127
+ f"test.{source}",
128
+ )
129
+ ],
130
+ "target_files": [
131
+ os.path.join(
132
+ data_dir,
133
+ f"test.{target}",
134
+ )
135
+ ],
136
+ },
137
+ ),
138
+ datasets.SplitGenerator(
139
+ name=datasets.Split.VALIDATION,
140
+ gen_kwargs={
141
+ "source_files": [
142
+ os.path.join(
143
+ data_dir,
144
+ f"valid.{source}",
145
+ )
146
+ ],
147
+ "target_files": [
148
+ os.path.join(
149
+ data_dir,
150
+ f"valid.{target}",
151
+ )
152
+ ],
153
+ },
154
+ ),
155
+ ]
156
+
157
+ def _generate_examples(self, source_files, target_files):
158
+ """Yields examples."""
159
+ id_ = 0
160
+ source, target = self.config.pair.split("-")
161
+ for source_file, target_file in zip(source_files, target_files):
162
+ with open(source_file, "r", encoding="utf-8") as sf:
163
+ with open(target_file, "r", encoding="utf-8") as tf:
164
+ for source_row, target_row in zip(sf, tf):
165
+ source_row = source_row.strip()
166
+ target_row = target_row.strip()
167
+
168
+ if source_row.startswith("<"):
169
+ if source_row.startswith("<seg"):
170
+ # Remove <seg id="1">.....</seg>
171
+ # Very simple code instead of regex or xml parsing
172
+ part1 = source_row.split(">")[1]
173
+ source_row = part1.split("<")[0]
174
+ part1 = target_row.split(">")[1]
175
+ target_row = part1.split("<")[0]
176
+
177
+ source_row = source_row.strip()
178
+ target_row = target_row.strip()
179
+ else:
180
+ continue
181
+
182
+ yield id_, {"translation": {source: source_row, target: target_row}}
183
+ id_ += 1