Datasets:
Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +7 -0
- dataset_infos.json +1 -1
- dummy/cs-en/1.0.0/dummy_data.zip +2 -2
- wmt_utils.py +105 -100
README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1 |
---
|
|
|
2 |
paperswithcode_id: wmt-2014
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
4 |
|
5 |
# Dataset Card for "wmt14"
|
|
|
1 |
---
|
2 |
+
pretty_name: WMT14
|
3 |
paperswithcode_id: wmt-2014
|
4 |
+
multilinguality:
|
5 |
+
- translation
|
6 |
+
task_categories:
|
7 |
+
- conditional-text-generation
|
8 |
+
task_ids:
|
9 |
+
- machine-translation
|
10 |
---
|
11 |
|
12 |
# Dataset Card for "wmt14"
|
dataset_infos.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cs-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["cs", "en"], "id": null, "_type": "Translation"}}, "supervised_keys": {"input": "cs", "output": "en"}, "builder_name": "wmt14", "config_name": "cs-en", "version": {"version_str": "1.0.0", "description": null, "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 759321, "num_examples": 3003, "dataset_name": "wmt14"}, "train": {"name": "train", "num_bytes": 281479898, "num_examples": 953621, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 703973, "num_examples": 3000, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt13/resolve/main/training-parallel-europarl-v7.tgz": {"num_bytes": 657632379, "checksum": "0224c7c710c8a063dfd893b0cc0830202d61f4c75c17eb8e31836103d27d96e7"}, "https://huggingface.co/datasets/wmt/wmt13/resolve/main/training-parallel-commoncrawl.tgz": {"num_bytes": 918311367, "checksum": "c7a74e2ea01ac6c920123108627e35278d4ccb5701e15428ffa34de86fa3a9e5"}, "https://huggingface.co/datasets/wmt/wmt14/resolve/main/training-parallel-nc-v9.tgz": {"num_bytes": 80418416, "checksum": "cb8953f292298e6877ae433c98912b927cb0766b303f4540512ddd286c748485"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.tgz": {"num_bytes": 38654961, "checksum": "7a7deccf82ebb05ba508dba5eb21356492224e8f630ec4f992132b029b4b25e7"}}, "download_size": 1695017123, "dataset_size": 282943192, "size_in_bytes": 1977960315}}
|
|
|
1 |
+
{"cs-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["cs", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": {"input": "cs", "output": "en"}, "task_templates": null, "builder_name": "wmt14", "config_name": "cs-en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 280992794, "num_examples": 953621, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 702473, "num_examples": 3000, "dataset_name": "wmt14"}, "test": {"name": "test", "num_bytes": 757817, "num_examples": 3003, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-europarl-v7.zip": {"num_bytes": 658092427, "checksum": "5b2d8b32c2396da739b4e731871c597fcc6e75729becd74619d0712eecf7770e"}, "https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-commoncrawl.zip": {"num_bytes": 918734483, "checksum": "5ffe980072ea29adfd84568d099bea366d9f72772b988e670794ae851b4e5627"}, "https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/training-parallel-nc-v9.zip": {"num_bytes": 80462375, "checksum": "ce199f93ec56ff480137ba29f0819f9a22e70d88be6d7458f112303d67d623d5"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip": {"num_bytes": 38714274, "checksum": "d796e363740fdc4261aa6f5a3d2f8223e3adaee7d737b7724863325b8956dfd1"}}, "download_size": 1696003559, "post_processing_size": null, "dataset_size": 282453084, "size_in_bytes": 1978456643}, "de-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["de", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": {"input": "de", "output": "en"}, "task_templates": null, "builder_name": "wmt14", "config_name": "de-en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1358410408, "num_examples": 4508785, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 736415, "num_examples": 3000, "dataset_name": "wmt14"}, "test": {"name": "test", "num_bytes": 777334, "num_examples": 3003, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-europarl-v7.zip": {"num_bytes": 658092427, "checksum": "5b2d8b32c2396da739b4e731871c597fcc6e75729becd74619d0712eecf7770e"}, "https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-commoncrawl.zip": {"num_bytes": 918734483, "checksum": "5ffe980072ea29adfd84568d099bea366d9f72772b988e670794ae851b4e5627"}, "https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/training-parallel-nc-v9.zip": {"num_bytes": 80462375, "checksum": "ce199f93ec56ff480137ba29f0819f9a22e70d88be6d7458f112303d67d623d5"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip": {"num_bytes": 38714274, "checksum": "d796e363740fdc4261aa6f5a3d2f8223e3adaee7d737b7724863325b8956dfd1"}}, "download_size": 1696003559, "post_processing_size": null, "dataset_size": 1359924157, "size_in_bytes": 3055927716}, "fr-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["fr", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": {"input": "fr", "output": "en"}, "task_templates": null, "builder_name": "wmt14", "config_name": "fr-en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 14752554924, "num_examples": 40836715, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 744447, "num_examples": 3000, "dataset_name": "wmt14"}, "test": {"name": "test", "num_bytes": 838857, "num_examples": 3003, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-europarl-v7.zip": {"num_bytes": 658092427, "checksum": "5b2d8b32c2396da739b4e731871c597fcc6e75729becd74619d0712eecf7770e"}, "https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-commoncrawl.zip": {"num_bytes": 918734483, "checksum": "5ffe980072ea29adfd84568d099bea366d9f72772b988e670794ae851b4e5627"}, "https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-un.zip": {"num_bytes": 2366237633, "checksum": "74f07002e053c81bc7f73b4fdab58e7987e831338748f264cbda82a8b062d2e2"}, "https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/training-parallel-nc-v9.zip": {"num_bytes": 80462375, "checksum": "ce199f93ec56ff480137ba29f0819f9a22e70d88be6d7458f112303d67d623d5"}, "https://huggingface.co/datasets/wmt/wmt10/resolve/main-zip/training-giga-fren.zip": {"num_bytes": 2595877717, "checksum": "9439f86523e5dff3f923526dbf6c6929da1786c18dbf64436d2b7564b83aaba3"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip": {"num_bytes": 38714274, "checksum": "d796e363740fdc4261aa6f5a3d2f8223e3adaee7d737b7724863325b8956dfd1"}}, "download_size": 6658118909, "post_processing_size": null, "dataset_size": 14754138228, "size_in_bytes": 21412257137}, "hi-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["hi", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": {"input": "hi", "output": "en"}, "task_templates": null, "builder_name": "wmt14", "config_name": "hi-en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1936035, "num_examples": 32863, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 181465, "num_examples": 520, "dataset_name": "wmt14"}, "test": {"name": "test", "num_bytes": 1075016, "num_examples": 2507, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/wiki-titles.zip": {"num_bytes": 8165410, "checksum": "72aa3109be74d0ecadc82c1121118878934ca234f260cfd4e4766a25e16fdbb1"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip": {"num_bytes": 38714274, "checksum": "d796e363740fdc4261aa6f5a3d2f8223e3adaee7d737b7724863325b8956dfd1"}}, "download_size": 46879684, "post_processing_size": null, "dataset_size": 3192516, "size_in_bytes": 50072200}, "ru-en": {"description": "Translate dataset based on the data from statmt.org.\n\nVersions exists for the different years using a combination of multiple data\nsources. The base `wmt_translate` allows you to create your own config to choose\nyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.\n\n```\nconfig = datasets.wmt.WmtConfig(\n version=\"0.0.1\",\n language_pair=(\"fr\", \"de\"),\n subsets={\n datasets.Split.TRAIN: [\"commoncrawl_frde\"],\n datasets.Split.VALIDATION: [\"euelections_dev2019\"],\n },\n)\nbuilder = datasets.builder(\"wmt_translate\", config=config)\n```\n\n", "citation": "\n@InProceedings{bojar-EtAl:2014:W14-33,\n author = {Bojar, Ondrej and Buck, Christian and Federmann, Christian and Haddow, Barry and Koehn, Philipp and Leveling, Johannes and Monz, Christof and Pecina, Pavel and Post, Matt and Saint-Amand, Herve and Soricut, Radu and Specia, Lucia and Tamchyna, Ale\u000b{s}},\n title = {Findings of the 2014 Workshop on Statistical Machine Translation},\n booktitle = {Proceedings of the Ninth Workshop on Statistical Machine Translation},\n month = {June},\n year = {2014},\n address = {Baltimore, Maryland, USA},\n publisher = {Association for Computational Linguistics},\n pages = {12--58},\n url = {http://www.aclweb.org/anthology/W/W14/W14-3302}\n}\n", "homepage": "http://www.statmt.org/wmt14/translation-task.html", "license": "", "features": {"translation": {"languages": ["ru", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": {"input": "ru", "output": "en"}, "task_templates": null, "builder_name": "wmt14", "config_name": "ru-en", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 433210270, "num_examples": 1486965, "dataset_name": "wmt14"}, "validation": {"name": "validation", "num_bytes": 977946, "num_examples": 3000, "dataset_name": "wmt14"}, "test": {"name": "test", "num_bytes": 1087746, "num_examples": 3003, "dataset_name": "wmt14"}}, "download_checksums": {"https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-commoncrawl.zip": {"num_bytes": 918734483, "checksum": "5ffe980072ea29adfd84568d099bea366d9f72772b988e670794ae851b4e5627"}, "https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/training-parallel-nc-v9.zip": {"num_bytes": 80462375, "checksum": "ce199f93ec56ff480137ba29f0819f9a22e70d88be6d7458f112303d67d623d5"}, "https://huggingface.co/datasets/wmt/wmt15/resolve/main-zip/wiki-titles.zip": {"num_bytes": 9485604, "checksum": "b3134566261b39d830eed345df1be1864039339cfeccf24b1bf86398c9e4a87c"}, "https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip": {"num_bytes": 38714274, "checksum": "d796e363740fdc4261aa6f5a3d2f8223e3adaee7d737b7724863325b8956dfd1"}}, "download_size": 1047396736, "post_processing_size": null, "dataset_size": 435275962, "size_in_bytes": 1482672698}}
|
dummy/cs-en/1.0.0/dummy_data.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2378379d166d875de3a4b6229e742982f2a667388a37101d747db77b599459fa
|
3 |
+
size 6748
|
wmt_utils.py
CHANGED
@@ -96,7 +96,7 @@ class SubDataset:
|
|
96 |
def _inject_language(self, src, strings):
|
97 |
"""Injects languages into (potentially) template strings."""
|
98 |
if src not in self.sources:
|
99 |
-
raise ValueError("Invalid source for '{
|
100 |
|
101 |
def _format_string(s):
|
102 |
if "{0}" in s and "{1}" and "{src}" in s:
|
@@ -127,7 +127,7 @@ _TRAIN_SUBSETS = [
|
|
127 |
name="commoncrawl",
|
128 |
target="en", # fr-de pair in commoncrawl_frde
|
129 |
sources={"cs", "de", "es", "fr", "ru"},
|
130 |
-
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main/training-parallel-commoncrawl.
|
131 |
path=("commoncrawl.{src}-en.{src}", "commoncrawl.{src}-en.en"),
|
132 |
),
|
133 |
SubDataset(
|
@@ -184,14 +184,14 @@ _TRAIN_SUBSETS = [
|
|
184 |
name="dcep_v1",
|
185 |
target="en",
|
186 |
sources={"lv"},
|
187 |
-
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main/translation-task/dcep.lv-en.v1.
|
188 |
path=("dcep.en-lv/dcep.lv", "dcep.en-lv/dcep.en"),
|
189 |
),
|
190 |
SubDataset(
|
191 |
name="europarl_v7",
|
192 |
target="en",
|
193 |
sources={"cs", "de", "es", "fr"},
|
194 |
-
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main/training-parallel-europarl-v7.
|
195 |
path=("training/europarl-v7.{src}-en.{src}", "training/europarl-v7.{src}-en.en"),
|
196 |
),
|
197 |
SubDataset(
|
@@ -208,14 +208,14 @@ _TRAIN_SUBSETS = [
|
|
208 |
name="europarl_v8_18",
|
209 |
target="en",
|
210 |
sources={"et", "fi"},
|
211 |
-
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main/translation-task/training-parallel-ep-v8.
|
212 |
path=("training/europarl-v8.{src}-en.{src}", "training/europarl-v8.{src}-en.en"),
|
213 |
),
|
214 |
SubDataset(
|
215 |
name="europarl_v8_16",
|
216 |
target="en",
|
217 |
sources={"fi", "ro"},
|
218 |
-
url="https://huggingface.co/datasets/wmt/wmt16/resolve/main/translation-task/training-parallel-ep-v8.
|
219 |
path=("training-parallel-ep-v8/europarl-v8.{src}-en.{src}", "training-parallel-ep-v8/europarl-v8.{src}-en.en"),
|
220 |
),
|
221 |
SubDataset(
|
@@ -229,7 +229,7 @@ _TRAIN_SUBSETS = [
|
|
229 |
name="gigafren",
|
230 |
target="en",
|
231 |
sources={"fr"},
|
232 |
-
url="https://huggingface.co/datasets/wmt/wmt10/resolve/main/training-giga-fren.
|
233 |
path=("giga-fren.release2.fixed.fr.gz", "giga-fren.release2.fixed.en.gz"),
|
234 |
),
|
235 |
SubDataset(
|
@@ -244,35 +244,35 @@ _TRAIN_SUBSETS = [
|
|
244 |
name="leta_v1",
|
245 |
target="en",
|
246 |
sources={"lv"},
|
247 |
-
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main/translation-task/leta.v1.
|
248 |
path=("LETA-lv-en/leta.lv", "LETA-lv-en/leta.en"),
|
249 |
),
|
250 |
SubDataset(
|
251 |
name="multiun",
|
252 |
target="en",
|
253 |
sources={"es", "fr"},
|
254 |
-
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main/training-parallel-un.
|
255 |
path=("un/undoc.2000.{src}-en.{src}", "un/undoc.2000.{src}-en.en"),
|
256 |
),
|
257 |
SubDataset(
|
258 |
name="newscommentary_v9",
|
259 |
target="en",
|
260 |
sources={"cs", "de", "fr", "ru"},
|
261 |
-
url="https://huggingface.co/datasets/wmt/wmt14/resolve/main/training-parallel-nc-v9.
|
262 |
path=("training/news-commentary-v9.{src}-en.{src}", "training/news-commentary-v9.{src}-en.en"),
|
263 |
),
|
264 |
SubDataset(
|
265 |
name="newscommentary_v10",
|
266 |
target="en",
|
267 |
sources={"cs", "de", "fr", "ru"},
|
268 |
-
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main/training-parallel-nc-v10.
|
269 |
path=("news-commentary-v10.{src}-en.{src}", "news-commentary-v10.{src}-en.en"),
|
270 |
),
|
271 |
SubDataset(
|
272 |
name="newscommentary_v11",
|
273 |
target="en",
|
274 |
sources={"cs", "de", "ru"},
|
275 |
-
url="https://huggingface.co/datasets/wmt/wmt16/resolve/main/translation-task/training-parallel-nc-v11.
|
276 |
path=(
|
277 |
"training-parallel-nc-v11/news-commentary-v11.{src}-en.{src}",
|
278 |
"training-parallel-nc-v11/news-commentary-v11.{src}-en.en",
|
@@ -282,14 +282,14 @@ _TRAIN_SUBSETS = [
|
|
282 |
name="newscommentary_v12",
|
283 |
target="en",
|
284 |
sources={"cs", "de", "ru", "zh"},
|
285 |
-
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main/translation-task/training-parallel-nc-v12.
|
286 |
path=("training/news-commentary-v12.{src}-en.{src}", "training/news-commentary-v12.{src}-en.en"),
|
287 |
),
|
288 |
SubDataset(
|
289 |
name="newscommentary_v13",
|
290 |
target="en",
|
291 |
sources={"cs", "de", "ru", "zh"},
|
292 |
-
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main/translation-task/training-parallel-nc-v13.
|
293 |
path=(
|
294 |
"training-parallel-nc-v13/news-commentary-v13.{src}-en.{src}",
|
295 |
"training-parallel-nc-v13/news-commentary-v13.{src}-en.en",
|
@@ -313,14 +313,14 @@ _TRAIN_SUBSETS = [
|
|
313 |
name="onlinebooks_v1",
|
314 |
target="en",
|
315 |
sources={"lv"},
|
316 |
-
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main/translation-task/books.lv-en.v1.
|
317 |
path=("farewell/farewell.lv", "farewell/farewell.en"),
|
318 |
),
|
319 |
SubDataset(
|
320 |
name="paracrawl_v1",
|
321 |
target="en",
|
322 |
sources={"cs", "de", "et", "fi", "ru"},
|
323 |
-
url="https://s3.amazonaws.com/web-language-models/paracrawl/release1/paracrawl-release1.en-{src}.zipporah0-dedup-clean.tgz",
|
324 |
path=(
|
325 |
"paracrawl-release1.en-{src}.zipporah0-dedup-clean.{src}",
|
326 |
"paracrawl-release1.en-{src}.zipporah0-dedup-clean.en",
|
@@ -330,7 +330,7 @@ _TRAIN_SUBSETS = [
|
|
330 |
name="paracrawl_v1_ru",
|
331 |
target="en",
|
332 |
sources={"ru"},
|
333 |
-
url="https://s3.amazonaws.com/web-language-models/paracrawl/release1/paracrawl-release1.en-ru.zipporah0-dedup-clean.tgz",
|
334 |
path=(
|
335 |
"paracrawl-release1.en-ru.zipporah0-dedup-clean.ru",
|
336 |
"paracrawl-release1.en-ru.zipporah0-dedup-clean.en",
|
@@ -357,7 +357,7 @@ _TRAIN_SUBSETS = [
|
|
357 |
name="rapid_2016",
|
358 |
target="en",
|
359 |
sources={"de", "et", "fi"},
|
360 |
-
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main/translation-task/rapid2016.
|
361 |
path=("rapid2016.{0}-{1}.{src}", "rapid2016.{0}-{1}.en"),
|
362 |
),
|
363 |
SubDataset(
|
@@ -385,21 +385,21 @@ _TRAIN_SUBSETS = [
|
|
385 |
name="uncorpus_v1",
|
386 |
target="en",
|
387 |
sources={"ru", "zh"},
|
388 |
-
url="https://huggingface.co/datasets/wmt/uncorpus/resolve/main/UNv1.0.en-{src}.
|
389 |
path=("en-{src}/UNv1.0.en-{src}.{src}", "en-{src}/UNv1.0.en-{src}.en"),
|
390 |
),
|
391 |
SubDataset(
|
392 |
name="wikiheadlines_fi",
|
393 |
target="en",
|
394 |
sources={"fi"},
|
395 |
-
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main/wiki-titles.
|
396 |
path="wiki/fi-en/titles.fi-en",
|
397 |
),
|
398 |
SubDataset(
|
399 |
name="wikiheadlines_hi",
|
400 |
target="en",
|
401 |
sources={"hi"},
|
402 |
-
url="https://huggingface.co/datasets/wmt/wmt14/resolve/main/wiki-titles.
|
403 |
path="wiki/hi-en/wiki-titles.hi-en",
|
404 |
),
|
405 |
SubDataset(
|
@@ -407,7 +407,7 @@ _TRAIN_SUBSETS = [
|
|
407 |
name="wikiheadlines_ru",
|
408 |
target="en",
|
409 |
sources={"ru"},
|
410 |
-
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main/wiki-titles.
|
411 |
path="wiki/ru-en/wiki.ru-en",
|
412 |
),
|
413 |
SubDataset(
|
@@ -431,7 +431,7 @@ _TRAIN_SUBSETS = [
|
|
431 |
name=ss,
|
432 |
target="en",
|
433 |
sources={"zh"},
|
434 |
-
url="
|
435 |
path=("%s/*_c[hn].txt" % ss, "%s/*_en.txt" % ss),
|
436 |
)
|
437 |
for ss in CWMT_SUBSET_NAMES
|
@@ -442,175 +442,175 @@ _DEV_SUBSETS = [
|
|
442 |
name="euelections_dev2019",
|
443 |
target="de",
|
444 |
sources={"fr"},
|
445 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
446 |
path=("dev/euelections_dev2019.fr-de.src.fr", "dev/euelections_dev2019.fr-de.tgt.de"),
|
447 |
),
|
448 |
SubDataset(
|
449 |
name="newsdev2014",
|
450 |
target="en",
|
451 |
sources={"hi"},
|
452 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
453 |
path=("dev/newsdev2014.hi", "dev/newsdev2014.en"),
|
454 |
),
|
455 |
SubDataset(
|
456 |
name="newsdev2015",
|
457 |
target="en",
|
458 |
sources={"fi"},
|
459 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
460 |
path=("dev/newsdev2015-fien-src.{src}.sgm", "dev/newsdev2015-fien-ref.en.sgm"),
|
461 |
),
|
462 |
SubDataset(
|
463 |
name="newsdiscussdev2015",
|
464 |
target="en",
|
465 |
sources={"ro", "tr"},
|
466 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
467 |
path=("dev/newsdiscussdev2015-{src}en-src.{src}.sgm", "dev/newsdiscussdev2015-{src}en-ref.en.sgm"),
|
468 |
),
|
469 |
SubDataset(
|
470 |
name="newsdev2016",
|
471 |
target="en",
|
472 |
sources={"ro", "tr"},
|
473 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
474 |
path=("dev/newsdev2016-{src}en-src.{src}.sgm", "dev/newsdev2016-{src}en-ref.en.sgm"),
|
475 |
),
|
476 |
SubDataset(
|
477 |
name="newsdev2017",
|
478 |
target="en",
|
479 |
sources={"lv", "zh"},
|
480 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
481 |
path=("dev/newsdev2017-{src}en-src.{src}.sgm", "dev/newsdev2017-{src}en-ref.en.sgm"),
|
482 |
),
|
483 |
SubDataset(
|
484 |
name="newsdev2018",
|
485 |
target="en",
|
486 |
sources={"et"},
|
487 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
488 |
path=("dev/newsdev2018-{src}en-src.{src}.sgm", "dev/newsdev2018-{src}en-ref.en.sgm"),
|
489 |
),
|
490 |
SubDataset(
|
491 |
name="newsdev2019",
|
492 |
target="en",
|
493 |
sources={"gu", "kk", "lt"},
|
494 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
495 |
path=("dev/newsdev2019-{src}en-src.{src}.sgm", "dev/newsdev2019-{src}en-ref.en.sgm"),
|
496 |
),
|
497 |
SubDataset(
|
498 |
name="newsdiscussdev2015",
|
499 |
target="en",
|
500 |
sources={"fr"},
|
501 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
502 |
path=("dev/newsdiscussdev2015-{src}en-src.{src}.sgm", "dev/newsdiscussdev2015-{src}en-ref.en.sgm"),
|
503 |
),
|
504 |
SubDataset(
|
505 |
name="newsdiscusstest2015",
|
506 |
target="en",
|
507 |
sources={"fr"},
|
508 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
509 |
path=("dev/newsdiscusstest2015-{src}en-src.{src}.sgm", "dev/newsdiscusstest2015-{src}en-ref.en.sgm"),
|
510 |
),
|
511 |
SubDataset(
|
512 |
name="newssyscomb2009",
|
513 |
target="en",
|
514 |
sources={"cs", "de", "es", "fr"},
|
515 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
516 |
path=("dev/newssyscomb2009.{src}", "dev/newssyscomb2009.en"),
|
517 |
),
|
518 |
SubDataset(
|
519 |
name="newstest2008",
|
520 |
target="en",
|
521 |
sources={"cs", "de", "es", "fr", "hu"},
|
522 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
523 |
path=("dev/news-test2008.{src}", "dev/news-test2008.en"),
|
524 |
),
|
525 |
SubDataset(
|
526 |
name="newstest2009",
|
527 |
target="en",
|
528 |
sources={"cs", "de", "es", "fr"},
|
529 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
530 |
path=("dev/newstest2009.{src}", "dev/newstest2009.en"),
|
531 |
),
|
532 |
SubDataset(
|
533 |
name="newstest2010",
|
534 |
target="en",
|
535 |
sources={"cs", "de", "es", "fr"},
|
536 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
537 |
path=("dev/newstest2010.{src}", "dev/newstest2010.en"),
|
538 |
),
|
539 |
SubDataset(
|
540 |
name="newstest2011",
|
541 |
target="en",
|
542 |
sources={"cs", "de", "es", "fr"},
|
543 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
544 |
path=("dev/newstest2011.{src}", "dev/newstest2011.en"),
|
545 |
),
|
546 |
SubDataset(
|
547 |
name="newstest2012",
|
548 |
target="en",
|
549 |
sources={"cs", "de", "es", "fr", "ru"},
|
550 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
551 |
path=("dev/newstest2012.{src}", "dev/newstest2012.en"),
|
552 |
),
|
553 |
SubDataset(
|
554 |
name="newstest2013",
|
555 |
target="en",
|
556 |
sources={"cs", "de", "es", "fr", "ru"},
|
557 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
558 |
path=("dev/newstest2013.{src}", "dev/newstest2013.en"),
|
559 |
),
|
560 |
SubDataset(
|
561 |
name="newstest2014",
|
562 |
target="en",
|
563 |
sources={"cs", "de", "es", "fr", "hi", "ru"},
|
564 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
565 |
path=("dev/newstest2014-{src}en-src.{src}.sgm", "dev/newstest2014-{src}en-ref.en.sgm"),
|
566 |
),
|
567 |
SubDataset(
|
568 |
name="newstest2015",
|
569 |
target="en",
|
570 |
sources={"cs", "de", "fi", "ru"},
|
571 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
572 |
path=("dev/newstest2015-{src}en-src.{src}.sgm", "dev/newstest2015-{src}en-ref.en.sgm"),
|
573 |
),
|
574 |
SubDataset(
|
575 |
name="newsdiscusstest2015",
|
576 |
target="en",
|
577 |
sources={"fr"},
|
578 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
579 |
path=("dev/newsdiscusstest2015-{src}en-src.{src}.sgm", "dev/newsdiscusstest2015-{src}en-ref.en.sgm"),
|
580 |
),
|
581 |
SubDataset(
|
582 |
name="newstest2016",
|
583 |
target="en",
|
584 |
sources={"cs", "de", "fi", "ro", "ru", "tr"},
|
585 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
586 |
path=("dev/newstest2016-{src}en-src.{src}.sgm", "dev/newstest2016-{src}en-ref.en.sgm"),
|
587 |
),
|
588 |
SubDataset(
|
589 |
name="newstestB2016",
|
590 |
target="en",
|
591 |
sources={"fi"},
|
592 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
593 |
path=("dev/newstestB2016-enfi-ref.{src}.sgm", "dev/newstestB2016-enfi-src.en.sgm"),
|
594 |
),
|
595 |
SubDataset(
|
596 |
name="newstest2017",
|
597 |
target="en",
|
598 |
sources={"cs", "de", "fi", "lv", "ru", "tr", "zh"},
|
599 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
600 |
path=("dev/newstest2017-{src}en-src.{src}.sgm", "dev/newstest2017-{src}en-ref.en.sgm"),
|
601 |
),
|
602 |
SubDataset(
|
603 |
name="newstestB2017",
|
604 |
target="en",
|
605 |
sources={"fi"},
|
606 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
607 |
path=("dev/newstestB2017-fien-src.fi.sgm", "dev/newstestB2017-fien-ref.en.sgm"),
|
608 |
),
|
609 |
SubDataset(
|
610 |
name="newstest2018",
|
611 |
target="en",
|
612 |
sources={"cs", "de", "et", "fi", "ru", "tr", "zh"},
|
613 |
-
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main/translation-task/dev.
|
614 |
path=("dev/newstest2018-{src}en-src.{src}.sgm", "dev/newstest2018-{src}en-ref.en.sgm"),
|
615 |
),
|
616 |
]
|
@@ -658,9 +658,7 @@ class WmtConfig(datasets.BuilderConfig):
|
|
658 |
# TODO(PVP): remove when manual dir works
|
659 |
# +++++++++++++++++++++
|
660 |
if language_pair[1] in ["cs", "hi", "ru"]:
|
661 |
-
assert NotImplementedError(
|
662 |
-
"The dataset for {}-en is currently not fully supported.".format(language_pair[1])
|
663 |
-
)
|
664 |
# +++++++++++++++++++++
|
665 |
|
666 |
|
@@ -730,7 +728,7 @@ class Wmt(ABC, datasets.GeneratorBasedBuilder):
|
|
730 |
if dataset.get_manual_dl_files(source):
|
731 |
# TODO(PVP): following two lines skip configs that are incomplete for now
|
732 |
# +++++++++++++++++++++
|
733 |
-
logger.info("Skipping {} for now. Incomplete dataset for {
|
734 |
continue
|
735 |
# +++++++++++++++++++++
|
736 |
|
@@ -741,9 +739,7 @@ class Wmt(ABC, datasets.GeneratorBasedBuilder):
|
|
741 |
]
|
742 |
assert all(
|
743 |
os.path.exists(path) for path in manual_paths
|
744 |
-
), "For {
|
745 |
-
dataset.name, dataset.get_url(source), dl_manager.manual_dir, ", ".join(manual_dl_files)
|
746 |
-
)
|
747 |
|
748 |
# set manual path for correct subset
|
749 |
manual_paths_dict[ss_name] = manual_paths
|
@@ -779,20 +775,31 @@ class Wmt(ABC, datasets.GeneratorBasedBuilder):
|
|
779 |
for ex_dir, rel_path in zip(extract_dirs, rel_paths)
|
780 |
]
|
781 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
for ss_name in split_subsets:
|
783 |
# TODO(PVP) remove following five lines when manual data works
|
784 |
# +++++++++++++++++++++
|
785 |
dataset = DATASET_MAP[ss_name]
|
786 |
source, _ = self.config.language_pair
|
787 |
if dataset.get_manual_dl_files(source):
|
788 |
-
logger.info("Skipping {} for now. Incomplete dataset for {
|
789 |
continue
|
790 |
# +++++++++++++++++++++
|
791 |
|
792 |
logger.info("Generating examples from: %s", ss_name)
|
|
|
793 |
dataset = DATASET_MAP[ss_name]
|
794 |
extract_dirs = extraction_map[ss_name]
|
795 |
files = _get_local_paths(dataset, extract_dirs)
|
|
|
|
|
|
|
796 |
|
797 |
if ss_name.startswith("czeng"):
|
798 |
if ss_name.endswith("16pre"):
|
@@ -809,8 +816,9 @@ class Wmt(ABC, datasets.GeneratorBasedBuilder):
|
|
809 |
sub_generator = _parse_frde_bitext
|
810 |
else:
|
811 |
sub_generator = _parse_parallel_sentences
|
|
|
812 |
elif len(files) == 1:
|
813 |
-
fname =
|
814 |
# Note: Due to formatting used by `download_manager`, the file
|
815 |
# extension may not be at the end of the file path.
|
816 |
if ".tsv" in fname:
|
@@ -830,28 +838,33 @@ class Wmt(ABC, datasets.GeneratorBasedBuilder):
|
|
830 |
else:
|
831 |
raise ValueError("Invalid number of files: %d" % len(files))
|
832 |
|
833 |
-
for sub_key, ex in sub_generator(*
|
834 |
if not all(ex.values()):
|
835 |
continue
|
836 |
# TODO(adarob): Add subset feature.
|
837 |
# ex["subset"] = subset
|
838 |
-
key = "{}/{}"
|
839 |
if with_translation is True:
|
840 |
ex = {"translation": ex}
|
841 |
yield key, ex
|
842 |
|
843 |
|
844 |
-
def _parse_parallel_sentences(f1, f2):
|
845 |
"""Returns examples from parallel SGML or text files, which may be gzipped."""
|
846 |
|
847 |
-
def _parse_text(path):
|
848 |
"""Returns the sentences from a single text file, which may be gzipped."""
|
849 |
-
split_path =
|
850 |
|
851 |
if split_path[-1] == "gz":
|
852 |
lang = split_path[-2]
|
853 |
-
|
854 |
-
|
|
|
|
|
|
|
|
|
|
|
855 |
|
856 |
if split_path[-1] == "txt":
|
857 |
# CWMT
|
@@ -859,25 +872,32 @@ def _parse_parallel_sentences(f1, f2):
|
|
859 |
lang = "zh" if lang in ("ch", "cn") else lang
|
860 |
else:
|
861 |
lang = split_path[-1]
|
862 |
-
with open(path, "rb") as f:
|
863 |
-
return f.read().decode("utf-8").split("\n"), lang
|
864 |
|
865 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
866 |
"""Returns sentences from a single SGML file."""
|
867 |
-
lang =
|
868 |
-
sentences = []
|
869 |
# Note: We can't use the XML parser since some of the files are badly
|
870 |
# formatted.
|
871 |
seg_re = re.compile(r"<seg id=\"\d+\">(.*)</seg>")
|
872 |
-
with open(path, encoding="utf-8") as f:
|
873 |
-
for line in f:
|
874 |
-
seg_match = re.match(seg_re, line)
|
875 |
-
if seg_match:
|
876 |
-
assert len(seg_match.groups()) == 1
|
877 |
-
sentences.append(seg_match.groups()[0])
|
878 |
-
return sentences, lang
|
879 |
|
880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
881 |
|
882 |
# Some datasets (e.g., CWMT) contain multiple parallel files specified with
|
883 |
# a wildcard. We sort both sets to align them and parse them one by one.
|
@@ -893,34 +913,19 @@ def _parse_parallel_sentences(f1, f2):
|
|
893 |
)
|
894 |
|
895 |
for f_id, (f1_i, f2_i) in enumerate(zip(sorted(f1_files), sorted(f2_files))):
|
896 |
-
l1_sentences, l1 = parse_file(f1_i)
|
897 |
-
l2_sentences, l2 = parse_file(f2_i)
|
898 |
-
|
899 |
-
assert len(l1_sentences) == len(l2_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
|
900 |
-
len(l1_sentences),
|
901 |
-
len(l2_sentences),
|
902 |
-
f1_i,
|
903 |
-
f2_i,
|
904 |
-
)
|
905 |
|
906 |
for line_id, (s1, s2) in enumerate(zip(l1_sentences, l2_sentences)):
|
907 |
-
key = "{}/{}"
|
908 |
yield key, {l1: s1, l2: s2}
|
909 |
|
910 |
|
911 |
def _parse_frde_bitext(fr_path, de_path):
|
912 |
-
with open(fr_path, encoding="utf-8") as
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
assert len(fr_sentences) == len(de_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
|
917 |
-
len(fr_sentences),
|
918 |
-
len(de_sentences),
|
919 |
-
fr_path,
|
920 |
-
de_path,
|
921 |
-
)
|
922 |
-
for line_id, (s1, s2) in enumerate(zip(fr_sentences, de_sentences)):
|
923 |
-
yield line_id, {"fr": s1, "de": s2}
|
924 |
|
925 |
|
926 |
def _parse_tmx(path):
|
@@ -997,7 +1002,7 @@ def _parse_czeng(*paths, **kwargs):
|
|
997 |
block_match = re.match(re_block, id_)
|
998 |
if block_match and block_match.groups()[0] in bad_blocks:
|
999 |
continue
|
1000 |
-
sub_key = "{}/{}"
|
1001 |
yield sub_key, {
|
1002 |
"cs": cs.strip(),
|
1003 |
"en": en.strip(),
|
|
|
96 |
def _inject_language(self, src, strings):
|
97 |
"""Injects languages into (potentially) template strings."""
|
98 |
if src not in self.sources:
|
99 |
+
raise ValueError(f"Invalid source for '{self.name}': {src}")
|
100 |
|
101 |
def _format_string(s):
|
102 |
if "{0}" in s and "{1}" and "{src}" in s:
|
|
|
127 |
name="commoncrawl",
|
128 |
target="en", # fr-de pair in commoncrawl_frde
|
129 |
sources={"cs", "de", "es", "fr", "ru"},
|
130 |
+
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-commoncrawl.zip",
|
131 |
path=("commoncrawl.{src}-en.{src}", "commoncrawl.{src}-en.en"),
|
132 |
),
|
133 |
SubDataset(
|
|
|
184 |
name="dcep_v1",
|
185 |
target="en",
|
186 |
sources={"lv"},
|
187 |
+
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main-zip/translation-task/dcep.lv-en.v1.zip",
|
188 |
path=("dcep.en-lv/dcep.lv", "dcep.en-lv/dcep.en"),
|
189 |
),
|
190 |
SubDataset(
|
191 |
name="europarl_v7",
|
192 |
target="en",
|
193 |
sources={"cs", "de", "es", "fr"},
|
194 |
+
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-europarl-v7.zip",
|
195 |
path=("training/europarl-v7.{src}-en.{src}", "training/europarl-v7.{src}-en.en"),
|
196 |
),
|
197 |
SubDataset(
|
|
|
208 |
name="europarl_v8_18",
|
209 |
target="en",
|
210 |
sources={"et", "fi"},
|
211 |
+
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main-zip/translation-task/training-parallel-ep-v8.zip",
|
212 |
path=("training/europarl-v8.{src}-en.{src}", "training/europarl-v8.{src}-en.en"),
|
213 |
),
|
214 |
SubDataset(
|
215 |
name="europarl_v8_16",
|
216 |
target="en",
|
217 |
sources={"fi", "ro"},
|
218 |
+
url="https://huggingface.co/datasets/wmt/wmt16/resolve/main-zip/translation-task/training-parallel-ep-v8.zip",
|
219 |
path=("training-parallel-ep-v8/europarl-v8.{src}-en.{src}", "training-parallel-ep-v8/europarl-v8.{src}-en.en"),
|
220 |
),
|
221 |
SubDataset(
|
|
|
229 |
name="gigafren",
|
230 |
target="en",
|
231 |
sources={"fr"},
|
232 |
+
url="https://huggingface.co/datasets/wmt/wmt10/resolve/main-zip/training-giga-fren.zip",
|
233 |
path=("giga-fren.release2.fixed.fr.gz", "giga-fren.release2.fixed.en.gz"),
|
234 |
),
|
235 |
SubDataset(
|
|
|
244 |
name="leta_v1",
|
245 |
target="en",
|
246 |
sources={"lv"},
|
247 |
+
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main-zip/translation-task/leta.v1.zip",
|
248 |
path=("LETA-lv-en/leta.lv", "LETA-lv-en/leta.en"),
|
249 |
),
|
250 |
SubDataset(
|
251 |
name="multiun",
|
252 |
target="en",
|
253 |
sources={"es", "fr"},
|
254 |
+
url="https://huggingface.co/datasets/wmt/wmt13/resolve/main-zip/training-parallel-un.zip",
|
255 |
path=("un/undoc.2000.{src}-en.{src}", "un/undoc.2000.{src}-en.en"),
|
256 |
),
|
257 |
SubDataset(
|
258 |
name="newscommentary_v9",
|
259 |
target="en",
|
260 |
sources={"cs", "de", "fr", "ru"},
|
261 |
+
url="https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/training-parallel-nc-v9.zip",
|
262 |
path=("training/news-commentary-v9.{src}-en.{src}", "training/news-commentary-v9.{src}-en.en"),
|
263 |
),
|
264 |
SubDataset(
|
265 |
name="newscommentary_v10",
|
266 |
target="en",
|
267 |
sources={"cs", "de", "fr", "ru"},
|
268 |
+
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main-zip/training-parallel-nc-v10.zip",
|
269 |
path=("news-commentary-v10.{src}-en.{src}", "news-commentary-v10.{src}-en.en"),
|
270 |
),
|
271 |
SubDataset(
|
272 |
name="newscommentary_v11",
|
273 |
target="en",
|
274 |
sources={"cs", "de", "ru"},
|
275 |
+
url="https://huggingface.co/datasets/wmt/wmt16/resolve/main-zip/translation-task/training-parallel-nc-v11.zip",
|
276 |
path=(
|
277 |
"training-parallel-nc-v11/news-commentary-v11.{src}-en.{src}",
|
278 |
"training-parallel-nc-v11/news-commentary-v11.{src}-en.en",
|
|
|
282 |
name="newscommentary_v12",
|
283 |
target="en",
|
284 |
sources={"cs", "de", "ru", "zh"},
|
285 |
+
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main-zip/translation-task/training-parallel-nc-v12.zip",
|
286 |
path=("training/news-commentary-v12.{src}-en.{src}", "training/news-commentary-v12.{src}-en.en"),
|
287 |
),
|
288 |
SubDataset(
|
289 |
name="newscommentary_v13",
|
290 |
target="en",
|
291 |
sources={"cs", "de", "ru", "zh"},
|
292 |
+
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main-zip/translation-task/training-parallel-nc-v13.zip",
|
293 |
path=(
|
294 |
"training-parallel-nc-v13/news-commentary-v13.{src}-en.{src}",
|
295 |
"training-parallel-nc-v13/news-commentary-v13.{src}-en.en",
|
|
|
313 |
name="onlinebooks_v1",
|
314 |
target="en",
|
315 |
sources={"lv"},
|
316 |
+
url="https://huggingface.co/datasets/wmt/wmt17/resolve/main-zip/translation-task/books.lv-en.v1.zip",
|
317 |
path=("farewell/farewell.lv", "farewell/farewell.en"),
|
318 |
),
|
319 |
SubDataset(
|
320 |
name="paracrawl_v1",
|
321 |
target="en",
|
322 |
sources={"cs", "de", "et", "fi", "ru"},
|
323 |
+
url="https://s3.amazonaws.com/web-language-models/paracrawl/release1/paracrawl-release1.en-{src}.zipporah0-dedup-clean.tgz", # TODO(QL): use gzip for streaming
|
324 |
path=(
|
325 |
"paracrawl-release1.en-{src}.zipporah0-dedup-clean.{src}",
|
326 |
"paracrawl-release1.en-{src}.zipporah0-dedup-clean.en",
|
|
|
330 |
name="paracrawl_v1_ru",
|
331 |
target="en",
|
332 |
sources={"ru"},
|
333 |
+
url="https://s3.amazonaws.com/web-language-models/paracrawl/release1/paracrawl-release1.en-ru.zipporah0-dedup-clean.tgz", # TODO(QL): use gzip for streaming
|
334 |
path=(
|
335 |
"paracrawl-release1.en-ru.zipporah0-dedup-clean.ru",
|
336 |
"paracrawl-release1.en-ru.zipporah0-dedup-clean.en",
|
|
|
357 |
name="rapid_2016",
|
358 |
target="en",
|
359 |
sources={"de", "et", "fi"},
|
360 |
+
url="https://huggingface.co/datasets/wmt/wmt18/resolve/main-zip/translation-task/rapid2016.zip",
|
361 |
path=("rapid2016.{0}-{1}.{src}", "rapid2016.{0}-{1}.en"),
|
362 |
),
|
363 |
SubDataset(
|
|
|
385 |
name="uncorpus_v1",
|
386 |
target="en",
|
387 |
sources={"ru", "zh"},
|
388 |
+
url="https://huggingface.co/datasets/wmt/uncorpus/resolve/main-zip/UNv1.0.en-{src}.zip",
|
389 |
path=("en-{src}/UNv1.0.en-{src}.{src}", "en-{src}/UNv1.0.en-{src}.en"),
|
390 |
),
|
391 |
SubDataset(
|
392 |
name="wikiheadlines_fi",
|
393 |
target="en",
|
394 |
sources={"fi"},
|
395 |
+
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main-zip/wiki-titles.zip",
|
396 |
path="wiki/fi-en/titles.fi-en",
|
397 |
),
|
398 |
SubDataset(
|
399 |
name="wikiheadlines_hi",
|
400 |
target="en",
|
401 |
sources={"hi"},
|
402 |
+
url="https://huggingface.co/datasets/wmt/wmt14/resolve/main-zip/wiki-titles.zip",
|
403 |
path="wiki/hi-en/wiki-titles.hi-en",
|
404 |
),
|
405 |
SubDataset(
|
|
|
407 |
name="wikiheadlines_ru",
|
408 |
target="en",
|
409 |
sources={"ru"},
|
410 |
+
url="https://huggingface.co/datasets/wmt/wmt15/resolve/main-zip/wiki-titles.zip",
|
411 |
path="wiki/ru-en/wiki.ru-en",
|
412 |
),
|
413 |
SubDataset(
|
|
|
431 |
name=ss,
|
432 |
target="en",
|
433 |
sources={"zh"},
|
434 |
+
url="http://www.hackcha.cn/cwmt_data//%s.zip" % ss,
|
435 |
path=("%s/*_c[hn].txt" % ss, "%s/*_en.txt" % ss),
|
436 |
)
|
437 |
for ss in CWMT_SUBSET_NAMES
|
|
|
442 |
name="euelections_dev2019",
|
443 |
target="de",
|
444 |
sources={"fr"},
|
445 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
446 |
path=("dev/euelections_dev2019.fr-de.src.fr", "dev/euelections_dev2019.fr-de.tgt.de"),
|
447 |
),
|
448 |
SubDataset(
|
449 |
name="newsdev2014",
|
450 |
target="en",
|
451 |
sources={"hi"},
|
452 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
453 |
path=("dev/newsdev2014.hi", "dev/newsdev2014.en"),
|
454 |
),
|
455 |
SubDataset(
|
456 |
name="newsdev2015",
|
457 |
target="en",
|
458 |
sources={"fi"},
|
459 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
460 |
path=("dev/newsdev2015-fien-src.{src}.sgm", "dev/newsdev2015-fien-ref.en.sgm"),
|
461 |
),
|
462 |
SubDataset(
|
463 |
name="newsdiscussdev2015",
|
464 |
target="en",
|
465 |
sources={"ro", "tr"},
|
466 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
467 |
path=("dev/newsdiscussdev2015-{src}en-src.{src}.sgm", "dev/newsdiscussdev2015-{src}en-ref.en.sgm"),
|
468 |
),
|
469 |
SubDataset(
|
470 |
name="newsdev2016",
|
471 |
target="en",
|
472 |
sources={"ro", "tr"},
|
473 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
474 |
path=("dev/newsdev2016-{src}en-src.{src}.sgm", "dev/newsdev2016-{src}en-ref.en.sgm"),
|
475 |
),
|
476 |
SubDataset(
|
477 |
name="newsdev2017",
|
478 |
target="en",
|
479 |
sources={"lv", "zh"},
|
480 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
481 |
path=("dev/newsdev2017-{src}en-src.{src}.sgm", "dev/newsdev2017-{src}en-ref.en.sgm"),
|
482 |
),
|
483 |
SubDataset(
|
484 |
name="newsdev2018",
|
485 |
target="en",
|
486 |
sources={"et"},
|
487 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
488 |
path=("dev/newsdev2018-{src}en-src.{src}.sgm", "dev/newsdev2018-{src}en-ref.en.sgm"),
|
489 |
),
|
490 |
SubDataset(
|
491 |
name="newsdev2019",
|
492 |
target="en",
|
493 |
sources={"gu", "kk", "lt"},
|
494 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
495 |
path=("dev/newsdev2019-{src}en-src.{src}.sgm", "dev/newsdev2019-{src}en-ref.en.sgm"),
|
496 |
),
|
497 |
SubDataset(
|
498 |
name="newsdiscussdev2015",
|
499 |
target="en",
|
500 |
sources={"fr"},
|
501 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
502 |
path=("dev/newsdiscussdev2015-{src}en-src.{src}.sgm", "dev/newsdiscussdev2015-{src}en-ref.en.sgm"),
|
503 |
),
|
504 |
SubDataset(
|
505 |
name="newsdiscusstest2015",
|
506 |
target="en",
|
507 |
sources={"fr"},
|
508 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
509 |
path=("dev/newsdiscusstest2015-{src}en-src.{src}.sgm", "dev/newsdiscusstest2015-{src}en-ref.en.sgm"),
|
510 |
),
|
511 |
SubDataset(
|
512 |
name="newssyscomb2009",
|
513 |
target="en",
|
514 |
sources={"cs", "de", "es", "fr"},
|
515 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
516 |
path=("dev/newssyscomb2009.{src}", "dev/newssyscomb2009.en"),
|
517 |
),
|
518 |
SubDataset(
|
519 |
name="newstest2008",
|
520 |
target="en",
|
521 |
sources={"cs", "de", "es", "fr", "hu"},
|
522 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
523 |
path=("dev/news-test2008.{src}", "dev/news-test2008.en"),
|
524 |
),
|
525 |
SubDataset(
|
526 |
name="newstest2009",
|
527 |
target="en",
|
528 |
sources={"cs", "de", "es", "fr"},
|
529 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
530 |
path=("dev/newstest2009.{src}", "dev/newstest2009.en"),
|
531 |
),
|
532 |
SubDataset(
|
533 |
name="newstest2010",
|
534 |
target="en",
|
535 |
sources={"cs", "de", "es", "fr"},
|
536 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
537 |
path=("dev/newstest2010.{src}", "dev/newstest2010.en"),
|
538 |
),
|
539 |
SubDataset(
|
540 |
name="newstest2011",
|
541 |
target="en",
|
542 |
sources={"cs", "de", "es", "fr"},
|
543 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
544 |
path=("dev/newstest2011.{src}", "dev/newstest2011.en"),
|
545 |
),
|
546 |
SubDataset(
|
547 |
name="newstest2012",
|
548 |
target="en",
|
549 |
sources={"cs", "de", "es", "fr", "ru"},
|
550 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
551 |
path=("dev/newstest2012.{src}", "dev/newstest2012.en"),
|
552 |
),
|
553 |
SubDataset(
|
554 |
name="newstest2013",
|
555 |
target="en",
|
556 |
sources={"cs", "de", "es", "fr", "ru"},
|
557 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
558 |
path=("dev/newstest2013.{src}", "dev/newstest2013.en"),
|
559 |
),
|
560 |
SubDataset(
|
561 |
name="newstest2014",
|
562 |
target="en",
|
563 |
sources={"cs", "de", "es", "fr", "hi", "ru"},
|
564 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
565 |
path=("dev/newstest2014-{src}en-src.{src}.sgm", "dev/newstest2014-{src}en-ref.en.sgm"),
|
566 |
),
|
567 |
SubDataset(
|
568 |
name="newstest2015",
|
569 |
target="en",
|
570 |
sources={"cs", "de", "fi", "ru"},
|
571 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
572 |
path=("dev/newstest2015-{src}en-src.{src}.sgm", "dev/newstest2015-{src}en-ref.en.sgm"),
|
573 |
),
|
574 |
SubDataset(
|
575 |
name="newsdiscusstest2015",
|
576 |
target="en",
|
577 |
sources={"fr"},
|
578 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
579 |
path=("dev/newsdiscusstest2015-{src}en-src.{src}.sgm", "dev/newsdiscusstest2015-{src}en-ref.en.sgm"),
|
580 |
),
|
581 |
SubDataset(
|
582 |
name="newstest2016",
|
583 |
target="en",
|
584 |
sources={"cs", "de", "fi", "ro", "ru", "tr"},
|
585 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
586 |
path=("dev/newstest2016-{src}en-src.{src}.sgm", "dev/newstest2016-{src}en-ref.en.sgm"),
|
587 |
),
|
588 |
SubDataset(
|
589 |
name="newstestB2016",
|
590 |
target="en",
|
591 |
sources={"fi"},
|
592 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
593 |
path=("dev/newstestB2016-enfi-ref.{src}.sgm", "dev/newstestB2016-enfi-src.en.sgm"),
|
594 |
),
|
595 |
SubDataset(
|
596 |
name="newstest2017",
|
597 |
target="en",
|
598 |
sources={"cs", "de", "fi", "lv", "ru", "tr", "zh"},
|
599 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
600 |
path=("dev/newstest2017-{src}en-src.{src}.sgm", "dev/newstest2017-{src}en-ref.en.sgm"),
|
601 |
),
|
602 |
SubDataset(
|
603 |
name="newstestB2017",
|
604 |
target="en",
|
605 |
sources={"fi"},
|
606 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
607 |
path=("dev/newstestB2017-fien-src.fi.sgm", "dev/newstestB2017-fien-ref.en.sgm"),
|
608 |
),
|
609 |
SubDataset(
|
610 |
name="newstest2018",
|
611 |
target="en",
|
612 |
sources={"cs", "de", "et", "fi", "ru", "tr", "zh"},
|
613 |
+
url="https://huggingface.co/datasets/wmt/wmt19/resolve/main-zip/translation-task/dev.zip",
|
614 |
path=("dev/newstest2018-{src}en-src.{src}.sgm", "dev/newstest2018-{src}en-ref.en.sgm"),
|
615 |
),
|
616 |
]
|
|
|
658 |
# TODO(PVP): remove when manual dir works
|
659 |
# +++++++++++++++++++++
|
660 |
if language_pair[1] in ["cs", "hi", "ru"]:
|
661 |
+
assert NotImplementedError(f"The dataset for {language_pair[1]}-en is currently not fully supported.")
|
|
|
|
|
662 |
# +++++++++++++++++++++
|
663 |
|
664 |
|
|
|
728 |
if dataset.get_manual_dl_files(source):
|
729 |
# TODO(PVP): following two lines skip configs that are incomplete for now
|
730 |
# +++++++++++++++++++++
|
731 |
+
logger.info(f"Skipping {dataset.name} for now. Incomplete dataset for {self.config.name}")
|
732 |
continue
|
733 |
# +++++++++++++++++++++
|
734 |
|
|
|
739 |
]
|
740 |
assert all(
|
741 |
os.path.exists(path) for path in manual_paths
|
742 |
+
), f"For {dataset.name}, you must manually download the following file(s) from {dataset.get_url(source)} and place them in {dl_manager.manual_dir}: {', '.join(manual_dl_files)}"
|
|
|
|
|
743 |
|
744 |
# set manual path for correct subset
|
745 |
manual_paths_dict[ss_name] = manual_paths
|
|
|
775 |
for ex_dir, rel_path in zip(extract_dirs, rel_paths)
|
776 |
]
|
777 |
|
778 |
+
def _get_filenames(dataset):
|
779 |
+
rel_paths = dataset.get_path(source)
|
780 |
+
urls = dataset.get_url(source)
|
781 |
+
if len(urls) == 1:
|
782 |
+
urls = urls * len(rel_paths)
|
783 |
+
return [rel_path if rel_path else os.path.basename(url) for url, rel_path in zip(urls, rel_paths)]
|
784 |
+
|
785 |
for ss_name in split_subsets:
|
786 |
# TODO(PVP) remove following five lines when manual data works
|
787 |
# +++++++++++++++++++++
|
788 |
dataset = DATASET_MAP[ss_name]
|
789 |
source, _ = self.config.language_pair
|
790 |
if dataset.get_manual_dl_files(source):
|
791 |
+
logger.info(f"Skipping {dataset.name} for now. Incomplete dataset for {self.config.name}")
|
792 |
continue
|
793 |
# +++++++++++++++++++++
|
794 |
|
795 |
logger.info("Generating examples from: %s", ss_name)
|
796 |
+
print("Generating examples from: %s", ss_name)
|
797 |
dataset = DATASET_MAP[ss_name]
|
798 |
extract_dirs = extraction_map[ss_name]
|
799 |
files = _get_local_paths(dataset, extract_dirs)
|
800 |
+
filenames = _get_filenames(dataset)
|
801 |
+
|
802 |
+
sub_generator_args = tuple(files)
|
803 |
|
804 |
if ss_name.startswith("czeng"):
|
805 |
if ss_name.endswith("16pre"):
|
|
|
816 |
sub_generator = _parse_frde_bitext
|
817 |
else:
|
818 |
sub_generator = _parse_parallel_sentences
|
819 |
+
sub_generator_args += tuple(filenames)
|
820 |
elif len(files) == 1:
|
821 |
+
fname = filenames[0]
|
822 |
# Note: Due to formatting used by `download_manager`, the file
|
823 |
# extension may not be at the end of the file path.
|
824 |
if ".tsv" in fname:
|
|
|
838 |
else:
|
839 |
raise ValueError("Invalid number of files: %d" % len(files))
|
840 |
|
841 |
+
for sub_key, ex in sub_generator(*sub_generator_args):
|
842 |
if not all(ex.values()):
|
843 |
continue
|
844 |
# TODO(adarob): Add subset feature.
|
845 |
# ex["subset"] = subset
|
846 |
+
key = f"{ss_name}/{sub_key}"
|
847 |
if with_translation is True:
|
848 |
ex = {"translation": ex}
|
849 |
yield key, ex
|
850 |
|
851 |
|
852 |
+
def _parse_parallel_sentences(f1, f2, filename1, filename2):
|
853 |
"""Returns examples from parallel SGML or text files, which may be gzipped."""
|
854 |
|
855 |
+
def _parse_text(path, original_filename):
|
856 |
"""Returns the sentences from a single text file, which may be gzipped."""
|
857 |
+
split_path = original_filename.split(".")
|
858 |
|
859 |
if split_path[-1] == "gz":
|
860 |
lang = split_path[-2]
|
861 |
+
|
862 |
+
def gen():
|
863 |
+
with open(path, "rb") as f, gzip.GzipFile(fileobj=f) as g:
|
864 |
+
for line in g:
|
865 |
+
yield line.decode("utf-8").rstrip()
|
866 |
+
|
867 |
+
return gen(), lang
|
868 |
|
869 |
if split_path[-1] == "txt":
|
870 |
# CWMT
|
|
|
872 |
lang = "zh" if lang in ("ch", "cn") else lang
|
873 |
else:
|
874 |
lang = split_path[-1]
|
|
|
|
|
875 |
|
876 |
+
def gen():
|
877 |
+
with open(path, "rb") as f:
|
878 |
+
for line in f:
|
879 |
+
yield line.decode("utf-8").rstrip()
|
880 |
+
|
881 |
+
return gen(), lang
|
882 |
+
|
883 |
+
def _parse_sgm(path, original_filename):
|
884 |
"""Returns sentences from a single SGML file."""
|
885 |
+
lang = original_filename.split(".")[-2]
|
|
|
886 |
# Note: We can't use the XML parser since some of the files are badly
|
887 |
# formatted.
|
888 |
seg_re = re.compile(r"<seg id=\"\d+\">(.*)</seg>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
|
890 |
+
def gen():
|
891 |
+
with open(path, encoding="utf-8") as f:
|
892 |
+
for line in f:
|
893 |
+
seg_match = re.match(seg_re, line)
|
894 |
+
if seg_match:
|
895 |
+
assert len(seg_match.groups()) == 1
|
896 |
+
yield seg_match.groups()[0]
|
897 |
+
|
898 |
+
return gen(), lang
|
899 |
+
|
900 |
+
parse_file = _parse_sgm if os.path.basename(f1).endswith(".sgm") else _parse_text
|
901 |
|
902 |
# Some datasets (e.g., CWMT) contain multiple parallel files specified with
|
903 |
# a wildcard. We sort both sets to align them and parse them one by one.
|
|
|
913 |
)
|
914 |
|
915 |
for f_id, (f1_i, f2_i) in enumerate(zip(sorted(f1_files), sorted(f2_files))):
|
916 |
+
l1_sentences, l1 = parse_file(f1_i, filename1)
|
917 |
+
l2_sentences, l2 = parse_file(f2_i, filename2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
|
919 |
for line_id, (s1, s2) in enumerate(zip(l1_sentences, l2_sentences)):
|
920 |
+
key = f"{f_id}/{line_id}"
|
921 |
yield key, {l1: s1, l2: s2}
|
922 |
|
923 |
|
924 |
def _parse_frde_bitext(fr_path, de_path):
|
925 |
+
with open(fr_path, encoding="utf-8") as fr_f:
|
926 |
+
with open(de_path, encoding="utf-8") as de_f:
|
927 |
+
for line_id, (s1, s2) in enumerate(zip(fr_f, de_f)):
|
928 |
+
yield line_id, {"fr": s1.rstrip(), "de": s2.rstrip()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
|
930 |
|
931 |
def _parse_tmx(path):
|
|
|
1002 |
block_match = re.match(re_block, id_)
|
1003 |
if block_match and block_match.groups()[0] in bad_blocks:
|
1004 |
continue
|
1005 |
+
sub_key = f"{filename}/{line_id}"
|
1006 |
yield sub_key, {
|
1007 |
"cs": cs.strip(),
|
1008 |
"en": en.strip(),
|