system HF staff commited on
Commit
483791c
0 Parent(s):

Update files from the datasets library (from 1.0.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.0.0

Files changed (3) hide show
  1. .gitattributes +27 -0
  2. dataset_infos.json +1 -0
  3. wikipedia.py +563 -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
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"20200501.en": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.en", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 18330235071, "num_examples": 6078422, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/enwiki/20200501/dumpstatus.json": {"num_bytes": 478807, "checksum": "f046ece6e80477d7c063b1dd2e436031d0ee05d77bd39bf3f1921c35b9b67a1f"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream13.xml-p5040437p6197594.bz2": {"num_bytes": 432157889, "checksum": "0b8e24785dbe6ff1ab8ac3392fec59e0c6da1fa4f2b955a32a3997c5bf09da24"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream12.xml-p3926862p5040436.bz2": {"num_bytes": 437003811, "checksum": "6267a8b2bc1d1a2a211fc6e8e66586bfd36d0c68c6b56e3fae4baa4efb58e7cb"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p45663462p47163461.bz2": {"num_bytes": 267729794, "checksum": "268fb79e7756f878a3c36e5009c84299199f8b92f2f354dbec315d863473d73f"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream18.xml-p13693074p15193073.bz2": {"num_bytes": 383206414, "checksum": "b8a5bc4a563efde13a89fdb708937498530f1eac572455da4f0b6b24d4bd99f1"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream7.xml-p892913p1268691.bz2": {"num_bytes": 353877982, "checksum": "f327e612df1d0c8b8a74a8e4562beed3e0cd4d094e7e5fada3c2629ae302db2e"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream6.xml-p565314p892912.bz2": {"num_bytes": 346420373, "checksum": "39d7483882c749ba35f35506ee9bd5c01d3eeb41a82c8268a110cddc4c94c891"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream8.xml-p1268692p1791079.bz2": {"num_bytes": 388878496, "checksum": "a4a205d28d3758f2644a6b3ab703a95a4b83c617ca66f8a6ad4f9d079a549002"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p50163462p51663461.bz2": {"num_bytes": 346912679, "checksum": "74d324ceee9115cb56eb50d78cdc7658ae92ca5a85448f7adb80a5847f4a2b00"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream24.xml-p32003451p33503450.bz2": {"num_bytes": 384546851, "checksum": "c5d90e90fa953cb4e841236646fd7f618ec9ec978434383ecb0d5e02bf550091"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream19.xml-p16120543p17620542.bz2": {"num_bytes": 326372095, "checksum": "aeed86966254cd3e602be89b575562676e9c00af45b4909df0c8de37602b104e"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream23.xml-p29823661p30503450.bz2": {"num_bytes": 143250867, "checksum": "20e2f3fd4eb71f3f9eb7e36094161377d83fb570bd234a2dc8c2473867d6b040"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream17.xml-p13039267p13693073.bz2": {"num_bytes": 168301491, "checksum": "78b03a4872decc575fc74993791dd99ebde0ca0e835fae4a5eafb15fc43f1fe0"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream4.xml-p200510p352689.bz2": {"num_bytes": 291451630, "checksum": "b39b87c3dc70633cdbd475d00dfc7b0b7935e4b36595c843ee7d35ef8a44097c"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream26.xml-p42567203p42663461.bz2": {"num_bytes": 23550236, "checksum": "95d01bb3c7660106fa7e3f7339a24659f79b6a86dd5ba8fd3d2c2670cd39f064"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p62163462p63663461.bz2": {"num_bytes": 390671803, "checksum": "f716b5fd2b7ad03e02d186f06a4db644f1e4f7459735775f25ba0f225a458d03"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream26.xml-p41067203p42567202.bz2": {"num_bytes": 372757744, "checksum": "9951a45ec9426154c86618507ad9a7f27f5e7771a0ffbb02a3af5249a75c6c54"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream22.xml-p23927984p25427983.bz2": {"num_bytes": 390836826, "checksum": "b1b4199d24752dbd7fdbc04c04aafc75f58ddd062839996a531a1307352e7db2"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p54663462p56163461.bz2": {"num_bytes": 314984115, "checksum": "f3cb80bdd4d708a832c1e89e8c48b027e2ca0cafc1fb164db570ac1af94db619"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream20.xml-p18754736p20254735.bz2": {"num_bytes": 353524645, "checksum": "0adb9d1c753653bca91c451849978ca016c379f70d4e8a8fce3adac54e2be351"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream9.xml-p1791080p2336422.bz2": {"num_bytes": 378488615, "checksum": "e45d3e2d38ded431fd789a19c0bf061158b56256d0f1e9cdad13109341e0a70e"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream25.xml-p35452816p36952815.bz2": {"num_bytes": 371615916, "checksum": "a5a0395e9ba9727c33ab1db36f94afd19bd70244f8a1b1ec2facfad4fba74a30"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream14.xml-p6197595p7697594.bz2": {"num_bytes": 437927656, "checksum": "ba66e13a36dc000c7335789746448cc85c9b699d622f1e708d046e3b345848fa"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream17.xml-p11539267p13039266.bz2": {"num_bytes": 410595682, "checksum": "a9d93a0d4458564c061e19e639fc87ce9557e69eb9204067b76f926eacec9591"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream24.xml-p33503451p33952815.bz2": {"num_bytes": 108197798, "checksum": "e5097876890c2fc382c4e25ce17dd6d52c0ab16128ef49e3f62bd7d9f5bcefdc"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p59163462p60663461.bz2": {"num_bytes": 326281765, "checksum": "3c794a85727d9d01ad4968f9ea86964ab506a8420ef1bc670c4ef6f38c406a38"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p47163462p48663461.bz2": {"num_bytes": 334137722, "checksum": "7759f0096abdd3c63c42bb9088f70eef4a2d79c7dc6db3132815cb1c157b55c4"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p51663462p53163461.bz2": {"num_bytes": 325256423, "checksum": "9c6fe9e6ce445a16a8d7d1568ad7e9364aa5f930e1950bb60c221d7420ed7d2b"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream14.xml-p7697595p7744800.bz2": {"num_bytes": 12803584, "checksum": "5cced6a20f17fe0a7e0025f6cf68680d9c62135f989c81ebd2df00c7b7f696a0"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p60663462p62163461.bz2": {"num_bytes": 346963638, "checksum": "60643f523f0358c0c54b256eb0f5729524a0ba2c434225323cdd98998c4980bd"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p56163462p57663461.bz2": {"num_bytes": 357290829, "checksum": "b6000c8db723d9953a9ab5620be1991bd6e62072d0f231fa1f44e6953d442415"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream22.xml-p25427984p26823660.bz2": {"num_bytes": 337962180, "checksum": "17061886cc9ced88fe90123859957c9784ae932d13f07f40047e41cb518485b7"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream25.xml-p33952816p35452815.bz2": {"num_bytes": 345406966, "checksum": "4c0f63d0eade96fa957477e807a95e3aa7288d3fff597bbfb3dda86193ddb61b"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p42663462p44163461.bz2": {"num_bytes": 376912048, "checksum": "29d4b2fc5fd15aa7ddb0a6f677b48e4eb1ddf8f047918501006a9a2cbcabf068"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream5.xml-p352690p565313.bz2": {"num_bytes": 319348574, "checksum": "57002ded46a15cf795a6ccecd1553fe79deb1a95585e95b589c22f1953227dd9"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream19.xml-p17620543p18754735.bz2": {"num_bytes": 264976948, "checksum": "6207ab0d0b5e9ed0c0e396723043c90b9c4cfa918dc2b50dbcfc34e1108342ee"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream23.xml-p26823661p28323660.bz2": {"num_bytes": 366885989, "checksum": "e73bcac9202f8e8fdd97b9766bbcbdedeb60c860deda63b41670ee370c57d826"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream10.xml-p2336423p3046512.bz2": {"num_bytes": 398910177, "checksum": "e20304b090d9a41da70a33799ec06a5344f8fe08dc30392b11eaa13e33c59cf8"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p57663462p59163461.bz2": {"num_bytes": 331691753, "checksum": "1ba2f8a762e6b28a8f805652fa595e69b5e20d70265394a7e59750efda4f2d24"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream23.xml-p28323661p29823660.bz2": {"num_bytes": 318835981, "checksum": "814e884b3d87e7b8c57c9840b69d9a98b589c972b4bb3351620bd9b767e08ecc"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream26.xml-p38067203p39567202.bz2": {"num_bytes": 374965429, "checksum": "fbb73166eaf5c8ef88baa7c1d6577ad232e5c6658e15804332eb74ac90b9ad41"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream26.xml-p39567203p41067202.bz2": {"num_bytes": 366325481, "checksum": "7a99125a43281489b29b728c0daab7fb73d2031616c5a4b3a2193aaf5e500a01"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream15.xml-p9244801p9518048.bz2": {"num_bytes": 68534882, "checksum": "a09422636e5271fd0a05d796be298c07ebed6fdef77c63f395726a5c63cbb4ba"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream21.xml-p22722157p23927983.bz2": {"num_bytes": 323714388, "checksum": "badef857bb043433267bc96b6c97decbf100d419272cd8199771be5a19f33a8e"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p48663462p50163461.bz2": {"num_bytes": 320585303, "checksum": "3dd1ab0634976d4683a085dc8e979ae88d25c78b92bca0ac37d46382b2348a5b"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream25.xml-p36952816p38067202.bz2": {"num_bytes": 262941763, "checksum": "cf5d33a872e70ff102171565546ec75f0ebf12a0b4fc185d3eb15bd0a18bb3d1"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream11.xml-p3046513p3926861.bz2": {"num_bytes": 420893917, "checksum": "6f8d2061c4a3f956e21ca259e5b882f1787b09c0964cac98f1d6892fa4d9eeac"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream16.xml-p9518049p11018048.bz2": {"num_bytes": 340863364, "checksum": "d495e5a1edafc817b1cacd733fae19ac1c228387535df99427f24405418f47ed"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p63663462p63833989.bz2": {"num_bytes": 39689667, "checksum": "905a94841f45903adad4ca4fd8df7f136b02b5c2ac4c2dd6da8e0d97856c1ae7"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream3.xml-p88445p200509.bz2": {"num_bytes": 286257431, "checksum": "6d86fc63984e1717029ab5b90e27c3374b16326234bc085a2743ca0b12a05430"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream24.xml-p30503451p32003450.bz2": {"num_bytes": 403564528, "checksum": "a2b76400d4fbed82437b1f5f94a618824533ff795be934688bd1172dcd55d213"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream2.xml-p30304p88444.bz2": {"num_bytes": 221557438, "checksum": "8496afb6b437b4426d1aa9744eb9c3c45e2d672c499a33bdddb592806297ee0e"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream1.xml-p1p30303.bz2": {"num_bytes": 186241262, "checksum": "07419f309994db13575869f3dd0ce1c18d6a46bd41933f50504a7583c4c84c19"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p44163462p45663461.bz2": {"num_bytes": 333033392, "checksum": "c9cf58069982f0760492cbfc1aff758764122fc70ec0431d9620eaa5a678acf3"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream15.xml-p7744801p9244800.bz2": {"num_bytes": 413095403, "checksum": "e127ca4371262a554e6118496e3ace1cc366bc4c57eff426cc998419772a10a6"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream16.xml-p11018049p11539266.bz2": {"num_bytes": 130729249, "checksum": "ca5d899b2041e2ad940d36e6d23edefc79c682d5e1760d4e0cf75940f9da74ee"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream20.xml-p20254736p21222156.bz2": {"num_bytes": 226580160, "checksum": "6e4dc1d5fa340bdfa62fe06c9b4f35816904a41e660fcea2b031147bf304b628"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream18.xml-p15193074p16120542.bz2": {"num_bytes": 215782188, "checksum": "646c01afe93bc1cbefe397ec9b3df281665d533d3e0f6a6a7cb964a039c738d9"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream27.xml-p53163462p54663461.bz2": {"num_bytes": 350761215, "checksum": "0faa7af015dd867fc8c79819aa265b58decd992a23e211a429a793f12f3e4457"}, "https://dumps.wikimedia.org/enwiki/20200501/enwiki-20200501-pages-articles-multistream21.xml-p21222157p22722156.bz2": {"num_bytes": 367798357, "checksum": "d8761b57ad7a3aac115d7ae608b8e10f0f1b76418340afc58b1bdcec2e0a2669"}}, "download_size": 18241319609, "dataset_size": 18330235071, "size_in_bytes": 36571554680}, "20200501.fr": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.fr", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 6482545638, "num_examples": 2210508, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/frwiki/20200501/dumpstatus.json": {"num_bytes": 99176, "checksum": "5d84244b65522df8716de523e16d3f72b384656b73410c0bd4801b00677387c8"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream6.xml-p8994129p10494128.bz2": {"num_bytes": 393133190, "checksum": "27fd49730b4a5fef166b84f1711037d3a829e5961e4f3945935d34ca46ec47c3"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream3.xml-p927546p2427545.bz2": {"num_bytes": 591357746, "checksum": "fda45ab766b507a1e28cc23a6e3fe25c44117d82ea5c89ecdb669c50c37d2d45"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream5.xml-p6092356p7494128.bz2": {"num_bytes": 454006861, "checksum": "6ef325bca0fd4ce9bb2f34216a923cf0be89c4e557b366cd873d84e809141372"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream3.xml-p2427546p2516881.bz2": {"num_bytes": 28169559, "checksum": "3cc6fcca4429e3d259d1f22b4127def489c7cafcd2552a9a4610bcc184723cdc"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream6.xml-p11994129p13301475.bz2": {"num_bytes": 363949982, "checksum": "7fed0c6263fe1818f1393bd317b51bf9f8ddb354f231969fbd98acdab2df27a2"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream4.xml-p4016882p4592355.bz2": {"num_bytes": 196679589, "checksum": "7d525e351ef4f17ed3311594b44730cc0b6f8a007aa5b812013353fb264725ab"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream2.xml-p275788p927545.bz2": {"num_bytes": 549288514, "checksum": "6c930cd89769506ac633474c23fcd947328de111d5143140e4ee419054838001"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream6.xml-p10494129p11994128.bz2": {"num_bytes": 389622504, "checksum": "978275442fce8746aec57050749d27eee8a141f3d169c5e1260e88d0daf1108d"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream4.xml-p2516882p4016881.bz2": {"num_bytes": 528931899, "checksum": "977fbe8792b6dc2fbb75fb255f8c4468c126afefd54ceec084271b4a8ef8bcde"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream5.xml-p4592356p6092355.bz2": {"num_bytes": 542749895, "checksum": "38089ddb2eb7d54cba1240a97940a962ff56705f6844d75e71229979037185d7"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream6.xml-p7494129p8994128.bz2": {"num_bytes": 341534465, "checksum": "25a8c87a1aab04a9578c74d391ec8d09a678d65cacd2e64d089a507bb1a46c21"}, "https://dumps.wikimedia.org/frwiki/20200501/frwiki-20200501-pages-articles-multistream1.xml-p1p275787.bz2": {"num_bytes": 500077878, "checksum": "ae1326aa0d690e388b05ab4a40eb2cdf8c07b1ee398baffecfaa5163d7181e2f"}}, "download_size": 4879601258, "dataset_size": 6482545638, "size_in_bytes": 11362146896}, "20200501.frr": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.frr", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 6165872, "num_examples": 11803, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/frrwiki/20200501/dumpstatus.json": {"num_bytes": 11002, "checksum": "3135da62aecdd6e396f2e8e534df31094a8ef876eacdb8a8764d241fc9c94b4a"}, "https://dumps.wikimedia.org/frrwiki/20200501/frrwiki-20200501-pages-articles-multistream.xml.bz2": {"num_bytes": 9476441, "checksum": "909fe94f9158fb32f288cb7bc5c7964ed050f5b60a260b0b238b89b41dbad91a"}}, "download_size": 9487443, "dataset_size": 6165872, "size_in_bytes": 15653315}, "20200501.simple": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.simple", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 189249480, "num_examples": 160949, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/simplewiki/20200501/dumpstatus.json": {"num_bytes": 11377, "checksum": "8920939251d1c9683fb8e26a8665c601a1354acb77be9335771ffa07a9fa3553"}, "https://dumps.wikimedia.org/simplewiki/20200501/simplewiki-20200501-pages-articles-multistream.xml.bz2": {"num_bytes": 186623764, "checksum": "6a55fa921827ff348a72e5dc98cf1c9c8aff26c8fbace6b64b8fc78dd36e5e83"}}, "download_size": 186635141, "dataset_size": 189249480, "size_in_bytes": 375884621}, "20200501.de": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.de", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 8091641736, "num_examples": 3140341, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/dewiki/20200501/dumpstatus.json": {"num_bytes": 113987, "checksum": "c971e73f0a4d6db3b4aeae0877f99e31b47819c8c56ea7e75c4fb62823c11048"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream2.xml-p262469p1095940.bz2": {"num_bytes": 611894545, "checksum": "7e9dcb8f133cf6d2b466ae587056dd3717aa7adfaf55f9b5b521f9f69141464f"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream1.xml-p1p262468.bz2": {"num_bytes": 475164655, "checksum": "0454ad62f74702c4324980feb97dc977c067fa51e00282c08208e076ede322ed"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream3.xml-p2595941p2920048.bz2": {"num_bytes": 130288483, "checksum": "7a62a7447a29b948fb2daac89d796f37553fabc8bf428df06eae583df9ef21ea"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream6.xml-p9842169p11277643.bz2": {"num_bytes": 799352580, "checksum": "cfd790f1f815f333f763940178cd43d1577f78e9836a6dd0f8ddf269bc07e9a3"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream5.xml-p5466276p6966275.bz2": {"num_bytes": 692216358, "checksum": "5a629ed9acef7c4b851e5a93fb68c74b223bbfc680c5f0d59daf65e9f0b86300"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream4.xml-p2920049p4420048.bz2": {"num_bytes": 609402951, "checksum": "47b9108dab34898f15f379f2b0c72c4434d21c349cb1b7a59a975cf6eee665a4"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream3.xml-p1095941p2595940.bz2": {"num_bytes": 647318033, "checksum": "229164fcef03f5c71f2234dcf9b438e9025c006429c54c1d7188dbc48efa5eac"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream4.xml-p4420049p5466275.bz2": {"num_bytes": 411951344, "checksum": "30fd55c28c8acc1ed82d4c40a990d500ccd3f3033d8de4eaa0fbff2b69789a52"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream5.xml-p6966276p8342168.bz2": {"num_bytes": 686465414, "checksum": "cb8791decc5a48865899aa8b4443eac4d3bc332d204d7d59c465d3820da40600"}, "https://dumps.wikimedia.org/dewiki/20200501/dewiki-20200501-pages-articles-multistream6.xml-p8342169p9842168.bz2": {"num_bytes": 736362001, "checksum": "5cfcbac138591069f01a640d394b249ea387f51480d70567e1e758cddff1524f"}}, "download_size": 5800530351, "dataset_size": 8091641736, "size_in_bytes": 13892172087}, "20200501.it": {"description": "Wikipedia dataset containing cleaned articles of all languages.\nThe datasets are built from the Wikipedia dump\n(https://dumps.wikimedia.org/) with one split per language. Each example\ncontains the content of one full Wikipedia article with cleaning to strip\nmarkdown and unwanted sections (references, etc.).\n", "citation": "@ONLINE {wikidump,\n author = \"Wikimedia Foundation\",\n title = \"Wikimedia Downloads\",\n url = \"https://dumps.wikimedia.org\"\n}\n", "homepage": "https://dumps.wikimedia.org", "license": "", "features": {"title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "wikipedia", "config_name": "20200501.it", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3994955896, "num_examples": 1931197, "dataset_name": "wikipedia"}}, "download_checksums": {"https://dumps.wikimedia.org/itwiki/20200501/dumpstatus.json": {"num_bytes": 67472, "checksum": "680b4afc31634172f43f5e2c563fce21f1793b734c0ca93deaef7e68171003f1"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream3.xml-p1057873p1959895.bz2": {"num_bytes": 424589476, "checksum": "a572bf5651bb97cc0f80b473241b9c201555e1ac6ffbcbe723b6ffb89c64d1e6"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream6.xml-p8013199p8444835.bz2": {"num_bytes": 128220446, "checksum": "a574b0019157d8a37034bb6746c11bf596071294bac756c4589883c912885f80"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream1.xml-p1p277091.bz2": {"num_bytes": 261171943, "checksum": "4c800cbdd646c66acabe2108097db6e2821ad72a51048b21d0d73660d0c40fdb"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream2.xml-p277092p1057872.bz2": {"num_bytes": 364658191, "checksum": "dc8efb9edd8e42e0d663c0ab1a7799b3b4eb6542f3436eae6f92dcacd31ff07d"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream5.xml-p4647943p5013198.bz2": {"num_bytes": 138073550, "checksum": "ad587cb921a8d384c1f20a03cfb2d20f4db78dca9ffbb712f2b5a99d6fa48ae0"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream6.xml-p5013199p6513198.bz2": {"num_bytes": 452495628, "checksum": "66655b6ffdc9f389d8b424d524f702eea1f481d15d519926aef3dd371aa8e83b"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream6.xml-p6513199p8013198.bz2": {"num_bytes": 269193946, "checksum": "a0802dc96c62161933382d4277a5f04f2468c4c17f09a737b6eb824b9e927e92"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream5.xml-p3147943p4647942.bz2": {"num_bytes": 577586049, "checksum": "b72c081a7115453aef231297cf7f2b3ba081e621b84997866423ca342103a141"}, "https://dumps.wikimedia.org/itwiki/20200501/itwiki-20200501-pages-articles-multistream4.xml-p1959896p3147942.bz2": {"num_bytes": 498811495, "checksum": "a70a2cb0383705fc09bc43a25fbe398ef9fc86df468b5c7bcb72ef4a0c9d7ee0"}}, "download_size": 3114868196, "dataset_size": 3994955896, "size_in_bytes": 7109824092}}
wikipedia.py ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ from __future__ import absolute_import, division, print_function
20
+
21
+ import codecs
22
+ import json
23
+ import logging
24
+ import re
25
+ import xml.etree.cElementTree as etree
26
+
27
+ import six
28
+
29
+ import datasets
30
+
31
+
32
+ if six.PY3:
33
+ import bz2 # pylint:disable=g-import-not-at-top
34
+ else:
35
+ # py2's built-in bz2 package does not support reading from file objects.
36
+ import bz2file as bz2 # pylint:disable=g-import-not-at-top
37
+
38
+ _CITATION = """\
39
+ @ONLINE {wikidump,
40
+ author = {Wikimedia Foundation},
41
+ title = {Wikimedia Downloads},
42
+ url = {https://dumps.wikimedia.org}
43
+ }
44
+ """
45
+
46
+ _DESCRIPTION = """\
47
+ Wikipedia dataset containing cleaned articles of all languages.
48
+ The datasets are built from the Wikipedia dump
49
+ (https://dumps.wikimedia.org/) with one split per language. Each example
50
+ contains the content of one full Wikipedia article with cleaning to strip
51
+ markdown and unwanted sections (references, etc.).
52
+ """
53
+
54
+ _LICENSE = (
55
+ "This work is licensed under the Creative Commons Attribution-ShareAlike "
56
+ "3.0 Unported License. To view a copy of this license, visit "
57
+ "http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to "
58
+ "Creative Commons, PO Box 1866, Mountain View, CA 94042, USA."
59
+ )
60
+
61
+ # Source: https://en.wikipedia.org/wiki/List_of_Wikipedias (accessed 3/1/2019)
62
+ # Removed because no articles: hz.
63
+ WIKIPEDIA_LANGUAGES = [
64
+ "aa",
65
+ "ab",
66
+ "ace",
67
+ "ady",
68
+ "af",
69
+ "ak",
70
+ "als",
71
+ "am",
72
+ "an",
73
+ "ang",
74
+ "ar",
75
+ "arc",
76
+ "arz",
77
+ "as",
78
+ "ast",
79
+ "atj",
80
+ "av",
81
+ "ay",
82
+ "az",
83
+ "azb",
84
+ "ba",
85
+ "bar",
86
+ "bat-smg",
87
+ "bcl",
88
+ "be",
89
+ "be-x-old",
90
+ "bg",
91
+ "bh",
92
+ "bi",
93
+ "bjn",
94
+ "bm",
95
+ "bn",
96
+ "bo",
97
+ "bpy",
98
+ "br",
99
+ "bs",
100
+ "bug",
101
+ "bxr",
102
+ "ca",
103
+ "cbk-zam",
104
+ "cdo",
105
+ "ce",
106
+ "ceb",
107
+ "ch",
108
+ "cho",
109
+ "chr",
110
+ "chy",
111
+ "ckb",
112
+ "co",
113
+ "cr",
114
+ "crh",
115
+ "cs",
116
+ "csb",
117
+ "cu",
118
+ "cv",
119
+ "cy",
120
+ "da",
121
+ "de",
122
+ "din",
123
+ "diq",
124
+ "dsb",
125
+ "dty",
126
+ "dv",
127
+ "dz",
128
+ "ee",
129
+ "el",
130
+ "eml",
131
+ "en",
132
+ "eo",
133
+ "es",
134
+ "et",
135
+ "eu",
136
+ "ext",
137
+ "fa",
138
+ "ff",
139
+ "fi",
140
+ "fiu-vro",
141
+ "fj",
142
+ "fo",
143
+ "fr",
144
+ "frp",
145
+ "frr",
146
+ "fur",
147
+ "fy",
148
+ "ga",
149
+ "gag",
150
+ "gan",
151
+ "gd",
152
+ "gl",
153
+ "glk",
154
+ "gn",
155
+ "gom",
156
+ "gor",
157
+ "got",
158
+ "gu",
159
+ "gv",
160
+ "ha",
161
+ "hak",
162
+ "haw",
163
+ "he",
164
+ "hi",
165
+ "hif",
166
+ "ho",
167
+ "hr",
168
+ "hsb",
169
+ "ht",
170
+ "hu",
171
+ "hy",
172
+ "ia",
173
+ "id",
174
+ "ie",
175
+ "ig",
176
+ "ii",
177
+ "ik",
178
+ "ilo",
179
+ "inh",
180
+ "io",
181
+ "is",
182
+ "it",
183
+ "iu",
184
+ "ja",
185
+ "jam",
186
+ "jbo",
187
+ "jv",
188
+ "ka",
189
+ "kaa",
190
+ "kab",
191
+ "kbd",
192
+ "kbp",
193
+ "kg",
194
+ "ki",
195
+ "kj",
196
+ "kk",
197
+ "kl",
198
+ "km",
199
+ "kn",
200
+ "ko",
201
+ "koi",
202
+ "krc",
203
+ "ks",
204
+ "ksh",
205
+ "ku",
206
+ "kv",
207
+ "kw",
208
+ "ky",
209
+ "la",
210
+ "lad",
211
+ "lb",
212
+ "lbe",
213
+ "lez",
214
+ "lfn",
215
+ "lg",
216
+ "li",
217
+ "lij",
218
+ "lmo",
219
+ "ln",
220
+ "lo",
221
+ "lrc",
222
+ "lt",
223
+ "ltg",
224
+ "lv",
225
+ "mai",
226
+ "map-bms",
227
+ "mdf",
228
+ "mg",
229
+ "mh",
230
+ "mhr",
231
+ "mi",
232
+ "min",
233
+ "mk",
234
+ "ml",
235
+ "mn",
236
+ "mr",
237
+ "mrj",
238
+ "ms",
239
+ "mt",
240
+ "mus",
241
+ "mwl",
242
+ "my",
243
+ "myv",
244
+ "mzn",
245
+ "na",
246
+ "nah",
247
+ "nap",
248
+ "nds",
249
+ "nds-nl",
250
+ "ne",
251
+ "new",
252
+ "ng",
253
+ "nl",
254
+ "nn",
255
+ "no",
256
+ "nov",
257
+ "nrm",
258
+ "nso",
259
+ "nv",
260
+ "ny",
261
+ "oc",
262
+ "olo",
263
+ "om",
264
+ "or",
265
+ "os",
266
+ "pa",
267
+ "pag",
268
+ "pam",
269
+ "pap",
270
+ "pcd",
271
+ "pdc",
272
+ "pfl",
273
+ "pi",
274
+ "pih",
275
+ "pl",
276
+ "pms",
277
+ "pnb",
278
+ "pnt",
279
+ "ps",
280
+ "pt",
281
+ "qu",
282
+ "rm",
283
+ "rmy",
284
+ "rn",
285
+ "ro",
286
+ "roa-rup",
287
+ "roa-tara",
288
+ "ru",
289
+ "rue",
290
+ "rw",
291
+ "sa",
292
+ "sah",
293
+ "sat",
294
+ "sc",
295
+ "scn",
296
+ "sco",
297
+ "sd",
298
+ "se",
299
+ "sg",
300
+ "sh",
301
+ "si",
302
+ "simple",
303
+ "sk",
304
+ "sl",
305
+ "sm",
306
+ "sn",
307
+ "so",
308
+ "sq",
309
+ "sr",
310
+ "srn",
311
+ "ss",
312
+ "st",
313
+ "stq",
314
+ "su",
315
+ "sv",
316
+ "sw",
317
+ "szl",
318
+ "ta",
319
+ "tcy",
320
+ "te",
321
+ "tet",
322
+ "tg",
323
+ "th",
324
+ "ti",
325
+ "tk",
326
+ "tl",
327
+ "tn",
328
+ "to",
329
+ "tpi",
330
+ "tr",
331
+ "ts",
332
+ "tt",
333
+ "tum",
334
+ "tw",
335
+ "ty",
336
+ "tyv",
337
+ "udm",
338
+ "ug",
339
+ "uk",
340
+ "ur",
341
+ "uz",
342
+ "ve",
343
+ "vec",
344
+ "vep",
345
+ "vi",
346
+ "vls",
347
+ "vo",
348
+ "wa",
349
+ "war",
350
+ "wo",
351
+ "wuu",
352
+ "xal",
353
+ "xh",
354
+ "xmf",
355
+ "yi",
356
+ "yo",
357
+ "za",
358
+ "zea",
359
+ "zh",
360
+ "zh-classical",
361
+ "zh-min-nan",
362
+ "zh-yue",
363
+ "zu",
364
+ ]
365
+
366
+ _BASE_URL_TMPL = "https://dumps.wikimedia.org/{lang}wiki/{date}/"
367
+ _INFO_FILE = "dumpstatus.json"
368
+
369
+
370
+ class WikipediaConfig(datasets.BuilderConfig):
371
+ """BuilderConfig for Wikipedia."""
372
+
373
+ def __init__(self, language=None, date=None, **kwargs):
374
+ """BuilderConfig for Wikipedia.
375
+
376
+ Args:
377
+ language: string, the language code for the Wikipedia dump to use.
378
+ date: string, date of the Wikipedia dump in YYYYMMDD format. A list of
379
+ available dates can be found at https://dumps.wikimedia.org/enwiki/.
380
+ **kwargs: keyword arguments forwarded to super.
381
+ """
382
+ super(WikipediaConfig, self).__init__(
383
+ name="{0}.{1}".format(date, language),
384
+ description="Wikipedia dataset for {0}, parsed from {1} dump.".format(language, date),
385
+ **kwargs,
386
+ )
387
+ self.date = date
388
+ self.language = language
389
+
390
+
391
+ _VERSION = datasets.Version("1.0.0", "")
392
+
393
+
394
+ class Wikipedia(datasets.BeamBasedBuilder):
395
+ """Wikipedia dataset."""
396
+
397
+ # Use mirror (your.org) to avoid download caps.
398
+
399
+ BUILDER_CONFIGS = [
400
+ WikipediaConfig(
401
+ version=_VERSION,
402
+ language=lang,
403
+ date="20200501",
404
+ ) # pylint:disable=g-complex-comprehension
405
+ for lang in WIKIPEDIA_LANGUAGES
406
+ ]
407
+
408
+ def _info(self):
409
+ return datasets.DatasetInfo(
410
+ description=_DESCRIPTION,
411
+ features=datasets.Features({"title": datasets.Value("string"), "text": datasets.Value("string")}),
412
+ # No default supervised_keys.
413
+ supervised_keys=None,
414
+ homepage="https://dumps.wikimedia.org",
415
+ citation=_CITATION,
416
+ )
417
+
418
+ def _split_generators(self, dl_manager, pipeline):
419
+ def _base_url(lang):
420
+ return _BASE_URL_TMPL.format(lang=lang.replace("-", "_"), date=self.config.date)
421
+
422
+ lang = self.config.language
423
+
424
+ info_url = _base_url(lang) + _INFO_FILE
425
+ # Use dictionary since testing mock always returns the same result.
426
+ downloaded_files = dl_manager.download_and_extract({"info": info_url})
427
+
428
+ xml_urls = []
429
+ total_bytes = 0
430
+ with open(downloaded_files["info"], encoding="utf-8") as f:
431
+ dump_info = json.load(f)
432
+ multistream_dump_info = dump_info["jobs"]["articlesmultistreamdump"]
433
+ assert (
434
+ multistream_dump_info["status"] == "done"
435
+ ), "Specified dump (%s) multistream status is not 'done': %s" % (
436
+ _base_url(lang),
437
+ multistream_dump_info["status"],
438
+ )
439
+
440
+ for fname, info in multistream_dump_info["files"].items():
441
+ if ".xml" not in fname:
442
+ continue
443
+ total_bytes += info["size"]
444
+ xml_urls.append(_base_url(lang) + fname)
445
+
446
+ # Use dictionary since testing mock always returns the same result.
447
+ downloaded_files = dl_manager.download({"xml": xml_urls})
448
+ if not pipeline.is_local():
449
+ downloaded_files = dl_manager.ship_files_with_pipeline(downloaded_files, pipeline)
450
+
451
+ return [
452
+ datasets.SplitGenerator( # pylint:disable=g-complex-comprehension
453
+ name=datasets.Split.TRAIN, gen_kwargs={"filepaths": downloaded_files["xml"], "language": lang}
454
+ )
455
+ ]
456
+
457
+ def _build_pcollection(self, pipeline, filepaths, language):
458
+ """Build PCollection of examples in the raw (text) form."""
459
+ import apache_beam as beam
460
+ import mwparserfromhell
461
+
462
+ def _extract_content(filepath):
463
+ """Extracts article content from a single WikiMedia XML file."""
464
+ logging.info("generating examples from = %s", filepath)
465
+ with beam.io.filesystems.FileSystems.open(filepath) as f:
466
+ f = bz2.BZ2File(filename=f)
467
+ if six.PY3:
468
+ # Workaround due to:
469
+ # https://github.com/tensorflow/tensorflow/issues/33563
470
+ utf_f = codecs.getreader("utf-8")(f)
471
+ else:
472
+ utf_f = f
473
+
474
+ # To clear root, to free-up more memory than just `elem.clear()`.
475
+ context = etree.iterparse(utf_f, events=("end",))
476
+ context = iter(context)
477
+ unused_event, root = next(context)
478
+ for unused_event, elem in context:
479
+ if not elem.tag.endswith("page"):
480
+ continue
481
+ namespace = elem.tag[:-4]
482
+ title = elem.find("./{0}title".format(namespace)).text
483
+ ns = elem.find("./{0}ns".format(namespace)).text
484
+ id_ = elem.find("./{0}id".format(namespace)).text
485
+
486
+ # Filter pages that are not in the "main" namespace.
487
+ if ns != "0":
488
+ root.clear()
489
+ continue
490
+
491
+ raw_content = elem.find("./{0}revision/{0}text".format(namespace)).text
492
+ root.clear()
493
+
494
+ # Filter redirects.
495
+ if raw_content is None or raw_content.lower().startswith("#redirect"):
496
+ beam.metrics.Metrics.counter(language, "filtered-redirects").inc()
497
+ continue
498
+
499
+ beam.metrics.Metrics.counter(language, "extracted-examples").inc()
500
+ yield (id_, title, raw_content)
501
+
502
+ def _clean_content(inputs):
503
+ """Cleans raw wikicode to extract text."""
504
+ id_, title, raw_content = inputs
505
+ try:
506
+ text = _parse_and_clean_wikicode(raw_content, parser=mwparserfromhell)
507
+ except (mwparserfromhell.parser.ParserError) as e:
508
+ beam.metrics.Metrics.counter(language, "parser-error").inc()
509
+ logging.error("mwparserfromhell ParseError: %s", e)
510
+ return
511
+
512
+ if not text:
513
+ beam.metrics.Metrics.counter(language, "empty-clean-examples").inc()
514
+ return
515
+
516
+ beam.metrics.Metrics.counter(language, "cleaned-examples").inc()
517
+
518
+ yield id_, {"title": title, "text": text}
519
+
520
+ return (
521
+ pipeline
522
+ | "Initialize" >> beam.Create(filepaths)
523
+ | "Extract content" >> beam.FlatMap(_extract_content)
524
+ | "Distribute" >> beam.transforms.Reshuffle()
525
+ | "Clean content" >> beam.FlatMap(_clean_content)
526
+ )
527
+
528
+
529
+ def _parse_and_clean_wikicode(raw_content, parser):
530
+ """Strips formatting and unwanted sections from raw page content."""
531
+ wikicode = parser.parse(raw_content)
532
+
533
+ # Filters for references, tables, and file/image links.
534
+ re_rm_wikilink = re.compile("^(?:File|Image|Media):", flags=re.IGNORECASE | re.UNICODE)
535
+
536
+ def rm_wikilink(obj):
537
+ return bool(re_rm_wikilink.match(six.text_type(obj.title)))
538
+
539
+ def rm_tag(obj):
540
+ return six.text_type(obj.tag) in {"ref", "table"}
541
+
542
+ def rm_template(obj):
543
+ return obj.name.lower() in {"reflist", "notelist", "notelist-ua", "notelist-lr", "notelist-ur", "notelist-lg"}
544
+
545
+ def try_remove_obj(obj, section):
546
+ try:
547
+ section.remove(obj)
548
+ except ValueError:
549
+ # For unknown reasons, objects are sometimes not found.
550
+ pass
551
+
552
+ section_text = []
553
+ # Filter individual sections to clean.
554
+ for section in wikicode.get_sections(flat=True, include_lead=True, include_headings=True):
555
+ for obj in section.ifilter_wikilinks(matches=rm_wikilink, recursive=True):
556
+ try_remove_obj(obj, section)
557
+ for obj in section.ifilter_templates(matches=rm_template, recursive=True):
558
+ try_remove_obj(obj, section)
559
+ for obj in section.ifilter_tags(matches=rm_tag, recursive=True):
560
+ try_remove_obj(obj, section)
561
+
562
+ section_text.append(section.strip_code().strip())
563
+ return "\n\n".join(section_text)