Datasets:
Commit
·
ba0781a
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +155 -0
- dataset_infos.json +1 -0
- dummy/en-es/1.0.0/dummy_data.zip +3 -0
- dummy/en-pt-es/1.0.0/dummy_data.zip +3 -0
- dummy/en-pt/1.0.0/dummy_data.zip +3 -0
- scielo.py +122 -0
.gitattributes
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- found
|
| 4 |
+
language_creators:
|
| 5 |
+
- found
|
| 6 |
+
languages:
|
| 7 |
+
en-es:
|
| 8 |
+
- en
|
| 9 |
+
- es
|
| 10 |
+
en-pt:
|
| 11 |
+
- en
|
| 12 |
+
- pt
|
| 13 |
+
en-pt-es:
|
| 14 |
+
- en
|
| 15 |
+
- pt
|
| 16 |
+
- es
|
| 17 |
+
licenses:
|
| 18 |
+
- unknown
|
| 19 |
+
multilinguality:
|
| 20 |
+
- multilingual
|
| 21 |
+
size_categories:
|
| 22 |
+
- 100K<n<1M
|
| 23 |
+
source_datasets:
|
| 24 |
+
- original
|
| 25 |
+
task_categories:
|
| 26 |
+
- conditional-text-generation
|
| 27 |
+
task_ids:
|
| 28 |
+
- machine-translation
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
# Dataset Card for [Dataset Name]
|
| 32 |
+
|
| 33 |
+
## Table of Contents
|
| 34 |
+
- [Dataset Description](#dataset-description)
|
| 35 |
+
- [Dataset Summary](#dataset-summary)
|
| 36 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
| 37 |
+
- [Languages](#languages)
|
| 38 |
+
- [Dataset Structure](#dataset-structure)
|
| 39 |
+
- [Data Instances](#data-instances)
|
| 40 |
+
- [Data Fields](#data-instances)
|
| 41 |
+
- [Data Splits](#data-instances)
|
| 42 |
+
- [Dataset Creation](#dataset-creation)
|
| 43 |
+
- [Curation Rationale](#curation-rationale)
|
| 44 |
+
- [Source Data](#source-data)
|
| 45 |
+
- [Annotations](#annotations)
|
| 46 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
| 47 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
| 48 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
| 49 |
+
- [Discussion of Biases](#discussion-of-biases)
|
| 50 |
+
- [Other Known Limitations](#other-known-limitations)
|
| 51 |
+
- [Additional Information](#additional-information)
|
| 52 |
+
- [Dataset Curators](#dataset-curators)
|
| 53 |
+
- [Licensing Information](#licensing-information)
|
| 54 |
+
- [Citation Information](#citation-information)
|
| 55 |
+
|
| 56 |
+
## Dataset Description
|
| 57 |
+
|
| 58 |
+
- **Homepage:**[SciELO](https://sites.google.com/view/felipe-soares/datasets#h.p_92uSCyAjWSRB)
|
| 59 |
+
- **Repository:**
|
| 60 |
+
- **Paper:** [A Large Parallel Corpus of Full-Text Scientific Articles](https://arxiv.org/abs/1905.01852)
|
| 61 |
+
- **Leaderboard:**
|
| 62 |
+
- **Point of Contact:**
|
| 63 |
+
|
| 64 |
+
### Dataset Summary
|
| 65 |
+
|
| 66 |
+
A parallel corpus of full-text scientific articles collected from Scielo database in the following languages:English, Portuguese and Spanish.
|
| 67 |
+
The corpus is sentence aligned for all language pairs, as well as trilingual aligned for a small subset of sentences.
|
| 68 |
+
Alignment was carried out using the Hunalign algorithm.
|
| 69 |
+
|
| 70 |
+
### Supported Tasks and Leaderboards
|
| 71 |
+
|
| 72 |
+
The underlying task is machine translation.
|
| 73 |
+
|
| 74 |
+
### Languages
|
| 75 |
+
|
| 76 |
+
[More Information Needed]
|
| 77 |
+
|
| 78 |
+
## Dataset Structure
|
| 79 |
+
|
| 80 |
+
### Data Instances
|
| 81 |
+
|
| 82 |
+
[More Information Needed]
|
| 83 |
+
|
| 84 |
+
### Data Fields
|
| 85 |
+
|
| 86 |
+
[More Information Needed]
|
| 87 |
+
|
| 88 |
+
### Data Splits
|
| 89 |
+
|
| 90 |
+
[More Information Needed]
|
| 91 |
+
|
| 92 |
+
## Dataset Creation
|
| 93 |
+
|
| 94 |
+
### Curation Rationale
|
| 95 |
+
|
| 96 |
+
[More Information Needed]
|
| 97 |
+
|
| 98 |
+
### Source Data
|
| 99 |
+
|
| 100 |
+
#### Initial Data Collection and Normalization
|
| 101 |
+
|
| 102 |
+
[More Information Needed]
|
| 103 |
+
|
| 104 |
+
#### Who are the source language producers?
|
| 105 |
+
|
| 106 |
+
[More Information Needed]
|
| 107 |
+
|
| 108 |
+
### Annotations
|
| 109 |
+
|
| 110 |
+
#### Annotation process
|
| 111 |
+
|
| 112 |
+
[More Information Needed]
|
| 113 |
+
|
| 114 |
+
#### Who are the annotators?
|
| 115 |
+
|
| 116 |
+
[More Information Needed]
|
| 117 |
+
|
| 118 |
+
### Personal and Sensitive Information
|
| 119 |
+
|
| 120 |
+
[More Information Needed]
|
| 121 |
+
|
| 122 |
+
## Considerations for Using the Data
|
| 123 |
+
|
| 124 |
+
### Social Impact of Dataset
|
| 125 |
+
|
| 126 |
+
[More Information Needed]
|
| 127 |
+
|
| 128 |
+
### Discussion of Biases
|
| 129 |
+
|
| 130 |
+
[More Information Needed]
|
| 131 |
+
|
| 132 |
+
### Other Known Limitations
|
| 133 |
+
|
| 134 |
+
[More Information Needed]
|
| 135 |
+
|
| 136 |
+
## Additional Information
|
| 137 |
+
|
| 138 |
+
### Dataset Curators
|
| 139 |
+
|
| 140 |
+
[More Information Needed]
|
| 141 |
+
|
| 142 |
+
### Licensing Information
|
| 143 |
+
|
| 144 |
+
[More Information Needed]
|
| 145 |
+
|
| 146 |
+
### Citation Information
|
| 147 |
+
|
| 148 |
+
```
|
| 149 |
+
@inproceedings{soares2018large,
|
| 150 |
+
title={A Large Parallel Corpus of Full-Text Scientific Articles},
|
| 151 |
+
author={Soares, Felipe and Moreira, Viviane and Becker, Karin},
|
| 152 |
+
booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC-2018)},
|
| 153 |
+
year={2018}
|
| 154 |
+
}
|
| 155 |
+
```
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"en-es": {"description": "A parallel corpus of full-text scientific articles collected from Scielo database in the following languages: English, Portuguese and Spanish. The corpus is sentence aligned for all language pairs, as well as trilingual aligned for a small subset of sentences. Alignment was carried out using the Hunalign algorithm.\n", "citation": "@inproceedings{soares2018large,\n title={A Large Parallel Corpus of Full-Text Scientific Articles},\n author={Soares, Felipe and Moreira, Viviane and Becker, Karin},\n booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC-2018)},\n year={2018}\n}\n", "homepage": "http://www.euromatrixplus.net/multi-un/", "license": "", "features": {"translation": {"languages": ["en", "es"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "scielo", "config_name": "en-es", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 71777213, "num_examples": 177782, "dataset_name": "scielo"}}, "download_checksums": {"https://ndownloader.figstatic.com/files/14019287": {"num_bytes": 22965217, "checksum": "a56de2ee24727b42817a88339913b2741e10c37347b567ae4bf239894c6e1fca"}}, "download_size": 22965217, "post_processing_size": null, "dataset_size": 71777213, "size_in_bytes": 94742430}, "en-pt": {"description": "A parallel corpus of full-text scientific articles collected from Scielo database in the following languages: English, Portuguese and Spanish. The corpus is sentence aligned for all language pairs, as well as trilingual aligned for a small subset of sentences. Alignment was carried out using the Hunalign algorithm.\n", "citation": "@inproceedings{soares2018large,\n title={A Large Parallel Corpus of Full-Text Scientific Articles},\n author={Soares, Felipe and Moreira, Viviane and Becker, Karin},\n booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC-2018)},\n year={2018}\n}\n", "homepage": "http://www.euromatrixplus.net/multi-un/", "license": "", "features": {"translation": {"languages": ["en", "pt"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "scielo", "config_name": "en-pt", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1032669686, "num_examples": 2828917, "dataset_name": "scielo"}}, "download_checksums": {"https://ndownloader.figstatic.com/files/14019308": {"num_bytes": 322726075, "checksum": "d494e3566019f67c56cfa937c6ceb26dcad8f1454e0154c2da192de9bfff6a0c"}}, "download_size": 322726075, "post_processing_size": null, "dataset_size": 1032669686, "size_in_bytes": 1355395761}, "en-pt-es": {"description": "A parallel corpus of full-text scientific articles collected from Scielo database in the following languages: English, Portuguese and Spanish. The corpus is sentence aligned for all language pairs, as well as trilingual aligned for a small subset of sentences. Alignment was carried out using the Hunalign algorithm.\n", "citation": "@inproceedings{soares2018large,\n title={A Large Parallel Corpus of Full-Text Scientific Articles},\n author={Soares, Felipe and Moreira, Viviane and Becker, Karin},\n booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC-2018)},\n year={2018}\n}\n", "homepage": "http://www.euromatrixplus.net/multi-un/", "license": "", "features": {"translation": {"languages": ["en", "pt", "es"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "scielo", "config_name": "en-pt-es", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 147472132, "num_examples": 255915, "dataset_name": "scielo"}}, "download_checksums": {"https://ndownloader.figstatic.com/files/14019293": {"num_bytes": 45556562, "checksum": "ad943502c027e0c8ac804e15529ffab2ceefa919e63127635f67ff31e51da32f"}}, "download_size": 45556562, "post_processing_size": null, "dataset_size": 147472132, "size_in_bytes": 193028694}}
|
dummy/en-es/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d93294fe8061dcfab0259709da212036e4c555f56cf489421541f5a19cdc0f7c
|
| 3 |
+
size 653
|
dummy/en-pt-es/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab2f5fc7fae733c08e8bc7eedf995ee7d8c00f21f30dd7bcd6664eac89a4c02c
|
| 3 |
+
size 419
|
dummy/en-pt/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a4706b052eb671b714727e75a71f67b9835a4521c17a602c888eb873a78b0c4
|
| 3 |
+
size 579
|
scielo.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors.
|
| 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 |
+
"""Parallel corpus of full-text articles in Portuguese, English and Spanish from SciELO"""
|
| 16 |
+
|
| 17 |
+
from __future__ import absolute_import, division, print_function
|
| 18 |
+
|
| 19 |
+
import os
|
| 20 |
+
|
| 21 |
+
import datasets
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
_CITATION = """\
|
| 25 |
+
@inproceedings{soares2018large,
|
| 26 |
+
title={A Large Parallel Corpus of Full-Text Scientific Articles},
|
| 27 |
+
author={Soares, Felipe and Moreira, Viviane and Becker, Karin},
|
| 28 |
+
booktitle={Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC-2018)},
|
| 29 |
+
year={2018}
|
| 30 |
+
}
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
_DESCRIPTION = """\
|
| 35 |
+
A parallel corpus of full-text scientific articles collected from Scielo database in the following languages: \
|
| 36 |
+
English, Portuguese and Spanish. The corpus is sentence aligned for all language pairs, \
|
| 37 |
+
as well as trilingual aligned for a small subset of sentences. Alignment was carried out using the Hunalign algorithm.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
_HOMEPAGE = "https://sites.google.com/view/felipe-soares/datasets#h.p_92uSCyAjWSRB"
|
| 42 |
+
|
| 43 |
+
_LANGUAGES = ["en-es", "en-pt", "en-pt-es"]
|
| 44 |
+
|
| 45 |
+
_URLS = {
|
| 46 |
+
"en-es": "https://ndownloader.figstatic.com/files/14019287",
|
| 47 |
+
"en-pt": "https://ndownloader.figstatic.com/files/14019308",
|
| 48 |
+
"en-pt-es": "https://ndownloader.figstatic.com/files/14019293",
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class Scielo(datasets.GeneratorBasedBuilder):
|
| 53 |
+
"""Parallel corpus of full-text articles in Portuguese, English and Spanish from SciELO"""
|
| 54 |
+
|
| 55 |
+
VERSION = datasets.Version("1.0.0")
|
| 56 |
+
|
| 57 |
+
BUILDER_CONFIGS = [
|
| 58 |
+
datasets.BuilderConfig(name="en-es", version=datasets.Version("1.0.0"), description="English-Spanish"),
|
| 59 |
+
datasets.BuilderConfig(name="en-pt", version=datasets.Version("1.0.0"), description="English-Portuguese"),
|
| 60 |
+
datasets.BuilderConfig(
|
| 61 |
+
name="en-pt-es", version=datasets.Version("1.0.0"), description="English-Portuguese-Spanish"
|
| 62 |
+
),
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
def _info(self):
|
| 66 |
+
return datasets.DatasetInfo(
|
| 67 |
+
description=_DESCRIPTION,
|
| 68 |
+
features=datasets.Features(
|
| 69 |
+
{"translation": datasets.features.Translation(languages=tuple(self.config.name.split("-")))}
|
| 70 |
+
),
|
| 71 |
+
supervised_keys=None,
|
| 72 |
+
homepage=_HOMEPAGE,
|
| 73 |
+
citation=_CITATION,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
def _split_generators(self, dl_manager):
|
| 77 |
+
"""Returns SplitGenerators."""
|
| 78 |
+
data_dir = dl_manager.download_and_extract(_URLS[self.config.name])
|
| 79 |
+
lang_pair = self.config.name.split("-")
|
| 80 |
+
fname = self.config.name.replace("-", "_")
|
| 81 |
+
|
| 82 |
+
if self.config.name == "en-pt-es":
|
| 83 |
+
return [
|
| 84 |
+
datasets.SplitGenerator(
|
| 85 |
+
name=datasets.Split.TRAIN,
|
| 86 |
+
gen_kwargs={
|
| 87 |
+
"source_file": os.path.join(data_dir, f"{fname}.en"),
|
| 88 |
+
"target_file": os.path.join(data_dir, f"{fname}.pt"),
|
| 89 |
+
"target_file_2": os.path.join(data_dir, f"{fname}.es"),
|
| 90 |
+
},
|
| 91 |
+
),
|
| 92 |
+
]
|
| 93 |
+
|
| 94 |
+
return [
|
| 95 |
+
datasets.SplitGenerator(
|
| 96 |
+
name=datasets.Split.TRAIN,
|
| 97 |
+
gen_kwargs={
|
| 98 |
+
"source_file": os.path.join(data_dir, f"{fname}.{lang_pair[0]}"),
|
| 99 |
+
"target_file": os.path.join(data_dir, f"{fname}.{lang_pair[1]}"),
|
| 100 |
+
},
|
| 101 |
+
),
|
| 102 |
+
]
|
| 103 |
+
|
| 104 |
+
def _generate_examples(self, source_file, target_file, target_file_2=None):
|
| 105 |
+
with open(source_file, encoding="utf-8") as f:
|
| 106 |
+
source_sentences = f.read().split("\n")
|
| 107 |
+
with open(target_file, encoding="utf-8") as f:
|
| 108 |
+
target_sentences = f.read().split("\n")
|
| 109 |
+
|
| 110 |
+
if self.config.name == "en-pt-es":
|
| 111 |
+
with open(target_file_2, encoding="utf-8") as f:
|
| 112 |
+
target_2_sentences = f.read().split("\n")
|
| 113 |
+
|
| 114 |
+
source, target, target_2 = tuple(self.config.name.split("-"))
|
| 115 |
+
for idx, (l1, l2, l3) in enumerate(zip(source_sentences, target_sentences, target_2_sentences)):
|
| 116 |
+
result = {"translation": {source: l1, target: l2, target_2: l3}}
|
| 117 |
+
yield idx, result
|
| 118 |
+
else:
|
| 119 |
+
source, target = tuple(self.config.name.split("-"))
|
| 120 |
+
for idx, (l1, l2) in enumerate(zip(source_sentences, target_sentences)):
|
| 121 |
+
result = {"translation": {source: l1, target: l2}}
|
| 122 |
+
yield idx, result
|