davidmezzetti commited on
Commit
9eac014
1 Parent(s): 65cbb48
Files changed (2) hide show
  1. README.md +779 -0
  2. wikipedia.py +1141 -0
README.md ADDED
@@ -0,0 +1,779 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - no-annotation
4
+ language_creators:
5
+ - crowdsourced
6
+ pretty_name: Wikipedia
7
+ paperswithcode_id: null
8
+ license:
9
+ - cc-by-sa-3.0
10
+ - gfdl
11
+ task_categories:
12
+ - text-generation
13
+ - fill-mask
14
+ task_ids:
15
+ - language-modeling
16
+ - masked-language-modeling
17
+ source_datasets:
18
+ - original
19
+ multilinguality:
20
+ - multilingual
21
+ size_categories:
22
+ - n<1K
23
+ - 1K<n<10K
24
+ - 10K<n<100K
25
+ - 100K<n<1M
26
+ - 1M<n<10M
27
+ language:
28
+ - aa
29
+ - ab
30
+ - ace
31
+ - af
32
+ - ak
33
+ - als
34
+ - am
35
+ - an
36
+ - ang
37
+ - ar
38
+ - arc
39
+ - arz
40
+ - as
41
+ - ast
42
+ - atj
43
+ - av
44
+ - ay
45
+ - az
46
+ - azb
47
+ - ba
48
+ - bar
49
+ - bcl
50
+ - be
51
+ - bg
52
+ - bh
53
+ - bi
54
+ - bjn
55
+ - bm
56
+ - bn
57
+ - bo
58
+ - bpy
59
+ - br
60
+ - bs
61
+ - bug
62
+ - bxr
63
+ - ca
64
+ - cbk
65
+ - cdo
66
+ - ce
67
+ - ceb
68
+ - ch
69
+ - cho
70
+ - chr
71
+ - chy
72
+ - ckb
73
+ - co
74
+ - cr
75
+ - crh
76
+ - cs
77
+ - csb
78
+ - cu
79
+ - cv
80
+ - cy
81
+ - da
82
+ - de
83
+ - din
84
+ - diq
85
+ - dsb
86
+ - dty
87
+ - dv
88
+ - dz
89
+ - ee
90
+ - el
91
+ - eml
92
+ - en
93
+ - eo
94
+ - es
95
+ - et
96
+ - eu
97
+ - ext
98
+ - fa
99
+ - ff
100
+ - fi
101
+ - fj
102
+ - fo
103
+ - fr
104
+ - frp
105
+ - frr
106
+ - fur
107
+ - fy
108
+ - ga
109
+ - gag
110
+ - gan
111
+ - gd
112
+ - gl
113
+ - glk
114
+ - gn
115
+ - gom
116
+ - gor
117
+ - got
118
+ - gu
119
+ - gv
120
+ - ha
121
+ - hak
122
+ - haw
123
+ - he
124
+ - hi
125
+ - hif
126
+ - ho
127
+ - hr
128
+ - hsb
129
+ - ht
130
+ - hu
131
+ - hy
132
+ - ia
133
+ - id
134
+ - ie
135
+ - ig
136
+ - ii
137
+ - ik
138
+ - ilo
139
+ - inh
140
+ - io
141
+ - is
142
+ - it
143
+ - iu
144
+ - ja
145
+ - jam
146
+ - jbo
147
+ - jv
148
+ - ka
149
+ - kaa
150
+ - kab
151
+ - kbd
152
+ - kbp
153
+ - kg
154
+ - ki
155
+ - kj
156
+ - kk
157
+ - kl
158
+ - km
159
+ - kn
160
+ - ko
161
+ - koi
162
+ - krc
163
+ - ks
164
+ - ksh
165
+ - ku
166
+ - kv
167
+ - kw
168
+ - ky
169
+ - la
170
+ - lad
171
+ - lb
172
+ - lbe
173
+ - lez
174
+ - lfn
175
+ - lg
176
+ - li
177
+ - lij
178
+ - lmo
179
+ - ln
180
+ - lo
181
+ - lrc
182
+ - lt
183
+ - ltg
184
+ - lv
185
+ - lzh
186
+ - mai
187
+ - mdf
188
+ - mg
189
+ - mh
190
+ - mhr
191
+ - mi
192
+ - min
193
+ - mk
194
+ - ml
195
+ - mn
196
+ - mr
197
+ - mrj
198
+ - ms
199
+ - mt
200
+ - mus
201
+ - mwl
202
+ - my
203
+ - myv
204
+ - mzn
205
+ - na
206
+ - nah
207
+ - nan
208
+ - nap
209
+ - nds
210
+ - ne
211
+ - new
212
+ - ng
213
+ - nl
214
+ - nn
215
+ - 'no'
216
+ - nov
217
+ - nrf
218
+ - nso
219
+ - nv
220
+ - ny
221
+ - oc
222
+ - olo
223
+ - om
224
+ - or
225
+ - os
226
+ - pa
227
+ - pag
228
+ - pam
229
+ - pap
230
+ - pcd
231
+ - pdc
232
+ - pfl
233
+ - pi
234
+ - pih
235
+ - pl
236
+ - pms
237
+ - pnb
238
+ - pnt
239
+ - ps
240
+ - pt
241
+ - qu
242
+ - rm
243
+ - rmy
244
+ - rn
245
+ - ro
246
+ - ru
247
+ - rue
248
+ - rup
249
+ - rw
250
+ - sa
251
+ - sah
252
+ - sat
253
+ - sc
254
+ - scn
255
+ - sco
256
+ - sd
257
+ - se
258
+ - sg
259
+ - sgs
260
+ - sh
261
+ - si
262
+ - sk
263
+ - sl
264
+ - sm
265
+ - sn
266
+ - so
267
+ - sq
268
+ - sr
269
+ - srn
270
+ - ss
271
+ - st
272
+ - stq
273
+ - su
274
+ - sv
275
+ - sw
276
+ - szl
277
+ - ta
278
+ - tcy
279
+ - tdt
280
+ - te
281
+ - tg
282
+ - th
283
+ - ti
284
+ - tk
285
+ - tl
286
+ - tn
287
+ - to
288
+ - tpi
289
+ - tr
290
+ - ts
291
+ - tt
292
+ - tum
293
+ - tw
294
+ - ty
295
+ - tyv
296
+ - udm
297
+ - ug
298
+ - uk
299
+ - ur
300
+ - uz
301
+ - ve
302
+ - vec
303
+ - vep
304
+ - vi
305
+ - vls
306
+ - vo
307
+ - vro
308
+ - wa
309
+ - war
310
+ - wo
311
+ - wuu
312
+ - xal
313
+ - xh
314
+ - xmf
315
+ - yi
316
+ - yo
317
+ - yue
318
+ - za
319
+ - zea
320
+ - zh
321
+ - zu
322
+ language_bcp47:
323
+ - nds-nl
324
+ config_names:
325
+ - 20240101.aa
326
+ - 20220101.ab
327
+ - 20240101.ace
328
+ - 20240101.ady
329
+ - 20240101.af
330
+ - 20240101.ak
331
+ - 20240101.als
332
+ - 20240101.am
333
+ - 20240101.an
334
+ - 20240101.ang
335
+ - 20240101.ar
336
+ - 20240101.arc
337
+ - 20240101.arz
338
+ - 20240101.as
339
+ - 20240101.ast
340
+ - 20240101.atj
341
+ - 20240101.av
342
+ - 20240101.ay
343
+ - 20240101.az
344
+ - 20240101.azb
345
+ - 20240101.ba
346
+ - 20240101.bar
347
+ - 20240101.bat-smg
348
+ - 20240101.bcl
349
+ - 20240101.be
350
+ - 20240101.be-x-old
351
+ - 20240101.bg
352
+ - 20240101.bh
353
+ - 20240101.bi
354
+ - 20240101.bjn
355
+ - 20240101.bm
356
+ - 20240101.bn
357
+ - 20240101.bo
358
+ - 20240101.bpy
359
+ - 20240101.br
360
+ - 20240101.bs
361
+ - 20240101.bug
362
+ - 20240101.bxr
363
+ - 20240101.ca
364
+ - 20240101.cbk-zam
365
+ - 20240101.cdo
366
+ - 20240101.ce
367
+ - 20240101.ceb
368
+ - 20240101.ch
369
+ - 20240101.cho
370
+ - 20240101.chr
371
+ - 20240101.chy
372
+ - 20240101.ckb
373
+ - 20240101.co
374
+ - 20240101.cr
375
+ - 20240101.crh
376
+ - 20240101.cs
377
+ - 20240101.csb
378
+ - 20240101.cu
379
+ - 20240101.cv
380
+ - 20240101.cy
381
+ - 20240101.da
382
+ - 20240101.de
383
+ - 20240101.din
384
+ - 20240101.diq
385
+ - 20240101.dsb
386
+ - 20240101.dty
387
+ - 20240101.dv
388
+ - 20240101.dz
389
+ - 20240101.ee
390
+ - 20240101.el
391
+ - 20240101.eml
392
+ - 20240101.en
393
+ - 20240101.eo
394
+ - 20240101.es
395
+ - 20240101.et
396
+ - 20240101.eu
397
+ - 20240101.ext
398
+ - 20240101.fa
399
+ - 20240101.ff
400
+ - 20240101.fi
401
+ - 20240101.fiu-vro
402
+ - 20240101.fj
403
+ - 20240101.fo
404
+ - 20240101.fr
405
+ - 20240101.frp
406
+ - 20240101.frr
407
+ - 20240101.fur
408
+ - 20240101.fy
409
+ - 20240101.ga
410
+ - 20240101.gag
411
+ - 20240101.gan
412
+ - 20240101.gd
413
+ - 20240101.gl
414
+ - 20240101.glk
415
+ - 20240101.gn
416
+ - 20240101.gom
417
+ - 20240101.gor
418
+ - 20240101.got
419
+ - 20240101.gu
420
+ - 20240101.gv
421
+ - 20240101.ha
422
+ - 20240101.hak
423
+ - 20240101.haw
424
+ - 20240101.he
425
+ - 20240101.hi
426
+ - 20240101.hif
427
+ - 20240101.ho
428
+ - 20240101.hr
429
+ - 20240101.hsb
430
+ - 20240101.ht
431
+ - 20240101.hu
432
+ - 20240101.hy
433
+ - 20240101.ia
434
+ - 20240101.id
435
+ - 20240101.ie
436
+ - 20240101.ig
437
+ - 20240101.ii
438
+ - 20240101.ik
439
+ - 20240101.ilo
440
+ - 20240101.inh
441
+ - 20240101.io
442
+ - 20240101.is
443
+ - 20240101.it
444
+ - 20240101.iu
445
+ - 20240101.ja
446
+ - 20240101.jam
447
+ - 20240101.jbo
448
+ - 20240101.jv
449
+ - 20240101.ka
450
+ - 20240101.kaa
451
+ - 20240101.kab
452
+ - 20240101.kbd
453
+ - 20240101.kbp
454
+ - 20240101.kg
455
+ - 20240101.ki
456
+ - 20240101.kj
457
+ - 20240101.kk
458
+ - 20240101.kl
459
+ - 20240101.km
460
+ - 20240101.kn
461
+ - 20240101.ko
462
+ - 20240101.koi
463
+ - 20240101.krc
464
+ - 20240101.ks
465
+ - 20240101.ksh
466
+ - 20240101.ku
467
+ - 20240101.kv
468
+ - 20240101.kw
469
+ - 20240101.ky
470
+ - 20240101.la
471
+ - 20240101.lad
472
+ - 20240101.lb
473
+ - 20240101.lbe
474
+ - 20240101.lez
475
+ - 20240101.lfn
476
+ - 20240101.lg
477
+ - 20240101.li
478
+ - 20240101.lij
479
+ - 20240101.lmo
480
+ - 20240101.ln
481
+ - 20240101.lo
482
+ - 20240101.lrc
483
+ - 20240101.lt
484
+ - 20240101.ltg
485
+ - 20240101.lv
486
+ - 20240101.mai
487
+ - 20240101.map-bms
488
+ - 20240101.mdf
489
+ - 20240101.mg
490
+ - 20240101.mh
491
+ - 20240101.mhr
492
+ - 20240101.mi
493
+ - 20240101.min
494
+ - 20240101.mk
495
+ - 20240101.ml
496
+ - 20240101.mn
497
+ - 20240101.mr
498
+ - 20240101.mrj
499
+ - 20240101.ms
500
+ - 20240101.mt
501
+ - 20240101.mus
502
+ - 20240101.mwl
503
+ - 20240101.my
504
+ - 20240101.myv
505
+ - 20240101.mzn
506
+ - 20240101.na
507
+ - 20240101.nah
508
+ - 20240101.nap
509
+ - 20240101.nds
510
+ - 20240101.nds-nl
511
+ - 20240101.ne
512
+ - 20240101.new
513
+ - 20240101.ng
514
+ - 20240101.nl
515
+ - 20240101.nn
516
+ - 20240101.no
517
+ - 20240101.nov
518
+ - 20240101.nrm
519
+ - 20240101.nso
520
+ - 20240101.nv
521
+ - 20240101.ny
522
+ - 20240101.oc
523
+ - 20240101.olo
524
+ - 20240101.om
525
+ - 20240101.or
526
+ - 20240101.os
527
+ - 20240101.pa
528
+ - 20240101.pag
529
+ - 20240101.pam
530
+ - 20240101.pap
531
+ - 20240101.pcd
532
+ - 20240101.pdc
533
+ - 20240101.pfl
534
+ - 20240101.pi
535
+ - 20240101.pih
536
+ - 20240101.pl
537
+ - 20240101.pms
538
+ - 20240101.pnb
539
+ - 20240101.pnt
540
+ - 20240101.ps
541
+ - 20240101.pt
542
+ - 20240101.qu
543
+ - 20240101.rm
544
+ - 20240101.rmy
545
+ - 20240101.rn
546
+ - 20240101.ro
547
+ - 20240101.roa-rup
548
+ - 20240101.roa-tara
549
+ - 20240101.ru
550
+ - 20240101.rue
551
+ - 20240101.rw
552
+ - 20240101.sa
553
+ - 20240101.sah
554
+ - 20240101.sat
555
+ - 20240101.sc
556
+ - 20240101.scn
557
+ - 20240101.sco
558
+ - 20240101.sd
559
+ - 20240101.se
560
+ - 20240101.sg
561
+ - 20240101.sh
562
+ - 20240101.si
563
+ - 20240101.simple
564
+ - 20240101.sk
565
+ - 20240101.sl
566
+ - 20240101.sm
567
+ - 20240101.sn
568
+ - 20240101.so
569
+ - 20240101.sq
570
+ - 20240101.sr
571
+ - 20240101.srn
572
+ - 20240101.ss
573
+ - 20240101.st
574
+ - 20240101.stq
575
+ - 20240101.su
576
+ - 20240101.sv
577
+ - 20240101.sw
578
+ - 20240101.szl
579
+ - 20240101.ta
580
+ - 20240101.tcy
581
+ - 20240101.te
582
+ - 20240101.tet
583
+ - 20240101.tg
584
+ - 20240101.th
585
+ - 20240101.ti
586
+ - 20240101.tk
587
+ - 20240101.tl
588
+ - 20240101.tn
589
+ - 20240101.to
590
+ - 20240101.tpi
591
+ - 20240101.tr
592
+ - 20240101.ts
593
+ - 20240101.tt
594
+ - 20240101.tum
595
+ - 20240101.tw
596
+ - 20240101.ty
597
+ - 20240101.tyv
598
+ - 20240101.udm
599
+ - 20240101.ug
600
+ - 20240101.uk
601
+ - 20240101.ur
602
+ - 20240101.uz
603
+ - 20240101.ve
604
+ - 20240101.vec
605
+ - 20240101.vep
606
+ - 20240101.vi
607
+ - 20240101.vls
608
+ - 20240101.vo
609
+ - 20240101.wa
610
+ - 20240101.war
611
+ - 20240101.wo
612
+ - 20240101.wuu
613
+ - 20240101.xal
614
+ - 20240101.xh
615
+ - 20240101.xmf
616
+ - 20240101.yi
617
+ - 20240101.yo
618
+ - 20240101.za
619
+ - 20240101.zea
620
+ - 20240101.zh
621
+ - 20240101.zh-classical
622
+ - 20240101.zh-min-nan
623
+ - 20240101.zh-yue
624
+ - 20240101.zu
625
+ ---
626
+
627
+ # Dataset Card for Wikipedia
628
+
629
+ This repo is a fork of the [olm/wikipedia](https://huggingface.co/datasets/olm/wikipedia) repo which itself is a fork of the original Hugging Face Wikipedia repo [here](https://huggingface.co/datasets/wikipedia).
630
+
631
+ This fork modifies `olm/wikipedia` to enable running on lower resourced machines. These changes have been proposed as a [PR with the olm/wikipedia project](https://huggingface.co/datasets/olm/wikipedia/discussions/6).
632
+
633
+ ## Table of Contents
634
+ - [Dataset Description](#dataset-description)
635
+ - [Dataset Summary](#dataset-summary)
636
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
637
+ - [Languages](#languages)
638
+ - [Dataset Structure](#dataset-structure)
639
+ - [Data Instances](#data-instances)
640
+ - [Data Fields](#data-fields)
641
+ - [Data Splits](#data-splits)
642
+ - [Dataset Creation](#dataset-creation)
643
+ - [Curation Rationale](#curation-rationale)
644
+ - [Source Data](#source-data)
645
+ - [Annotations](#annotations)
646
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
647
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
648
+ - [Social Impact of Dataset](#social-impact-of-dataset)
649
+ - [Discussion of Biases](#discussion-of-biases)
650
+ - [Other Known Limitations](#other-known-limitations)
651
+ - [Additional Information](#additional-information)
652
+ - [Dataset Curators](#dataset-curators)
653
+ - [Licensing Information](#licensing-information)
654
+ - [Citation Information](#citation-information)
655
+ - [Contributions](#contributions)
656
+
657
+ ## Dataset Description
658
+
659
+ - **Homepage:** [https://dumps.wikimedia.org](https://dumps.wikimedia.org)
660
+ - **Repository:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
661
+ - **Paper:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
662
+ - **Point of Contact:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
663
+
664
+ ### Dataset Summary
665
+
666
+ Wikipedia dataset containing cleaned articles of all languages. The datasets are built from the Wikipedia dump (https://dumps.wikimedia.org/) with one split per language. Each example contains the content of one full Wikipedia article with cleaning to strip markdown and unwanted sections (references, etc.).
667
+
668
+ The articles are parsed using the ``mwparserfromhell`` tool.
669
+
670
+ To load this dataset you need to install the following dependencies:
671
+
672
+ ```
673
+ pip install mwparserfromhell
674
+ ```
675
+
676
+ Then, you can load any subset of Wikipedia per language and per date this way:
677
+
678
+ ```python
679
+ from datasets import load_dataset
680
+
681
+ load_dataset("neuml/wikipedia", language="en", date="20240101")
682
+ ```
683
+
684
+ You can find the full list of languages and dates [here](https://dumps.wikimedia.org/backup-index.html).
685
+
686
+ ### Supported Tasks and Leaderboards
687
+
688
+ The dataset is generally used for Language Modeling.
689
+
690
+ ### Languages
691
+
692
+ You can find the list of languages [here](https://meta.wikimedia.org/wiki/List_of_Wikipedias).
693
+
694
+ ## Dataset Structure
695
+
696
+ ### Data Instances
697
+
698
+ An example looks as follows:
699
+
700
+ ```
701
+ {'id': '1',
702
+ 'url': 'https://simple.wikipedia.org/wiki/April',
703
+ 'title': 'April',
704
+ 'text': 'April is the fourth month...'
705
+ }
706
+ ```
707
+
708
+ ### Data Fields
709
+
710
+ The data fields are the same among all configurations:
711
+
712
+ - `id` (`str`): ID of the article.
713
+ - `url` (`str`): URL of the article.
714
+ - `title` (`str`): Title of the article.
715
+ - `text` (`str`): Text content of the article.
716
+
717
+ ### Curation Rationale
718
+
719
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
720
+
721
+ ### Source Data
722
+
723
+ #### Initial Data Collection and Normalization
724
+
725
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
726
+
727
+ #### Who are the source language producers?
728
+
729
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
730
+
731
+ ### Annotations
732
+
733
+ #### Annotation process
734
+
735
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
736
+
737
+ #### Who are the annotators?
738
+
739
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
740
+
741
+ ### Personal and Sensitive Information
742
+
743
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
744
+
745
+ ## Considerations for Using the Data
746
+
747
+ ### Social Impact of Dataset
748
+
749
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
750
+
751
+ ### Discussion of Biases
752
+
753
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
754
+
755
+ ### Other Known Limitations
756
+
757
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
758
+
759
+ ## Additional Information
760
+
761
+ ### Dataset Curators
762
+
763
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
764
+
765
+ ### Licensing Information
766
+
767
+ Most of Wikipedia's text and many of its images are co-licensed under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License)(CC BY-SA) and the [GNU Free Documentation License](https://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License)(GFDL) (unversioned, with no invariant sections, front-cover texts, or back-cover texts).
768
+
769
+ Some text has been imported only under CC BY-SA and CC BY-SA-compatible license and cannot be reused under GFDL; such text will be identified on the page footer, in the page history, or on the discussion page of the article that utilizes the text.
770
+
771
+ ### Citation Information
772
+
773
+ ```
774
+ @ONLINE{wikidump,
775
+ author = "Wikimedia Foundation",
776
+ title = "Wikimedia Downloads",
777
+ url = "https://dumps.wikimedia.org"
778
+ }
779
+ ```
wikipedia.py ADDED
@@ -0,0 +1,1141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and 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
+
16
+ # Lint as: python3
17
+ """Wikipedia dataset containing cleaned articles of all languages."""
18
+
19
+
20
+ import bz2
21
+ import codecs
22
+ import json
23
+ import os
24
+ import re
25
+ import xml.etree.cElementTree as etree
26
+
27
+ from multiprocessing import Process, Queue
28
+ from urllib.parse import quote
29
+
30
+ import datasets
31
+ import mwparserfromhell
32
+
33
+
34
+ logger = datasets.logging.get_logger(__name__)
35
+
36
+
37
+ _CITATION = """\
38
+ @ONLINE {wikidump,
39
+ author = {Wikimedia Foundation},
40
+ title = {Wikimedia Downloads},
41
+ url = {https://dumps.wikimedia.org}
42
+ }
43
+ """
44
+
45
+ _DESCRIPTION = """\
46
+ Wikipedia dataset containing cleaned articles of all languages.
47
+ The datasets are built from the Wikipedia dump
48
+ (https://dumps.wikimedia.org/) with one split per language. Each example
49
+ contains the content of one full Wikipedia article with cleaning to strip
50
+ markdown and unwanted sections (references, etc.).
51
+ """
52
+
53
+ _LICENSE = (
54
+ "This work is licensed under the Creative Commons Attribution-ShareAlike "
55
+ "3.0 Unported License. To view a copy of this license, visit "
56
+ "http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to "
57
+ "Creative Commons, PO Box 1866, Mountain View, CA 94042, USA."
58
+ )
59
+
60
+ # Source: https://en.wikipedia.org/wiki/List_of_Wikipedias (accessed 3/1/2019)
61
+ # Removed because no articles: hz.
62
+ WIKIPEDIA_LANGUAGES = [
63
+ "aa",
64
+ "ab",
65
+ "ace",
66
+ "ady",
67
+ "af",
68
+ "ak",
69
+ "als",
70
+ "am",
71
+ "an",
72
+ "ang",
73
+ "ar",
74
+ "arc",
75
+ "arz",
76
+ "as",
77
+ "ast",
78
+ "atj",
79
+ "av",
80
+ "ay",
81
+ "az",
82
+ "azb",
83
+ "ba",
84
+ "bar",
85
+ "bat-smg",
86
+ "bcl",
87
+ "be",
88
+ "be-x-old",
89
+ "bg",
90
+ "bh",
91
+ "bi",
92
+ "bjn",
93
+ "bm",
94
+ "bn",
95
+ "bo",
96
+ "bpy",
97
+ "br",
98
+ "bs",
99
+ "bug",
100
+ "bxr",
101
+ "ca",
102
+ "cbk-zam",
103
+ "cdo",
104
+ "ce",
105
+ "ceb",
106
+ "ch",
107
+ "cho",
108
+ "chr",
109
+ "chy",
110
+ "ckb",
111
+ "co",
112
+ "cr",
113
+ "crh",
114
+ "cs",
115
+ "csb",
116
+ "cu",
117
+ "cv",
118
+ "cy",
119
+ "da",
120
+ "de",
121
+ "din",
122
+ "diq",
123
+ "dsb",
124
+ "dty",
125
+ "dv",
126
+ "dz",
127
+ "ee",
128
+ "el",
129
+ "eml",
130
+ "en",
131
+ "eo",
132
+ "es",
133
+ "et",
134
+ "eu",
135
+ "ext",
136
+ "fa",
137
+ "ff",
138
+ "fi",
139
+ "fiu-vro",
140
+ "fj",
141
+ "fo",
142
+ "fr",
143
+ "frp",
144
+ "frr",
145
+ "fur",
146
+ "fy",
147
+ "ga",
148
+ "gag",
149
+ "gan",
150
+ "gd",
151
+ "gl",
152
+ "glk",
153
+ "gn",
154
+ "gom",
155
+ "gor",
156
+ "got",
157
+ "gu",
158
+ "gv",
159
+ "ha",
160
+ "hak",
161
+ "haw",
162
+ "he",
163
+ "hi",
164
+ "hif",
165
+ "ho",
166
+ "hr",
167
+ "hsb",
168
+ "ht",
169
+ "hu",
170
+ "hy",
171
+ "ia",
172
+ "id",
173
+ "ie",
174
+ "ig",
175
+ "ii",
176
+ "ik",
177
+ "ilo",
178
+ "inh",
179
+ "io",
180
+ "is",
181
+ "it",
182
+ "iu",
183
+ "ja",
184
+ "jam",
185
+ "jbo",
186
+ "jv",
187
+ "ka",
188
+ "kaa",
189
+ "kab",
190
+ "kbd",
191
+ "kbp",
192
+ "kg",
193
+ "ki",
194
+ "kj",
195
+ "kk",
196
+ "kl",
197
+ "km",
198
+ "kn",
199
+ "ko",
200
+ "koi",
201
+ "krc",
202
+ "ks",
203
+ "ksh",
204
+ "ku",
205
+ "kv",
206
+ "kw",
207
+ "ky",
208
+ "la",
209
+ "lad",
210
+ "lb",
211
+ "lbe",
212
+ "lez",
213
+ "lfn",
214
+ "lg",
215
+ "li",
216
+ "lij",
217
+ "lmo",
218
+ "ln",
219
+ "lo",
220
+ "lrc",
221
+ "lt",
222
+ "ltg",
223
+ "lv",
224
+ "mai",
225
+ "map-bms",
226
+ "mdf",
227
+ "mg",
228
+ "mh",
229
+ "mhr",
230
+ "mi",
231
+ "min",
232
+ "mk",
233
+ "ml",
234
+ "mn",
235
+ "mr",
236
+ "mrj",
237
+ "ms",
238
+ "mt",
239
+ "mus",
240
+ "mwl",
241
+ "my",
242
+ "myv",
243
+ "mzn",
244
+ "na",
245
+ "nah",
246
+ "nap",
247
+ "nds",
248
+ "nds-nl",
249
+ "ne",
250
+ "new",
251
+ "ng",
252
+ "nl",
253
+ "nn",
254
+ "no",
255
+ "nov",
256
+ "nrm",
257
+ "nso",
258
+ "nv",
259
+ "ny",
260
+ "oc",
261
+ "olo",
262
+ "om",
263
+ "or",
264
+ "os",
265
+ "pa",
266
+ "pag",
267
+ "pam",
268
+ "pap",
269
+ "pcd",
270
+ "pdc",
271
+ "pfl",
272
+ "pi",
273
+ "pih",
274
+ "pl",
275
+ "pms",
276
+ "pnb",
277
+ "pnt",
278
+ "ps",
279
+ "pt",
280
+ "qu",
281
+ "rm",
282
+ "rmy",
283
+ "rn",
284
+ "ro",
285
+ "roa-rup",
286
+ "roa-tara",
287
+ "ru",
288
+ "rue",
289
+ "rw",
290
+ "sa",
291
+ "sah",
292
+ "sat",
293
+ "sc",
294
+ "scn",
295
+ "sco",
296
+ "sd",
297
+ "se",
298
+ "sg",
299
+ "sh",
300
+ "si",
301
+ "simple",
302
+ "sk",
303
+ "sl",
304
+ "sm",
305
+ "sn",
306
+ "so",
307
+ "sq",
308
+ "sr",
309
+ "srn",
310
+ "ss",
311
+ "st",
312
+ "stq",
313
+ "su",
314
+ "sv",
315
+ "sw",
316
+ "szl",
317
+ "ta",
318
+ "tcy",
319
+ "te",
320
+ "tet",
321
+ "tg",
322
+ "th",
323
+ "ti",
324
+ "tk",
325
+ "tl",
326
+ "tn",
327
+ "to",
328
+ "tpi",
329
+ "tr",
330
+ "ts",
331
+ "tt",
332
+ "tum",
333
+ "tw",
334
+ "ty",
335
+ "tyv",
336
+ "udm",
337
+ "ug",
338
+ "uk",
339
+ "ur",
340
+ "uz",
341
+ "ve",
342
+ "vec",
343
+ "vep",
344
+ "vi",
345
+ "vls",
346
+ "vo",
347
+ "wa",
348
+ "war",
349
+ "wo",
350
+ "wuu",
351
+ "xal",
352
+ "xh",
353
+ "xmf",
354
+ "yi",
355
+ "yo",
356
+ "za",
357
+ "zea",
358
+ "zh",
359
+ "zh-classical",
360
+ "zh-min-nan",
361
+ "zh-yue",
362
+ "zu",
363
+ ]
364
+
365
+ # Source: for each Wikipedia language code (example shown for "ab"), aliases for namespaces -2 and 6 accessed via this API call:
366
+ # https://ab.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=namespacealiases|namespaces&format=json&formatversion=2 (accessed 12/21/2021)
367
+ MEDIA_ALIASES = {
368
+ "ab": ["Медиа", "Файл", "Афаил", "Амедиа", "Изображение"],
369
+ "ace": ["Beureukaih", "Gambar", "Alat", "Berkas"],
370
+ "ady": ["Медиа"],
371
+ "af": ["Lêer", "Beeld"],
372
+ "als": ["Medium", "Datei", "Bild"],
373
+ "am": ["ፋይል", "ስዕል"],
374
+ "an": ["Imachen", "Imagen"],
375
+ "ang": ["Ymele", "Biliþ"],
376
+ "ar": ["ميديا", "صورة", "وسائط", "ملف"],
377
+ "arc": ["ܠܦܦܐ", "ܡܝܕܝܐ"],
378
+ "arz": ["ميديا", "صورة", "وسائط", "ملف"],
379
+ "as": ["চিত্ৰ", "चित्र", "চিত্র", "মাধ্যম"],
380
+ "ast": ["Imaxen", "Ficheru", "Imaxe", "Archivu", "Imagen", "Medios"],
381
+ "atj": ["Tipatcimoctakewin", "Natisinahikaniwoc"],
382
+ "av": ["Медиа", "Файл", "Изображение"],
383
+ "ay": ["Medio", "Archivo", "Imagen"],
384
+ "az": ["Mediya", "Şəkil", "Fayl"],
385
+ "azb": ["رسانه", "تصویر", "مدیا", "فایل", "رسانه‌ای"],
386
+ "ba": ["Медиа", "Рәсем", "Файл", "Изображение"],
387
+ "bar": ["Medium", "Datei", "Bild"],
388
+ "bat-smg": ["Vaizdas", "Medėjė", "Abruozdielis"],
389
+ "bcl": ["Medio", "Ladawan"],
390
+ "be": ["Мультымедыя", "Файл", "Выява"],
391
+ "be-x-old": ["Мэдыя", "Файл", "Выява"],
392
+ "bg": ["Медия", "Файл", "Картинка"],
393
+ "bh": ["मीडिया", "चित्र"],
394
+ "bjn": ["Barakas", "Gambar", "Berkas"],
395
+ "bm": ["Média", "Fichier"],
396
+ "bn": ["চিত্র", "মিডিয়া"],
397
+ "bpy": ["ছবি", "মিডিয়া"],
398
+ "br": ["Skeudenn", "Restr"],
399
+ "bs": ["Mediji", "Slika", "Datoteka", "Medija"],
400
+ "bug": ["Gambar", "Berkas"],
401
+ "bxr": ["Файл", "Меди", "Изображение"],
402
+ "ca": ["Fitxer", "Imatge"],
403
+ "cbk-zam": ["Medio", "Archivo", "Imagen"],
404
+ "cdo": ["文件", "媒體", "圖像", "檔案"],
405
+ "ce": ["Хlум", "Медиа", "Сурт", "Файл", "Медйа", "Изображение"],
406
+ "ceb": ["Payl", "Medya", "Imahen"],
407
+ "ch": ["Litratu"],
408
+ "ckb": ["میدیا", "پەڕگە"],
409
+ "co": ["Immagine"],
410
+ "crh": ["Медиа", "Resim", "Файл", "Fayl", "Ресим"],
411
+ "cs": ["Soubor", "Média", "Obrázok"],
412
+ "csb": ["Òbrôzk", "Grafika"],
413
+ "cu": ["Видъ", "Ви́дъ", "Дѣло", "Срѣдьства"],
414
+ "cv": ["Медиа", "Ӳкерчĕк", "Изображение"],
415
+ "cy": ["Delwedd"],
416
+ "da": ["Billede", "Fil"],
417
+ "de": ["Medium", "Datei", "Bild"],
418
+ "din": ["Ciɛl", "Apamduööt"],
419
+ "diq": ["Medya", "Dosya"],
420
+ "dsb": ["Wobraz", "Dataja", "Bild", "Medija"],
421
+ "dty": ["चित्र", "मिडिया"],
422
+ "dv": ["ފައިލު", "މީޑިއާ", "ފައިލް"],
423
+ "el": ["Εικόνα", "Αρχείο", "Μέσο", "Μέσον"],
424
+ "eml": ["Immagine"],
425
+ "eo": ["Dosiero", "Aŭdvidaĵo"],
426
+ "es": ["Medio", "Archivo", "Imagen"],
427
+ "et": ["Pilt", "Fail", "Meedia"],
428
+ "eu": ["Irudi", "Fitxategi"],
429
+ "ext": ["Archivu", "Imagen", "Mediu"],
430
+ "fa": ["رسانه", "تصویر", "مدیا", "پرونده", "رسانه‌ای"],
431
+ "ff": ["Média", "Fichier"],
432
+ "fi": ["Kuva", "Tiedosto"],
433
+ "fiu-vro": ["Pilt", "Meediä"],
434
+ "fo": ["Miðil", "Mynd"],
435
+ "fr": ["Média", "Fichier"],
436
+ "frp": ["Émâge", "Fichiér", "Mèdia"],
437
+ "frr": ["Medium", "Datei", "Bild"],
438
+ "fur": ["Immagine", "Figure"],
439
+ "fy": ["Ofbyld"],
440
+ "ga": ["Íomhá", "Meán"],
441
+ "gag": ["Mediya", "Medya", "Resim", "Dosya", "Dosye"],
442
+ "gan": ["媒体文件", "文件", "文檔", "档案", "媒體", "图像", "圖像", "媒体", "檔案"],
443
+ "gd": ["Faidhle", "Meadhan"],
444
+ "gl": ["Imaxe", "Ficheiro", "Arquivo", "Imagem"],
445
+ "glk": ["رسانه", "تصویر", "پرونده", "فاىل", "رسانه‌ای", "مديا"],
446
+ "gn": ["Medio", "Imagen", "Ta'ãnga"],
447
+ "gom": ["माध्यम", "मिडिया", "फायल"],
448
+ "gor": ["Gambar", "Berkas"],
449
+ "got": ["𐍆𐌴𐌹𐌻𐌰"],
450
+ "gu": ["દ્રશ્ય-શ્રાવ્ય (મિડિયા)", "દ્રશ્ય-શ્રાવ્ય_(મિડિયા)", "ચિત્ર"],
451
+ "gv": ["Coadan", "Meanyn"],
452
+ "hak": ["文件", "媒體", "圖像", "檔案"],
453
+ "haw": ["Kiʻi", "Waihona", "Pāpaho"],
454
+ "he": ["תמונה", "קו", "מדיה", "קו��ץ"],
455
+ "hi": ["मीडिया", "चित्र"],
456
+ "hif": ["file", "saadhan"],
457
+ "hr": ["Mediji", "DT", "Slika", "F", "Datoteka"],
458
+ "hsb": ["Wobraz", "Dataja", "Bild"],
459
+ "ht": ["Imaj", "Fichye", "Medya"],
460
+ "hu": ["Kép", "Fájl", "Média"],
461
+ "hy": ["Պատկեր", "Մեդիա"],
462
+ "ia": ["Imagine", "Multimedia"],
463
+ "id": ["Gambar", "Berkas"],
464
+ "ig": ["Nká", "Midia", "Usòrò", "Ákwúkwó orünotu", "Ákwúkwó_orünotu"],
465
+ "ii": ["媒体文件", "文件", "档案", "图像", "媒体"],
466
+ "ilo": ["Midia", "Papeles"],
467
+ "inh": ["Медиа", "Файл", "Изображение"],
468
+ "io": ["Imajo", "Arkivo"],
469
+ "is": ["Miðill", "Mynd"],
470
+ "it": ["Immagine"],
471
+ "ja": ["メディア", "ファイル", "画像"],
472
+ "jbo": ["velsku", "datnyvei"],
473
+ "jv": ["Barkas", "Medhia", "Gambar", "Médhia"],
474
+ "ka": ["მედია", "სურათი", "ფაილი"],
475
+ "kaa": ["Swret", "Таспа", "سۋرەت", "Taspa", "Su'wret", "Сурет", "تاسپا"],
476
+ "kab": ["Tugna"],
477
+ "kbd": ["Медиа", "Файл"],
478
+ "kbp": ["Média", "Fichier"],
479
+ "kg": ["Fisye"],
480
+ "kk": ["Swret", "سۋرەت", "Таспа", "Taspa", "Сурет", "تاسپا"],
481
+ "kl": ["Billede", "Fiileq", "Fil"],
482
+ "km": ["ឯកសារ", "រូបភាព", "មេឌា", "មីឌា"],
483
+ "kn": ["ಚಿತ್ರ", "ಮೀಡಿಯ"],
484
+ "ko": ["미디어", "파일", "그림"],
485
+ "koi": ["Медиа", "Файл", "Изображение"],
486
+ "krc": ["Медиа", "Файл", "Изображение"],
487
+ "ks": ["میڈیا", "فَیِل"],
488
+ "ksh": ["Beld", "Meedije", "Medie", "Belld", "Medium", "Datei", "Meedijum", "Bild"],
489
+ "ku": ["میدیا", "پەڕگە", "Medya", "Wêne"],
490
+ "kv": ["Медиа", "Файл", "Изображение"],
491
+ "kw": ["Restren"],
492
+ "ky": ["Медиа", "Файл"],
493
+ "la": ["Imago", "Fasciculus"],
494
+ "lad": ["Dossia", "Medya", "Archivo", "Dosya", "Imagen", "Meddia"],
495
+ "lb": ["Fichier", "Bild"],
496
+ "lbe": ["Медиа", "Сурат", "Изображение"],
497
+ "lez": ["Медиа", "Mediya", "Файл", "Şəkil", "Изображение"],
498
+ "lfn": ["Fix"],
499
+ "li": ["Afbeelding", "Plaetje", "Aafbeilding"],
500
+ "lij": ["Immaggine", "Immagine"],
501
+ "lmo": ["Immagine", "Imàjine", "Archivi"],
502
+ "ln": ["Média", "Fichier"],
503
+ "lo": ["ສື່ອ", "ສື່", "ຮູບ"],
504
+ "lrc": ["رسانه", "تصویر", "رسانه‌ای", "جانیا", "أسگ", "ڤارئسگأر"],
505
+ "lt": ["Vaizdas", "Medija"],
506
+ "ltg": ["Medeja", "Fails"],
507
+ "lv": ["Attēls"],
508
+ "mai": ["मेडिया", "फाइल"],
509
+ "map-bms": ["Barkas", "Medhia", "Gambar", "Médhia"],
510
+ "mdf": ["Медиа", "Няйф", "Изображение"],
511
+ "mg": ["Rakitra", "Sary", "Média"],
512
+ "mhr": ["Медиа", "Файл", "Изображение"],
513
+ "min": ["Gambar", "Berkas"],
514
+ "mk": ["Податотека", "Медија", "Медиум", "Слика"],
515
+ "ml": ["പ്രമാണം", "ചി", "മീഡിയ", "പ്ര", "ചിത്രം"],
516
+ "mn": ["Медиа", "Файл", "Зураг"],
517
+ "mr": ["चित्र", "मिडिया"],
518
+ "mrj": ["Медиа", "Файл", "Изображение"],
519
+ "ms": ["Fail", "Imej"],
520
+ "mt": ["Midja", "Medja", "Stampa"],
521
+ "mwl": ["Multimédia", "Fexeiro", "Ficheiro", "Arquivo", "Imagem"],
522
+ "my": ["ဖိုင်", "မီဒီယာ"],
523
+ "myv": ["Медия", "Артовкс", "Изображение"],
524
+ "mzn": ["رسانه", "تصویر", "مه‌دیا", "مدیا", "پرونده", "رسانه‌ای"],
525
+ "nah": ["Mēdiatl", "Īxiptli", "Imagen"],
526
+ "nap": ["Fiùra", "Immagine"],
527
+ "nds": ["Datei", "Bild"],
528
+ "nds-nl": ["Ofbeelding", "Afbeelding", "Bestaand"],
529
+ "ne": ["मीडिया", "चित्र"],
530
+ "new": ["किपा", "माध्यम"],
531
+ "nl": ["Bestand", "Afbeelding"],
532
+ "nn": ["Fil", "Bilde", "Filpeikar"],
533
+ "no": ["Fil", "Medium", "Bilde"],
534
+ "nov": [],
535
+ "nrm": ["Média", "Fichier"],
536
+ "nso": ["Seswantšho"],
537
+ "nv": ["Eʼelyaaígíí"],
538
+ "oc": ["Imatge", "Fichièr", "Mèdia"],
539
+ "olo": ["Kuva", "Medii", "Failu"],
540
+ "or": ["ମାଧ୍ୟମ", "ଫାଇଲ"],
541
+ "os": ["Ныв", "Медиа", "Файл", "Изображение"],
542
+ "pa": ["ਤਸਵੀਰ", "ਮੀਡੀਆ"],
543
+ "pcd": ["Média", "Fichier"],
544
+ "pdc": ["Medium", "Datei", "Bild", "Feil"],
545
+ "pfl": ["Dadai", "Medium", "Datei", "Bild"],
546
+ "pi": ["मीडिया", "पटिमा"],
547
+ "pl": ["Plik", "Grafika"],
548
+ "pms": ["Figura", "Immagine"],
549
+ "pnb": ["میڈیا", "تصویر", "فائل"],
550
+ "pnt": ["Εικόνα", "Αρχείον", "Εικόναν", "Μέσον"],
551
+ "ps": ["انځور", "رسنۍ", "دوتنه"],
552
+ "pt": ["Multimédia", "Ficheiro", "Arquivo", "Imagem"],
553
+ "qu": ["Midya", "Imagen", "Rikcha"],
554
+ "rm": ["Multimedia", "Datoteca"],
555
+ "rmy": ["Fişier", "Mediya", "Chitro", "Imagine"],
556
+ "ro": ["Fişier", "Imagine", "Fișier"],
557
+ "roa-rup": ["Fişier", "Imagine", "Fișier"],
558
+ "roa-tara": ["Immagine"],
559
+ "ru": ["Медиа", "Файл", "Изображение"],
560
+ "rue": ["Медіа", "Медиа", "Файл", "Изображение", "Зображення"],
561
+ "rw": ["Dosiye", "Itangazamakuru"],
562
+ "sa": ["चित्रम्", "माध्यमम्", "सञ्चिका", "माध्यम", "चित्रं"],
563
+ "sah": ["Миэдьийэ", "Ойуу", "Билэ", "Изображение"],
564
+ "sat": ["ᱨᱮᱫ", "ᱢᱤᱰᱤᱭᱟ"],
565
+ "sc": ["Immàgini"],
566
+ "scn": ["Immagine", "Mmàggini", "Mèdia"],
567
+ "sd": ["عڪس", "ذريعات", "فائل"],
568
+ "se": ["Fiila"],
569
+ "sg": ["Média", "Fichier"],
570
+ "sh": ["Mediji", "Slika", "Медија", "Datoteka", "Medija", "Слика"],
571
+ "si": ["රූපය", "මාධ්‍යය", "ගොනුව"],
572
+ "sk": ["Súbor", "Obrázok", "Médiá"],
573
+ "sl": ["Slika", "Datoteka"],
574
+ "sq": ["Figura", "Skeda"],
575
+ "sr": ["Датотека", "Medij", "Slika", "Медија", "Datoteka", "Медиј", "Medija", "Слика"],
576
+ "srn": ["Afbeelding", "Gefre"],
577
+ "stq": ["Bielde", "Bild"],
578
+ "su": ["Média", "Gambar"],
579
+ "sv": ["Fil", "Bild"],
580
+ "sw": ["Faili", "Picha"],
581
+ "szl": ["Plik", "Grafika"],
582
+ "ta": ["படிமம்", "ஊடகம்"],
583
+ "tcy": ["ಮಾದ್ಯಮೊ", "ಫೈಲ್"],
584
+ "te": ["ఫైలు", "దస్త్రం", "బొమ్మ", "మీడియా"],
585
+ "tet": ["Imajen", "Arquivo", "Imagem"],
586
+ "tg": ["Акс", "Медиа"],
587
+ "th": ["ไฟล์", "สื่อ", "ภาพ"],
588
+ "ti": ["ፋይል", "ሜድያ"],
589
+ "tk": ["Faýl"],
590
+ "tl": ["Midya", "Talaksan"],
591
+ "tpi": ["Fail"],
592
+ "tr": ["Medya", "Resim", "Dosya", "Ortam"],
593
+ "tt": ["Медиа", "Рәсем", "Файл", "Räsem", "Изображение"],
594
+ "ty": ["Média", "Fichier"],
595
+ "tyv": ["Медиа", "Файл", "Изображение"],
596
+ "udm": ["Медиа", "Файл", "Суред", "Изображение"],
597
+ "ug": ["ۋاسىتە", "ھۆججەت"],
598
+ "uk": ["Медіа", "Медиа", "Файл", "Изображение", "Зображення"],
599
+ "ur": ["میڈیا", "تصویر", "وسیط", "زریعہ", "فائل", "ملف"],
600
+ "uz": ["Mediya", "Tasvir", "Fayl"],
601
+ "vec": ["Immagine", "Imàjine", "Mèdia"],
602
+ "vep": ["Pilt", "Fail"],
603
+ "vi": ["Phương_tiện", "Tập_tin", "Hình", "Tập tin", "Phương tiện"],
604
+ "vls": ["Afbeelding", "Ofbeeldienge"],
605
+ "vo": ["Ragiv", "Magod", "Nünamakanäd"],
606
+ "wa": ["Imådje"],
607
+ "war": ["Medya", "Fayl", "Paypay"],
608
+ "wo": ["Xibaarukaay", "Dencukaay"],
609
+ "wuu": ["文件", "档案", "图像", "媒体"],
610
+ "xal": ["Аһар", "Боомг", "Изображение", "Зург"],
611
+ "xmf": ["მედია", "სურათი", "ფაილი"],
612
+ "yi": ["מעדיע", "תמונה", "טעקע", "בילד"],
613
+ "yo": ["Fáìlì", "Amóhùnmáwòrán", "Àwòrán"],
614
+ "za": ["媒体文件", "文件", "档案", "图像", "媒体"],
615
+ "zea": ["Afbeelding", "Plaetje"],
616
+ "zh": ["媒体文件", "F", "文件", "媒體", "档案", "图像", "圖像", "媒体", "檔案"],
617
+ "zh-classical": ["文件", "媒體", "圖像", "檔案"],
618
+ "zh-min-nan": ["tóng-àn", "文件", "媒體", "Mûi-thé", "圖像", "檔案"],
619
+ "zh-yue": ["檔", "档", "文件", "图", "媒體", "圖", "档案", "图像", "圖像", "媒体", "檔案"],
620
+ }
621
+
622
+ # Source: for each Wikipedia language code (example shown for "ab"), aliases for namespace 14 accessed via this API call:
623
+ # https://ab.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=namespacealiases|namespaces&format=json&formatversion=2 (accessed 12/21/2021)
624
+ CAT_ALIASES = {
625
+ "ab": ["Категория", "Акатегориа"],
626
+ "ace": ["Kawan", "Kategori"],
627
+ "af": ["Kategorie"],
628
+ "ak": ["Nkyekyem"],
629
+ "als": ["Kategorie"],
630
+ "am": ["መደብ"],
631
+ "an": ["Categoría"],
632
+ "ang": ["Flocc"],
633
+ "ar": ["تصنيف"],
634
+ "arc": ["ܣܕܪܐ"],
635
+ "arz": ["تصنيف"],
636
+ "as": ["CAT", "শ্ৰেণী", "श्रेणी", "শ্রেণী"],
637
+ "ast": ["Categoría"],
638
+ "atj": ["Tipanictawin"],
639
+ "av": ["Категория"],
640
+ "ay": ["Categoría"],
641
+ "az": ["Kateqoriya"],
642
+ "azb": ["بؤلمه"],
643
+ "ba": ["Төркөм", "Категория"],
644
+ "bar": ["Kategorie"],
645
+ "bat-smg": ["Kategorija", "Kateguorėjė"],
646
+ "bcl": ["Kategorya"],
647
+ "be": ["Катэгорыя"],
648
+ "be-x-old": ["Катэгорыя"],
649
+ "bg": ["Категория"],
650
+ "bh": ["श्रेणी"],
651
+ "bjn": ["Tumbung", "Kategori"],
652
+ "bm": ["Catégorie"],
653
+ "bn": ["বিষয়শ্রেণী", "വിഭാഗം"],
654
+ "bpy": ["থাক"],
655
+ "br": ["Rummad"],
656
+ "bs": ["Kategorija"],
657
+ "bug": ["Kategori"],
658
+ "bxr": ["Категори", "Категория"],
659
+ "ca": ["Categoria"],
660
+ "cbk-zam": ["Categoría"],
661
+ "cdo": ["分類"],
662
+ "ce": ["Категори", "Тоба", "Кадегар"],
663
+ "ceb": ["Kategoriya"],
664
+ "ch": ["Katigoria"],
665
+ "ckb": ["پ", "پۆل"],
666
+ "co": ["Categoria"],
667
+ "crh": ["Категория", "Kategoriya"],
668
+ "cs": ["Kategorie"],
669
+ "csb": ["Kategòrëjô"],
670
+ "cu": ["Катигорї", "Категория", "Катигорїꙗ"],
671
+ "cv": ["Категори"],
672
+ "cy": ["Categori"],
673
+ "da": ["Kategori"],
674
+ "de": ["Kategorie"],
675
+ "din": ["Bekätakthook"],
676
+ "diq": ["Kategoriye", "Kategori"],
677
+ "dsb": ["Kategorija"],
678
+ "dty": ["श्रेणी"],
679
+ "dv": ["ޤިސްމު"],
680
+ "el": ["Κατηγορία"],
681
+ "eml": ["Categoria"],
682
+ "eo": ["Kategorio"],
683
+ "es": ["CAT", "Categoría"],
684
+ "et": ["Kategooria"],
685
+ "eu": ["Kategoria"],
686
+ "ext": ["Categoría", "Categoria"],
687
+ "fa": ["رده"],
688
+ "ff": ["Catégorie"],
689
+ "fi": ["Luokka"],
690
+ "fiu-vro": ["Katõgooria"],
691
+ "fo": ["Bólkur"],
692
+ "fr": ["Catégorie"],
693
+ "frp": ["Catègorie"],
694
+ "frr": ["Kategorie"],
695
+ "fur": ["Categorie"],
696
+ "fy": ["Kategory"],
697
+ "ga": ["Rang", "Catagóir"],
698
+ "gag": ["Kategori", "Kategoriya"],
699
+ "gan": ["分類", "分类"],
700
+ "gd": ["Roinn-seòrsa"],
701
+ "gl": ["Categoría"],
702
+ "glk": ["جرگه", "رده"],
703
+ "gn": ["Ñemohenda"],
704
+ "gom": ["वर्ग", "श्रेणी"],
705
+ "gor": ["Dalala"],
706
+ "got": ["𐌷𐌰𐌽𐍃𐌰"],
707
+ "gu": ["શ્રેણી", "CAT", "શ્રે"],
708
+ "gv": ["Ronney"],
709
+ "hak": ["分類"],
710
+ "haw": ["Māhele"],
711
+ "he": ["קטגוריה", "קט"],
712
+ "hi": ["श्र", "श्रेणी"],
713
+ "hif": ["vibhag"],
714
+ "hr": ["CT", "KT", "Kategorija"],
715
+ "hsb": ["Kategorija"],
716
+ "ht": ["Kategori"],
717
+ "hu": ["Kategória"],
718
+ "hy": ["Կատեգորիա"],
719
+ "ia": ["Categoria"],
720
+ "id": ["Kategori"],
721
+ "ie": ["Categorie"],
722
+ "ig": ["Ébéonọr", "Òtù"],
723
+ "ii": ["分类"],
724
+ "ilo": ["Kategoria"],
725
+ "inh": ["ОагӀат"],
726
+ "io": ["Kategorio"],
727
+ "is": ["Flokkur"],
728
+ "it": ["CAT", "Categoria"],
729
+ "ja": ["カテゴリ"],
730
+ "jbo": ["klesi"],
731
+ "jv": ["Kategori"],
732
+ "ka": ["კატეგორია"],
733
+ "kaa": ["Sanat", "Kategoriya", "Санат", "سانات"],
734
+ "kab": ["Taggayt"],
735
+ "kbd": ["Категория", "Категориэ"],
736
+ "kbp": ["Catégorie"],
737
+ "kg": ["Kalasi"],
738
+ "kk": ["Sanat", "Санат", "سانات"],
739
+ "kl": ["Sumut_atassuseq", "Kategori", "Sumut atassuseq"],
740
+ "km": ["ចំនាត់ថ្នាក់ក្រុម", "ចំណាត់ក្រុម", "ចំណាត់ថ្នាក់ក្រុម"],
741
+ "kn": ["ವರ್ಗ"],
742
+ "ko": ["분류"],
743
+ "koi": ["Категория"],
744
+ "krc": ["Категория"],
745
+ "ks": ["زٲژ"],
746
+ "ksh": ["Saachjropp", "Saachjrop", "Katejori", "Kategorie", "Saachjrupp", "Kattejori", "Sachjrop"],
747
+ "ku": ["Kategorî", "پۆل"],
748
+ "kv": ["Категория"],
749
+ "kw": ["Class", "Klass"],
750
+ "ky": ["Категория"],
751
+ "la": ["Categoria"],
752
+ "lad": ["Kateggoría", "Katēggoría", "Categoría"],
753
+ "lb": ["Kategorie"],
754
+ "lbe": ["Категория"],
755
+ "lez": ["Категория"],
756
+ "lfn": ["Categoria"],
757
+ "li": ["Categorie", "Kategorie"],
758
+ "lij": ["Categorîa", "Categoria"],
759
+ "lmo": ["Categuria", "Categoria"],
760
+ "ln": ["Catégorie"],
761
+ "lo": ["ໝວດ"],
762
+ "lrc": ["دأسە"],
763
+ "lt": ["Kategorija"],
764
+ "ltg": ["Kategoreja"],
765
+ "lv": ["Kategorija"],
766
+ "mai": ["CA", "श्रेणी"],
767
+ "map-bms": ["Kategori"],
768
+ "mdf": ["Категорие", "Категория"],
769
+ "mg": ["Sokajy", "Catégorie"],
770
+ "mhr": ["Категория", "Категорий"],
771
+ "min": ["Kategori"],
772
+ "mk": ["Категорија"],
773
+ "ml": ["വിഭാഗം", "വി", "വർഗ്ഗം", "വ"],
774
+ "mn": ["Ангилал"],
775
+ "mr": ["वर्ग"],
776
+ "mrj": ["Категори", "Категория"],
777
+ "ms": ["Kategori"],
778
+ "mt": ["Kategorija"],
779
+ "mwl": ["Catadorie", "Categoria"],
780
+ "my": ["ကဏ္ဍ"],
781
+ "myv": ["Категория"],
782
+ "mzn": ["رج", "رده"],
783
+ "nah": ["Neneuhcāyōtl", "Categoría"],
784
+ "nap": ["Categurìa", "Categoria"],
785
+ "nds": ["Kategorie"],
786
+ "nds-nl": ["Categorie", "Kattegerie", "Kategorie"],
787
+ "ne": ["श्रेणी"],
788
+ "new": ["पुचः"],
789
+ "nl": ["Categorie"],
790
+ "nn": ["Kategori"],
791
+ "no": ["Kategori"],
792
+ "nrm": ["Catégorie"],
793
+ "nso": ["Setensele"],
794
+ "nv": ["Tʼááłáhági_átʼéego", "Tʼááłáhági átʼéego"],
795
+ "oc": ["Categoria"],
796
+ "olo": ["Kategourii"],
797
+ "or": ["ବିଭାଗ", "ଶ୍ରେଣୀ"],
798
+ "os": ["Категори"],
799
+ "pa": ["ਸ਼੍ਰੇਣੀ"],
800
+ "pcd": ["Catégorie"],
801
+ "pdc": ["Abdeeling", "Kategorie"],
802
+ "pfl": ["Kadegorie", "Sachgrubb", "Kategorie"],
803
+ "pi": ["विभाग"],
804
+ "pl": ["Kategoria"],
805
+ "pms": ["Categorìa"],
806
+ "pnb": ["گٹھ"],
807
+ "pnt": ["Κατηγορίαν"],
808
+ "ps": ["وېشنيزه"],
809
+ "pt": ["Categoria"],
810
+ "qu": ["Katiguriya"],
811
+ "rm": ["Categoria"],
812
+ "rmy": ["Shopni"],
813
+ "ro": ["Categorie"],
814
+ "roa-rup": ["Categorie"],
815
+ "roa-tara": ["Categoria"],
816
+ "ru": ["Категория", "К"],
817
+ "rue": ["Категория", "Катеґорія"],
818
+ "rw": ["Ikiciro"],
819
+ "sa": ["वर्गः"],
820
+ "sah": ["Категория"],
821
+ "sat": ["ᱛᱷᱚᱠ"],
822
+ "sc": ["Categoria"],
823
+ "scn": ["Catigurìa"],
824
+ "sd": ["زمرو"],
825
+ "se": ["Kategoriija"],
826
+ "sg": ["Catégorie"],
827
+ "sh": ["Kategorija", "Категорија"],
828
+ "si": ["ප්‍රවර්ගය"],
829
+ "sk": ["Kategória"],
830
+ "sl": ["Kategorija"],
831
+ "sq": ["Kategoria", "Kategori"],
832
+ "sr": ["Kategorija", "Категорија"],
833
+ "srn": ["Categorie", "Guru"],
834
+ "stq": ["Kategorie"],
835
+ "su": ["Kategori"],
836
+ "sv": ["Kategori"],
837
+ "sw": ["Jamii"],
838
+ "szl": ["Kategoryjo", "Kategoria"],
839
+ "ta": ["பகுப்பு"],
840
+ "tcy": ["ವರ್ಗೊ"],
841
+ "te": ["వర్గం"],
842
+ "tet": ["Kategoría", "Kategoria"],
843
+ "tg": ["Гурӯҳ"],
844
+ "th": ["หมวดหมู่"],
845
+ "ti": ["መደብ"],
846
+ "tk": ["Kategoriýa"],
847
+ "tl": ["Kategorya", "Kaurian"],
848
+ "tpi": ["Grup"],
849
+ "tr": ["Kategori", "KAT"],
850
+ "tt": ["Төркем", "Törkem", "Категория"],
851
+ "ty": ["Catégorie"],
852
+ "tyv": ["Аңгылал", "Категория"],
853
+ "udm": ["Категория"],
854
+ "ug": ["تۈر"],
855
+ "uk": ["Категория", "Категорія"],
856
+ "ur": ["زمرہ"],
857
+ "uz": ["Turkum", "Kategoriya"],
858
+ "vec": ["Categoria"],
859
+ "vep": ["Kategorii"],
860
+ "vi": ["Thể_loại", "Thể loại"],
861
+ "vls": ["Categorie"],
862
+ "vo": ["Klad"],
863
+ "wa": ["Categoreye"],
864
+ "war": ["Kaarangay"],
865
+ "wo": ["Wàll", "Catégorie"],
866
+ "wuu": ["分类"],
867
+ "xal": ["Янз", "Әәшл"],
868
+ "xmf": ["კატეგორია"],
869
+ "yi": ["קאטעגאריע", "קאַטעגאָריע"],
870
+ "yo": ["Ẹ̀ka"],
871
+ "za": ["分类"],
872
+ "zea": ["Categorie"],
873
+ "zh": ["分类", "分類", "CAT"],
874
+ "zh-classical": ["分類", "CAT"],
875
+ "zh-min-nan": ["分類", "Lūi-pia̍t"],
876
+ "zh-yue": ["分类", "分類", "类", "類"],
877
+ }
878
+
879
+ _BASE_URL_TMPL = "https://dumps.wikimedia.org/{lang}wiki/{date}/"
880
+ _INFO_FILE = "dumpstatus.json"
881
+
882
+
883
+ _VERSION = datasets.Version("2.0.0", "")
884
+
885
+
886
+ class WikipediaConfig(datasets.BuilderConfig):
887
+ """BuilderConfig for Wikipedia."""
888
+
889
+ def __init__(self, language=None, date=None, version=_VERSION, **kwargs):
890
+ """BuilderConfig for Wikipedia.
891
+
892
+ Args:
893
+ language: string, the language code for the Wikipedia dump to use.
894
+ date: string, date of the Wikipedia dump in YYYYMMDD format. A list of
895
+ available dates can be found at https://dumps.wikimedia.org/enwiki/.
896
+ **kwargs: keyword arguments forwarded to super.
897
+ """
898
+ super().__init__(
899
+ name=f"{date}.{language}",
900
+ description=f"Wikipedia dataset for {language}, parsed from {date} dump.",
901
+ version=version,
902
+ **kwargs,
903
+ )
904
+ self.date = date
905
+ self.language = language
906
+
907
+
908
+ _DATE = "20240101"
909
+ _COMPLETE = 1
910
+
911
+ class Wikipedia(datasets.GeneratorBasedBuilder):
912
+ """Wikipedia dataset."""
913
+
914
+ # Use mirror (your.org) to avoid download caps.
915
+ BUILDER_CONFIG_CLASS = WikipediaConfig
916
+ BUILDER_CONFIGS = [
917
+ WikipediaConfig(
918
+ language=lang,
919
+ date=_DATE,
920
+ ) # pylint:disable=g-complex-comprehension
921
+ for lang in WIKIPEDIA_LANGUAGES
922
+ ]
923
+
924
+ def _info(self):
925
+ return datasets.DatasetInfo(
926
+ description=_DESCRIPTION,
927
+ features=datasets.Features(
928
+ {
929
+ "id": datasets.Value("string"),
930
+ "url": datasets.Value("string"),
931
+ "title": datasets.Value("string"),
932
+ "text": datasets.Value("string"),
933
+ }
934
+ ),
935
+ # No default supervised_keys.
936
+ supervised_keys=None,
937
+ homepage="https://dumps.wikimedia.org",
938
+ citation=_CITATION,
939
+ )
940
+
941
+ def _split_generators(self, dl_manager):
942
+ def _base_url(lang):
943
+ return _BASE_URL_TMPL.format(lang=lang.replace("-", "_"), date=self.config.date)
944
+
945
+ lang = self.config.language
946
+
947
+ info_url = _base_url(lang) + _INFO_FILE
948
+ # Use dictionary since testing mock always returns the same result.
949
+ downloaded_files = dl_manager.download_and_extract({"info": info_url})
950
+
951
+ xml_urls = []
952
+ total_bytes = 0
953
+ with open(downloaded_files["info"], encoding="utf-8") as f:
954
+ dump_info = json.load(f)
955
+ multistream_dump_info = dump_info["jobs"]["articlesmultistreamdump"]
956
+ assert (
957
+ multistream_dump_info["status"] == "done"
958
+ ), "Specified dump (%s) multistream status is not 'done': %s" % (
959
+ _base_url(lang),
960
+ multistream_dump_info["status"],
961
+ )
962
+
963
+ for fname, info in multistream_dump_info["files"].items():
964
+ if ".xml" not in fname:
965
+ continue
966
+ total_bytes += info["size"]
967
+ xml_urls.append(_base_url(lang) + fname)
968
+
969
+ # Use dictionary since testing mock always returns the same result.
970
+
971
+ # Download Wikipedia files
972
+ downloaded_files = dl_manager.download({"xml": xml_urls})
973
+
974
+ return [
975
+ datasets.SplitGenerator( # pylint:disable=g-complex-comprehension
976
+ name=datasets.Split.TRAIN, gen_kwargs={"filepaths": downloaded_files["xml"], "language": lang}
977
+ )
978
+ ]
979
+
980
+ def _generate_examples(self, filepaths, language, no_labels=False):
981
+
982
+
983
+ def _extract_content(filepath):
984
+ """Extracts article content from a single WikiMedia XML file."""
985
+ logger.info("generating examples from = %s", filepath)
986
+ f = bz2.BZ2File(filename=filepath)
987
+ # Workaround due to: https://github.com/tensorflow/tensorflow/issues/33563
988
+ utf_f = codecs.getreader("utf-8")(f)
989
+ context = etree.iterparse(utf_f, events=("end",))
990
+ for unused_event, elem in context:
991
+ if not elem.tag.endswith("page"):
992
+ continue
993
+
994
+ namespace = elem.tag[:-4]
995
+ title = elem.find(f"./{namespace}title").text
996
+ ns = elem.find(f"./{namespace}ns").text
997
+ id_ = elem.find(f"./{namespace}id").text
998
+ red_ = elem.find(f"./{namespace}redirect")
999
+
1000
+ # Filter pages that are not in the "main" namespace.
1001
+ if ns != "0":
1002
+ elem.clear()
1003
+ continue
1004
+
1005
+ raw_content = elem.find(f"./{namespace}revision/{namespace}text").text
1006
+ elem.clear()
1007
+
1008
+ # Filter redirects.
1009
+ if raw_content is None or red_ is not None:
1010
+ continue
1011
+
1012
+ yield (id_, title, raw_content)
1013
+
1014
+ def _clean_content(inputs, language):
1015
+ """Cleans raw wikicode to extract text."""
1016
+ id_, title, raw_content = inputs
1017
+ try:
1018
+ text = _parse_and_clean_wikicode(raw_content, parser=mwparserfromhell, language=language)
1019
+ except (mwparserfromhell.parser.ParserError) as e:
1020
+ logger.error("mwparserfromhell ParseError: %s", e)
1021
+ return
1022
+
1023
+ if not text:
1024
+ return
1025
+
1026
+ url = _construct_url(title, language)
1027
+
1028
+ return id_, {"id": id_, "url": url, "title": title, "text": text}
1029
+
1030
+ # Create queues, limit size of output queue
1031
+ inputs, outputs = Queue(), Queue(30000)
1032
+
1033
+ def execute(inputs, outputs):
1034
+ try:
1035
+ # Process until inputs queue is exhausted
1036
+ while not inputs.empty():
1037
+ batch, filepath = [], inputs.get()
1038
+ for obj in _extract_content(filepath):
1039
+ batch.append(_clean_content(obj, language=language))
1040
+ if len(batch) == 1024:
1041
+ outputs.put(batch)
1042
+ batch = []
1043
+
1044
+ if batch:
1045
+ outputs.put(batch)
1046
+
1047
+ finally:
1048
+ # Write message that process is complete
1049
+ outputs.put(_COMPLETE)
1050
+
1051
+ for filepath in filepaths:
1052
+ inputs.put(filepath)
1053
+
1054
+ # Start worker processes
1055
+ processes = []
1056
+ for _ in range(min(len(filepaths), os.cpu_count())):
1057
+ process = Process(target=execute, args=(inputs, outputs))
1058
+ process.start()
1059
+ processes.append(process)
1060
+
1061
+ # Read output from worker processes
1062
+ empty, complete = False, 0
1063
+ while not empty:
1064
+ # Get next result
1065
+ result = outputs.get()
1066
+
1067
+ # Mark process as complete if all workers are complete and output queue is empty
1068
+ if result == _COMPLETE:
1069
+ complete += 1
1070
+ empty = len(processes) == complete and outputs.empty()
1071
+
1072
+ elif result:
1073
+ for r in result:
1074
+ if r is not None:
1075
+ yield r
1076
+
1077
+ for process in processes:
1078
+ process.join()
1079
+
1080
+ def _parse_and_clean_wikicode(raw_content, parser, language):
1081
+ """Strips formatting and unwanted sections from raw page content."""
1082
+ wikicode = parser.parse(raw_content)
1083
+
1084
+ # Filters for magic words that are parser instructions -- e.g., __NOTOC__
1085
+ re_rm_magic = re.compile("__[A-Z]*__", flags=re.UNICODE)
1086
+
1087
+ # Filters for file/image links.
1088
+ media_prefixes = "|".join(["File", "Image", "Media"] + MEDIA_ALIASES.get(language, []))
1089
+ re_rm_wikilink = re.compile(f"^(?:{media_prefixes}):", flags=re.IGNORECASE | re.UNICODE)
1090
+
1091
+ def rm_wikilink(obj):
1092
+ return bool(re_rm_wikilink.match(str(obj.title)))
1093
+
1094
+ # Filters for references and tables
1095
+ def rm_tag(obj):
1096
+ return str(obj.tag) in {"ref", "table"}
1097
+
1098
+ # Leave category links in-place but remove the category prefixes
1099
+ cat_prefixes = "|".join(["Category"] + CAT_ALIASES.get(language, []))
1100
+ re_clean_wikilink = re.compile(f"^(?:{cat_prefixes}):", flags=re.IGNORECASE | re.UNICODE)
1101
+
1102
+ def is_category(obj):
1103
+ return bool(re_clean_wikilink.match(str(obj.title)))
1104
+
1105
+ def clean_wikilink(obj):
1106
+ text = obj.__strip__()
1107
+ text = re.sub(re_clean_wikilink, "", text)
1108
+ obj.text = text
1109
+
1110
+ def try_replace_obj(obj):
1111
+ try:
1112
+ clean_wikilink(obj)
1113
+ except ValueError:
1114
+ # For unknown reasons, objects are sometimes not found.
1115
+ pass
1116
+
1117
+ def try_remove_obj(obj, section):
1118
+ try:
1119
+ section.remove(obj)
1120
+ except ValueError:
1121
+ # For unknown reasons, objects are sometimes not found.
1122
+ pass
1123
+
1124
+ section_text = []
1125
+ # Filter individual sections to clean.
1126
+ for section in wikicode.get_sections(flat=True, include_lead=True, include_headings=True):
1127
+ for obj in section.ifilter_wikilinks(recursive=True):
1128
+ if rm_wikilink(obj):
1129
+ try_remove_obj(obj, section)
1130
+ elif is_category(obj):
1131
+ try_replace_obj(obj)
1132
+ for obj in section.ifilter_tags(matches=rm_tag, recursive=True):
1133
+ try_remove_obj(obj, section)
1134
+
1135
+ section_text.append(re.sub(re_rm_magic, "", section.strip_code().strip()))
1136
+ return "\n\n".join(section_text)
1137
+
1138
+
1139
+ def _construct_url(title, language):
1140
+ # See: https://meta.wikimedia.org/wiki/Help:URL
1141
+ return f"https://{language}.wikipedia.org/wiki/{quote(title)}"