Convert dataset to Parquet

#1
by dbihbka - opened
README.md CHANGED
@@ -15,7 +15,7 @@ dataset_info:
15
  - name: test
16
  num_bytes: 31035
17
  num_examples: 345
18
- download_size: 24678400
19
  dataset_size: 75673237
20
  - config_name: chv-rus
21
  features:
@@ -34,4 +34,12 @@ dataset_info:
34
  num_examples: 394
35
  download_size: 84889600
36
  dataset_size: 290881873
 
 
 
 
 
 
 
 
37
  ---
 
15
  - name: test
16
  num_bytes: 31035
17
  num_examples: 345
18
+ download_size: 46450938
19
  dataset_size: 75673237
20
  - config_name: chv-rus
21
  features:
 
34
  num_examples: 394
35
  download_size: 84889600
36
  dataset_size: 290881873
37
+ configs:
38
+ - config_name: chv-eng
39
+ data_files:
40
+ - split: train
41
+ path: chv-eng/train-*
42
+ - split: test
43
+ path: chv-eng/test-*
44
+ default: true
45
  ---
chv-eng/test-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0880827c4d5ec66698ee497794a7539e8b81d1cdf96c6bc69bb3f6090ffe4f1
3
+ size 20995
chv-eng/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9f4dc86c62e7777975ae17592bec7edceeb7aee8f920ebd36a08b53a93796d2
3
+ size 46429943
tatoeba-challenge.py DELETED
@@ -1,137 +0,0 @@
1
- import gzip
2
- from datasets import (
3
- BuilderConfig,
4
- GeneratorBasedBuilder,
5
- DownloadManager,
6
- StreamingDownloadManager,
7
- Version,
8
- SplitGenerator,
9
- Split,
10
- DatasetInfo,
11
- Features,
12
- Value,
13
- )
14
- from typing import Union
15
- from pathlib import Path
16
-
17
-
18
- class TatoebaChallengeConfig(BuilderConfig):
19
- """Builder config for Tatoeba challenge dataset."""
20
-
21
- def __init__(self, name: str, version: str, **kwargs):
22
- assert version == "2023-09-26", "Only v2023-09-26 is supported"
23
- super().__init__(
24
- name=name, version=Version(version.replace("-", ".")), **kwargs
25
- )
26
- self.version_str = version
27
- self.data_url = (
28
- f"https://object.pouta.csc.fi/Tatoeba-Challenge-v{version}/{name}.tar"
29
- )
30
-
31
-
32
- class TatoebaChallenge(GeneratorBasedBuilder):
33
- """Tatoeba challenge dataset."""
34
-
35
- BUILDER_CONFIG_CLASS = TatoebaChallengeConfig
36
- BUILDER_CONFIGS = [
37
- TatoebaChallengeConfig(name="chv-eng", version="2023-09-26"),
38
- TatoebaChallengeConfig(name="chv-rus", version="2023-09-26"),
39
- ]
40
-
41
- def _info(self) -> DatasetInfo:
42
- src, trg = self.config.name.split("-")
43
- return DatasetInfo(
44
- description="""
45
- The Tatoeba Translation Challenge.
46
- You can find more about the data here: https://github.com/Helsinki-NLP/Tatoeba-Challenge
47
-
48
- Here we have only Chuvash-English subset.
49
- We do not use official dataset https://huggingface.co/datasets/Helsinki-NLP/tatoeba_mt
50
- here because chv-eng of the dataset contains only test split.
51
- """,
52
- features=Features(
53
- {
54
- "id": Value("string"),
55
- src: Value("string"),
56
- trg: Value("string"),
57
- }
58
- ),
59
- supervised_keys=None,
60
- homepage="https://github.com/Helsinki-NLP/Tatoeba-Challenge",
61
- citation="""
62
- @inproceedings{tiedemann-2020-tatoeba,
63
- title = "The {T}atoeba {T}ranslation {C}hallenge {--} {R}ealistic Data Sets for Low Resource and Multilingual {MT}",
64
- author = {Tiedemann, J{\"o}rg},
65
- booktitle = "Proceedings of the Fifth Conference on Machine Translation",
66
- month = nov,
67
- year = "2020",
68
- address = "Online",
69
- publisher = "Association for Computational Linguistics",
70
- url = "https://www.aclweb.org/anthology/2020.wmt-1.139",
71
- pages = "1174--1182"
72
- }
73
- """,
74
- )
75
-
76
- def _split_generators(
77
- self, dl_manager: Union[DownloadManager, StreamingDownloadManager]
78
- ):
79
- dl_dir = dl_manager.download_and_extract(self.config.data_url)
80
- assert isinstance(dl_dir, str)
81
-
82
- path_to_folder = (
83
- Path(dl_dir)
84
- / "data"
85
- / "release"
86
- / f"v{self.config.version_str}"
87
- / self.config.name
88
- )
89
- return [
90
- SplitGenerator(
91
- name=Split.TRAIN._name,
92
- gen_kwargs={
93
- "langs": path_to_folder / "train.id.gz",
94
- "src": path_to_folder / "train.src.gz",
95
- "trg": path_to_folder / "train.trg.gz",
96
- },
97
- ),
98
- SplitGenerator(
99
- name=Split.TEST._name,
100
- gen_kwargs={
101
- "langs": path_to_folder / "test.id",
102
- "src": path_to_folder / "test.src",
103
- "trg": path_to_folder / "test.trg",
104
- },
105
- ),
106
- ]
107
-
108
- def _generate_examples(self, langs: Path, src: Path, trg: Path):
109
- if langs.suffix == ".gz":
110
- assert src.suffix == trg.suffix
111
- assert trg.suffix == langs.suffix
112
-
113
- opener = gzip.open
114
- else:
115
- opener = open
116
-
117
- with opener(langs, "rb") as langs_src:
118
- with opener(src, "rb") as src_src:
119
- with opener(trg, "rb") as trg_src:
120
- for id_, (langs_line, src_line, trg_line) in enumerate(
121
- zip(langs_src, src_src, trg_src)
122
- ):
123
- langs_row = langs_line.decode("utf8").strip().split("\t")
124
- # train contains 3 symbols
125
- if len(langs_row) == 3:
126
- _, src_lang, trg_lang = langs_row
127
- else:
128
- src_lang, trg_lang = langs_row
129
-
130
- yield (
131
- id_,
132
- {
133
- "id": id_,
134
- src_lang: src_line.decode("utf8").strip(),
135
- trg_lang: trg_line.decode("utf8").strip(),
136
- },
137
- )