Commit ·
39aebbf
0
Parent(s):
Duplicate from Helsinki-NLP/open_subtitles
Browse filesCo-authored-by: Parquet-converter (BOT) <parquet-converter@users.noreply.huggingface.co>
- .gitattributes +27 -0
- README.md +457 -0
- open_subtitles.py +161 -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,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
annotations_creators:
|
| 3 |
+
- found
|
| 4 |
+
language_creators:
|
| 5 |
+
- found
|
| 6 |
+
language:
|
| 7 |
+
- af
|
| 8 |
+
- ar
|
| 9 |
+
- bg
|
| 10 |
+
- bn
|
| 11 |
+
- br
|
| 12 |
+
- bs
|
| 13 |
+
- ca
|
| 14 |
+
- cs
|
| 15 |
+
- da
|
| 16 |
+
- de
|
| 17 |
+
- el
|
| 18 |
+
- en
|
| 19 |
+
- eo
|
| 20 |
+
- es
|
| 21 |
+
- et
|
| 22 |
+
- eu
|
| 23 |
+
- fa
|
| 24 |
+
- fi
|
| 25 |
+
- fr
|
| 26 |
+
- gl
|
| 27 |
+
- he
|
| 28 |
+
- hi
|
| 29 |
+
- hr
|
| 30 |
+
- hu
|
| 31 |
+
- hy
|
| 32 |
+
- id
|
| 33 |
+
- is
|
| 34 |
+
- it
|
| 35 |
+
- ja
|
| 36 |
+
- ka
|
| 37 |
+
- kk
|
| 38 |
+
- ko
|
| 39 |
+
- lt
|
| 40 |
+
- lv
|
| 41 |
+
- mk
|
| 42 |
+
- ml
|
| 43 |
+
- ms
|
| 44 |
+
- nl
|
| 45 |
+
- 'no'
|
| 46 |
+
- pl
|
| 47 |
+
- pt
|
| 48 |
+
- ro
|
| 49 |
+
- ru
|
| 50 |
+
- si
|
| 51 |
+
- sk
|
| 52 |
+
- sl
|
| 53 |
+
- sq
|
| 54 |
+
- sr
|
| 55 |
+
- sv
|
| 56 |
+
- ta
|
| 57 |
+
- te
|
| 58 |
+
- th
|
| 59 |
+
- tl
|
| 60 |
+
- tr
|
| 61 |
+
- uk
|
| 62 |
+
- ur
|
| 63 |
+
- vi
|
| 64 |
+
- zh
|
| 65 |
+
language_bcp47:
|
| 66 |
+
- pt-BR
|
| 67 |
+
- ze-EN
|
| 68 |
+
- ze-ZH
|
| 69 |
+
- zh-CN
|
| 70 |
+
- zh-TW
|
| 71 |
+
license:
|
| 72 |
+
- unknown
|
| 73 |
+
multilinguality:
|
| 74 |
+
- multilingual
|
| 75 |
+
size_categories:
|
| 76 |
+
- 10K<n<100K
|
| 77 |
+
- 1M<n<10M
|
| 78 |
+
- n<1K
|
| 79 |
+
source_datasets:
|
| 80 |
+
- original
|
| 81 |
+
task_categories:
|
| 82 |
+
- translation
|
| 83 |
+
task_ids: []
|
| 84 |
+
paperswithcode_id: opensubtitles
|
| 85 |
+
pretty_name: OpenSubtitles
|
| 86 |
+
dataset_info:
|
| 87 |
+
- config_name: bs-eo
|
| 88 |
+
features:
|
| 89 |
+
- name: id
|
| 90 |
+
dtype: string
|
| 91 |
+
- name: meta
|
| 92 |
+
struct:
|
| 93 |
+
- name: year
|
| 94 |
+
dtype: uint32
|
| 95 |
+
- name: imdbId
|
| 96 |
+
dtype: uint32
|
| 97 |
+
- name: subtitleId
|
| 98 |
+
struct:
|
| 99 |
+
- name: bs
|
| 100 |
+
dtype: uint32
|
| 101 |
+
- name: eo
|
| 102 |
+
dtype: uint32
|
| 103 |
+
- name: sentenceIds
|
| 104 |
+
struct:
|
| 105 |
+
- name: bs
|
| 106 |
+
sequence: uint32
|
| 107 |
+
- name: eo
|
| 108 |
+
sequence: uint32
|
| 109 |
+
- name: translation
|
| 110 |
+
dtype:
|
| 111 |
+
translation:
|
| 112 |
+
languages:
|
| 113 |
+
- bs
|
| 114 |
+
- eo
|
| 115 |
+
splits:
|
| 116 |
+
- name: train
|
| 117 |
+
num_bytes: 1204266
|
| 118 |
+
num_examples: 10989
|
| 119 |
+
download_size: 333050
|
| 120 |
+
dataset_size: 1204266
|
| 121 |
+
- config_name: fr-hy
|
| 122 |
+
features:
|
| 123 |
+
- name: id
|
| 124 |
+
dtype: string
|
| 125 |
+
- name: meta
|
| 126 |
+
struct:
|
| 127 |
+
- name: year
|
| 128 |
+
dtype: uint32
|
| 129 |
+
- name: imdbId
|
| 130 |
+
dtype: uint32
|
| 131 |
+
- name: subtitleId
|
| 132 |
+
struct:
|
| 133 |
+
- name: fr
|
| 134 |
+
dtype: uint32
|
| 135 |
+
- name: hy
|
| 136 |
+
dtype: uint32
|
| 137 |
+
- name: sentenceIds
|
| 138 |
+
struct:
|
| 139 |
+
- name: fr
|
| 140 |
+
sequence: uint32
|
| 141 |
+
- name: hy
|
| 142 |
+
sequence: uint32
|
| 143 |
+
- name: translation
|
| 144 |
+
dtype:
|
| 145 |
+
translation:
|
| 146 |
+
languages:
|
| 147 |
+
- fr
|
| 148 |
+
- hy
|
| 149 |
+
splits:
|
| 150 |
+
- name: train
|
| 151 |
+
num_bytes: 132450
|
| 152 |
+
num_examples: 668
|
| 153 |
+
download_size: 41861
|
| 154 |
+
dataset_size: 132450
|
| 155 |
+
- config_name: da-ru
|
| 156 |
+
features:
|
| 157 |
+
- name: id
|
| 158 |
+
dtype: string
|
| 159 |
+
- name: meta
|
| 160 |
+
struct:
|
| 161 |
+
- name: year
|
| 162 |
+
dtype: uint32
|
| 163 |
+
- name: imdbId
|
| 164 |
+
dtype: uint32
|
| 165 |
+
- name: subtitleId
|
| 166 |
+
struct:
|
| 167 |
+
- name: da
|
| 168 |
+
dtype: uint32
|
| 169 |
+
- name: ru
|
| 170 |
+
dtype: uint32
|
| 171 |
+
- name: sentenceIds
|
| 172 |
+
struct:
|
| 173 |
+
- name: da
|
| 174 |
+
sequence: uint32
|
| 175 |
+
- name: ru
|
| 176 |
+
sequence: uint32
|
| 177 |
+
- name: translation
|
| 178 |
+
dtype:
|
| 179 |
+
translation:
|
| 180 |
+
languages:
|
| 181 |
+
- da
|
| 182 |
+
- ru
|
| 183 |
+
splits:
|
| 184 |
+
- name: train
|
| 185 |
+
num_bytes: 1082649105
|
| 186 |
+
num_examples: 7543012
|
| 187 |
+
download_size: 267995167
|
| 188 |
+
dataset_size: 1082649105
|
| 189 |
+
- config_name: en-hi
|
| 190 |
+
features:
|
| 191 |
+
- name: id
|
| 192 |
+
dtype: string
|
| 193 |
+
- name: meta
|
| 194 |
+
struct:
|
| 195 |
+
- name: year
|
| 196 |
+
dtype: uint32
|
| 197 |
+
- name: imdbId
|
| 198 |
+
dtype: uint32
|
| 199 |
+
- name: subtitleId
|
| 200 |
+
struct:
|
| 201 |
+
- name: en
|
| 202 |
+
dtype: uint32
|
| 203 |
+
- name: hi
|
| 204 |
+
dtype: uint32
|
| 205 |
+
- name: sentenceIds
|
| 206 |
+
struct:
|
| 207 |
+
- name: en
|
| 208 |
+
sequence: uint32
|
| 209 |
+
- name: hi
|
| 210 |
+
sequence: uint32
|
| 211 |
+
- name: translation
|
| 212 |
+
dtype:
|
| 213 |
+
translation:
|
| 214 |
+
languages:
|
| 215 |
+
- en
|
| 216 |
+
- hi
|
| 217 |
+
splits:
|
| 218 |
+
- name: train
|
| 219 |
+
num_bytes: 13845544
|
| 220 |
+
num_examples: 93016
|
| 221 |
+
download_size: 2967295
|
| 222 |
+
dataset_size: 13845544
|
| 223 |
+
- config_name: bn-is
|
| 224 |
+
features:
|
| 225 |
+
- name: id
|
| 226 |
+
dtype: string
|
| 227 |
+
- name: meta
|
| 228 |
+
struct:
|
| 229 |
+
- name: year
|
| 230 |
+
dtype: uint32
|
| 231 |
+
- name: imdbId
|
| 232 |
+
dtype: uint32
|
| 233 |
+
- name: subtitleId
|
| 234 |
+
struct:
|
| 235 |
+
- name: bn
|
| 236 |
+
dtype: uint32
|
| 237 |
+
- name: is
|
| 238 |
+
dtype: uint32
|
| 239 |
+
- name: sentenceIds
|
| 240 |
+
struct:
|
| 241 |
+
- name: bn
|
| 242 |
+
sequence: uint32
|
| 243 |
+
- name: is
|
| 244 |
+
sequence: uint32
|
| 245 |
+
- name: translation
|
| 246 |
+
dtype:
|
| 247 |
+
translation:
|
| 248 |
+
languages:
|
| 249 |
+
- bn
|
| 250 |
+
- is
|
| 251 |
+
splits:
|
| 252 |
+
- name: train
|
| 253 |
+
num_bytes: 6371251
|
| 254 |
+
num_examples: 38272
|
| 255 |
+
download_size: 1411625
|
| 256 |
+
dataset_size: 6371251
|
| 257 |
+
config_names:
|
| 258 |
+
- bn-is
|
| 259 |
+
- bs-eo
|
| 260 |
+
- da-ru
|
| 261 |
+
- en-hi
|
| 262 |
+
- fr-hy
|
| 263 |
+
---
|
| 264 |
+
|
| 265 |
+
# Dataset Card for OpenSubtitles
|
| 266 |
+
|
| 267 |
+
## Table of Contents
|
| 268 |
+
- [Dataset Description](#dataset-description)
|
| 269 |
+
- [Dataset Summary](#dataset-summary)
|
| 270 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
| 271 |
+
- [Languages](#languages)
|
| 272 |
+
- [Dataset Structure](#dataset-structure)
|
| 273 |
+
- [Data Instances](#data-instances)
|
| 274 |
+
- [Data Fields](#data-fields)
|
| 275 |
+
- [Data Splits](#data-splits)
|
| 276 |
+
- [Dataset Creation](#dataset-creation)
|
| 277 |
+
- [Curation Rationale](#curation-rationale)
|
| 278 |
+
- [Source Data](#source-data)
|
| 279 |
+
- [Annotations](#annotations)
|
| 280 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
| 281 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
| 282 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
| 283 |
+
- [Discussion of Biases](#discussion-of-biases)
|
| 284 |
+
- [Other Known Limitations](#other-known-limitations)
|
| 285 |
+
- [Additional Information](#additional-information)
|
| 286 |
+
- [Dataset Curators](#dataset-curators)
|
| 287 |
+
- [Licensing Information](#licensing-information)
|
| 288 |
+
- [Citation Information](#citation-information)
|
| 289 |
+
- [Contributions](#contributions)
|
| 290 |
+
|
| 291 |
+
## Dataset Description
|
| 292 |
+
|
| 293 |
+
- **Homepage:** http://opus.nlpl.eu/OpenSubtitles.php
|
| 294 |
+
- **Repository:** None
|
| 295 |
+
- **Paper:** http://www.lrec-conf.org/proceedings/lrec2016/pdf/62_Paper.pdf
|
| 296 |
+
- **Leaderboard:** [More Information Needed]
|
| 297 |
+
- **Point of Contact:** [More Information Needed]
|
| 298 |
+
|
| 299 |
+
### Dataset Summary
|
| 300 |
+
|
| 301 |
+
To load a language pair which isn't part of the config, all you need to do is specify the language code as pairs.
|
| 302 |
+
You can find the valid pairs in Homepage section of Dataset Description: http://opus.nlpl.eu/OpenSubtitles.php
|
| 303 |
+
E.g.
|
| 304 |
+
|
| 305 |
+
`dataset = load_dataset("open_subtitles", lang1="fi", lang2="hi")`
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
### Supported Tasks and Leaderboards
|
| 309 |
+
|
| 310 |
+
[More Information Needed]
|
| 311 |
+
|
| 312 |
+
### Languages
|
| 313 |
+
|
| 314 |
+
The languages in the dataset are:
|
| 315 |
+
- af
|
| 316 |
+
- ar
|
| 317 |
+
- bg
|
| 318 |
+
- bn
|
| 319 |
+
- br
|
| 320 |
+
- bs
|
| 321 |
+
- ca
|
| 322 |
+
- cs
|
| 323 |
+
- da
|
| 324 |
+
- de
|
| 325 |
+
- el
|
| 326 |
+
- en
|
| 327 |
+
- eo
|
| 328 |
+
- es
|
| 329 |
+
- et
|
| 330 |
+
- eu
|
| 331 |
+
- fa
|
| 332 |
+
- fi
|
| 333 |
+
- fr
|
| 334 |
+
- gl
|
| 335 |
+
- he
|
| 336 |
+
- hi
|
| 337 |
+
- hr
|
| 338 |
+
- hu
|
| 339 |
+
- hy
|
| 340 |
+
- id
|
| 341 |
+
- is
|
| 342 |
+
- it
|
| 343 |
+
- ja
|
| 344 |
+
- ka
|
| 345 |
+
- kk
|
| 346 |
+
- ko
|
| 347 |
+
- lt
|
| 348 |
+
- lv
|
| 349 |
+
- mk
|
| 350 |
+
- ml
|
| 351 |
+
- ms
|
| 352 |
+
- nl
|
| 353 |
+
- no
|
| 354 |
+
- pl
|
| 355 |
+
- pt
|
| 356 |
+
- pt_br: Portuguese (Brazil) (pt-BR)
|
| 357 |
+
- ro
|
| 358 |
+
- ru
|
| 359 |
+
- si
|
| 360 |
+
- sk
|
| 361 |
+
- sl
|
| 362 |
+
- sq
|
| 363 |
+
- sr
|
| 364 |
+
- sv
|
| 365 |
+
- ta
|
| 366 |
+
- te
|
| 367 |
+
- th
|
| 368 |
+
- tl
|
| 369 |
+
- tr
|
| 370 |
+
- uk
|
| 371 |
+
- ur
|
| 372 |
+
- vi
|
| 373 |
+
- ze_en: English constituent of Bilingual Chinese-English (subtitles displaying two languages at once, one per line)
|
| 374 |
+
- ze_zh: Chinese constituent of Bilingual Chinese-English (subtitles displaying two languages at once, one per line)
|
| 375 |
+
- zh_cn: Simplified Chinese (zh-CN, `zh-Hans`)
|
| 376 |
+
- zh_tw: Traditional Chinese (zh-TW, `zh-Hant`)
|
| 377 |
+
|
| 378 |
+
## Dataset Structure
|
| 379 |
+
|
| 380 |
+
### Data Instances
|
| 381 |
+
|
| 382 |
+
Here are some examples of questions and facts:
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
### Data Fields
|
| 386 |
+
|
| 387 |
+
[More Information Needed]
|
| 388 |
+
|
| 389 |
+
### Data Splits
|
| 390 |
+
|
| 391 |
+
[More Information Needed]
|
| 392 |
+
|
| 393 |
+
## Dataset Creation
|
| 394 |
+
|
| 395 |
+
### Curation Rationale
|
| 396 |
+
|
| 397 |
+
[More Information Needed]
|
| 398 |
+
|
| 399 |
+
### Source Data
|
| 400 |
+
|
| 401 |
+
[More Information Needed]
|
| 402 |
+
|
| 403 |
+
#### Initial Data Collection and Normalization
|
| 404 |
+
|
| 405 |
+
[More Information Needed]
|
| 406 |
+
|
| 407 |
+
#### Who are the source language producers?
|
| 408 |
+
|
| 409 |
+
[More Information Needed]
|
| 410 |
+
|
| 411 |
+
### Annotations
|
| 412 |
+
|
| 413 |
+
[More Information Needed]
|
| 414 |
+
|
| 415 |
+
#### Annotation process
|
| 416 |
+
|
| 417 |
+
[More Information Needed]
|
| 418 |
+
|
| 419 |
+
#### Who are the annotators?
|
| 420 |
+
|
| 421 |
+
[More Information Needed]
|
| 422 |
+
|
| 423 |
+
### Personal and Sensitive Information
|
| 424 |
+
|
| 425 |
+
[More Information Needed]
|
| 426 |
+
|
| 427 |
+
## Considerations for Using the Data
|
| 428 |
+
|
| 429 |
+
### Social Impact of Dataset
|
| 430 |
+
|
| 431 |
+
[More Information Needed]
|
| 432 |
+
|
| 433 |
+
### Discussion of Biases
|
| 434 |
+
|
| 435 |
+
[More Information Needed]
|
| 436 |
+
|
| 437 |
+
### Other Known Limitations
|
| 438 |
+
|
| 439 |
+
[More Information Needed]
|
| 440 |
+
|
| 441 |
+
## Additional Information
|
| 442 |
+
|
| 443 |
+
### Dataset Curators
|
| 444 |
+
|
| 445 |
+
[More Information Needed]
|
| 446 |
+
|
| 447 |
+
### Licensing Information
|
| 448 |
+
|
| 449 |
+
[More Information Needed]
|
| 450 |
+
|
| 451 |
+
### Citation Information
|
| 452 |
+
|
| 453 |
+
[More Information Needed]
|
| 454 |
+
|
| 455 |
+
### Contributions
|
| 456 |
+
|
| 457 |
+
Thanks to [@abhishekkrthakur](https://github.com/abhishekkrthakur) for adding this dataset.
|
open_subtitles.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2020 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 |
+
|
| 16 |
+
# Lint as: python3
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_DESCRIPTION = """\
|
| 23 |
+
This is a new collection of translated movie subtitles from http://www.opensubtitles.org/.
|
| 24 |
+
|
| 25 |
+
IMPORTANT: If you use the OpenSubtitle corpus: Please, add a link to http://www.opensubtitles.org/ to your website and to your reports and publications produced with the data!
|
| 26 |
+
|
| 27 |
+
This is a slightly cleaner version of the subtitle collection using improved sentence alignment and better language checking.
|
| 28 |
+
|
| 29 |
+
62 languages, 1,782 bitexts
|
| 30 |
+
total number of files: 3,735,070
|
| 31 |
+
total number of tokens: 22.10G
|
| 32 |
+
total number of sentence fragments: 3.35G
|
| 33 |
+
"""
|
| 34 |
+
_HOMEPAGE_URL = "http://opus.nlpl.eu/OpenSubtitles.php"
|
| 35 |
+
_CITATION = """\
|
| 36 |
+
P. Lison and J. Tiedemann, 2016, OpenSubtitles2016: Extracting Large Parallel Corpora from Movie and TV Subtitles. In Proceedings of the 10th International Conference on Language Resources and Evaluation (LREC 2016)
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
_VERSION = "2018.0.0"
|
| 40 |
+
_BASE_NAME = "OpenSubtitles.{}.{}"
|
| 41 |
+
_BASE_URL = "https://object.pouta.csc.fi/OPUS-OpenSubtitles/v2018/moses/{}-{}.txt.zip"
|
| 42 |
+
|
| 43 |
+
# Please note that only few pairs are shown here. You can use config to generate data for all language pairs
|
| 44 |
+
_LANGUAGE_PAIRS = [
|
| 45 |
+
("bs", "eo"),
|
| 46 |
+
("fr", "hy"),
|
| 47 |
+
("da", "ru"),
|
| 48 |
+
("en", "hi"),
|
| 49 |
+
("bn", "is"),
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
class OpenSubtitlesConfig(datasets.BuilderConfig):
|
| 54 |
+
def __init__(self, *args, lang1=None, lang2=None, **kwargs):
|
| 55 |
+
super().__init__(
|
| 56 |
+
*args,
|
| 57 |
+
name=f"{lang1}-{lang2}",
|
| 58 |
+
**kwargs,
|
| 59 |
+
)
|
| 60 |
+
self.lang1 = lang1
|
| 61 |
+
self.lang2 = lang2
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class OpenSubtitles(datasets.GeneratorBasedBuilder):
|
| 65 |
+
BUILDER_CONFIGS = [
|
| 66 |
+
OpenSubtitlesConfig(
|
| 67 |
+
lang1=lang1,
|
| 68 |
+
lang2=lang2,
|
| 69 |
+
description=f"Translating {lang1} to {lang2} or vice versa",
|
| 70 |
+
version=datasets.Version(_VERSION),
|
| 71 |
+
)
|
| 72 |
+
for lang1, lang2 in _LANGUAGE_PAIRS
|
| 73 |
+
]
|
| 74 |
+
BUILDER_CONFIG_CLASS = OpenSubtitlesConfig
|
| 75 |
+
|
| 76 |
+
def _info(self):
|
| 77 |
+
return datasets.DatasetInfo(
|
| 78 |
+
description=_DESCRIPTION,
|
| 79 |
+
features=datasets.Features(
|
| 80 |
+
{
|
| 81 |
+
"id": datasets.Value("string"),
|
| 82 |
+
"meta": {
|
| 83 |
+
"year": datasets.Value("uint32"),
|
| 84 |
+
"imdbId": datasets.Value("uint32"),
|
| 85 |
+
"subtitleId": {
|
| 86 |
+
self.config.lang1: datasets.Value("uint32"),
|
| 87 |
+
self.config.lang2: datasets.Value("uint32"),
|
| 88 |
+
},
|
| 89 |
+
"sentenceIds": {
|
| 90 |
+
self.config.lang1: datasets.Sequence(datasets.Value("uint32")),
|
| 91 |
+
self.config.lang2: datasets.Sequence(datasets.Value("uint32")),
|
| 92 |
+
},
|
| 93 |
+
},
|
| 94 |
+
"translation": datasets.Translation(languages=(self.config.lang1, self.config.lang2)),
|
| 95 |
+
},
|
| 96 |
+
),
|
| 97 |
+
supervised_keys=None,
|
| 98 |
+
homepage=_HOMEPAGE_URL,
|
| 99 |
+
citation=_CITATION,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
def _split_generators(self, dl_manager):
|
| 103 |
+
def _base_url(lang1, lang2):
|
| 104 |
+
return _BASE_URL.format(lang1, lang2)
|
| 105 |
+
|
| 106 |
+
download_url = _base_url(self.config.lang1, self.config.lang2)
|
| 107 |
+
path = dl_manager.download_and_extract(download_url)
|
| 108 |
+
return [
|
| 109 |
+
datasets.SplitGenerator(
|
| 110 |
+
name=datasets.Split.TRAIN,
|
| 111 |
+
gen_kwargs={"datapath": path},
|
| 112 |
+
)
|
| 113 |
+
]
|
| 114 |
+
|
| 115 |
+
@classmethod
|
| 116 |
+
def _extract_info(cls, sentence_id):
|
| 117 |
+
# see https://github.com/huggingface/datasets/issues/1844
|
| 118 |
+
# sentence ids have the following format: en/2017/7006210/7050201.xml.gz
|
| 119 |
+
# lang/year/imdb_id/opensubtitles_id.xml.gz
|
| 120 |
+
parts = sentence_id[: -len(".xml.gz")].split("/")
|
| 121 |
+
parts.pop(0) # remove lang, we do not need it
|
| 122 |
+
|
| 123 |
+
# returns year, imdb_id, opensubtitles_id
|
| 124 |
+
return tuple(map(int, parts))
|
| 125 |
+
|
| 126 |
+
def _generate_examples(self, datapath):
|
| 127 |
+
l1, l2 = self.config.lang1, self.config.lang2
|
| 128 |
+
folder = l1 + "-" + l2
|
| 129 |
+
l1_file = _BASE_NAME.format(folder, l1)
|
| 130 |
+
l2_file = _BASE_NAME.format(folder, l2)
|
| 131 |
+
ids_file = _BASE_NAME.format(folder, "ids")
|
| 132 |
+
l1_path = os.path.join(datapath, l1_file)
|
| 133 |
+
l2_path = os.path.join(datapath, l2_file)
|
| 134 |
+
ids_path = os.path.join(datapath, ids_file)
|
| 135 |
+
with open(l1_path, encoding="utf-8") as f1, open(l2_path, encoding="utf-8") as f2, open(
|
| 136 |
+
ids_path, encoding="utf-8"
|
| 137 |
+
) as f3:
|
| 138 |
+
for sentence_counter, (x, y, _id) in enumerate(zip(f1, f2, f3)):
|
| 139 |
+
x = x.strip()
|
| 140 |
+
y = y.strip()
|
| 141 |
+
l1_id, l2_id, l1_sid, l2_sid = _id.split("\t")
|
| 142 |
+
year, imdb_id, l1_subtitle_id = self._extract_info(l1_id)
|
| 143 |
+
_, _, l2_subtitle_id = self._extract_info(l2_id)
|
| 144 |
+
l1_sentence_ids = list(map(int, l1_sid.split(" ")))
|
| 145 |
+
l2_sentence_ids = list(map(int, l2_sid.split(" ")))
|
| 146 |
+
|
| 147 |
+
result = (
|
| 148 |
+
sentence_counter,
|
| 149 |
+
{
|
| 150 |
+
"id": str(sentence_counter),
|
| 151 |
+
"meta": {
|
| 152 |
+
"year": year,
|
| 153 |
+
"imdbId": imdb_id,
|
| 154 |
+
"subtitleId": {l1: l1_subtitle_id, l2: l2_subtitle_id},
|
| 155 |
+
"sentenceIds": {l1: l1_sentence_ids, l2: l2_sentence_ids},
|
| 156 |
+
},
|
| 157 |
+
"translation": {l1: x, l2: y},
|
| 158 |
+
},
|
| 159 |
+
)
|
| 160 |
+
sentence_counter += 1
|
| 161 |
+
yield result
|