Release v0.1.0: batch 122/122
Browse files- data/arzwiki-001623.parquet +3 -0
- data/arzwiki-001624.parquet +3 -0
- data/arzwiki-001625.parquet +3 -0
- data/arzwiki-001626.parquet +3 -0
- data/arzwiki-001627.parquet +3 -0
- data/arzwiki-001628.parquet +3 -0
- data/arzwiki-001629.parquet +3 -0
- data/arzwiki-001630.parquet +3 -0
- data/arzwiki-001631.parquet +3 -0
- data/arzwiki-001632.parquet +3 -0
- data/arzwiki-001633.parquet +3 -0
- data/arzwiki-001634.parquet +3 -0
- data/arzwiki-001635.parquet +3 -0
- data/arzwiki-001636.parquet +3 -0
- data/arzwiki-001637.parquet +3 -0
- data/arzwiki-001638.parquet +3 -0
- data/arzwiki-001639.parquet +3 -0
- data/arzwiki-001640.parquet +3 -0
- metadata/source-and-quality.json +224 -0
- source/LICENSE +202 -0
- source/README.md +5 -0
- source/build_corpus.py +144 -0
- source/fetch_dump.py +71 -0
- source/requirements.txt +3 -0
data/arzwiki-001623.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:52a456eb4399475cd72b3d16c1134760b4928f43e4921ee9a74005af8c2c7840
|
| 3 |
+
size 5244815
|
data/arzwiki-001624.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ce27d14b397643b635b55daacc0b78ad3cefd322e8dfe2f9f4208a877d2608b
|
| 3 |
+
size 4081607
|
data/arzwiki-001625.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bf495fc008cc9c8b4ccad574850263834f7a7c61fe89a3f9e686f65c2024a4c6
|
| 3 |
+
size 5595748
|
data/arzwiki-001626.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77d125a4e228a828acda6b59d65021347733e9c26babbea4d0941fee61c304ba
|
| 3 |
+
size 5294307
|
data/arzwiki-001627.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:06a5ca9e4384fb89fde2d221e2e31c4f6098c3eba634b7586a2cd8842d5b456c
|
| 3 |
+
size 3556460
|
data/arzwiki-001628.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1112fe5a77c68626cc19ff9dd6a659e2099f926c26c615fe685b6e9bb6748009
|
| 3 |
+
size 3337277
|
data/arzwiki-001629.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4dfaa8170828dfd9a6e11f93eebd0f5c453b488e2075445279b7435b36c56693
|
| 3 |
+
size 5655331
|
data/arzwiki-001630.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:47158087c425ac2bdd74149056fa7e7f0ac041765c442a3aa50a1c7c50360a0b
|
| 3 |
+
size 5482727
|
data/arzwiki-001631.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b99265737d3eb19a7f3852c7dcf533602c87e273899fb1d726a5349e114271fb
|
| 3 |
+
size 4132539
|
data/arzwiki-001632.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f077b17b691056f2fbdc0ef68eb694908afe9925b52a056b43d5cd8a7ba750aa
|
| 3 |
+
size 5700278
|
data/arzwiki-001633.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a8d1f082b4e6fe8e56cfa1984133ceec92a7ed74751a479eba0abaccf762058
|
| 3 |
+
size 5860439
|
data/arzwiki-001634.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:539d19cea6a8ea5c69fe127b86fdef43ca1f052a02dd6e1bdbaa324078081666
|
| 3 |
+
size 5148170
|
data/arzwiki-001635.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bba28a856cb4940eae382f272172d0f054b094a6b499d95e6453eb5233ee7981
|
| 3 |
+
size 5021047
|
data/arzwiki-001636.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19458c0f549f66028424b775a85c73b23da2b61c318a75a02c540a8b9398e4a8
|
| 3 |
+
size 5712911
|
data/arzwiki-001637.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:abe432c6308d3c46d3118cf5571eab9ffed27a0ea19e98dc747536c34a58bc04
|
| 3 |
+
size 5765413
|
data/arzwiki-001638.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:137afb932aa6a97cf00c867e8ee80195e46440df62ffd42bb4cb218a47d3818f
|
| 3 |
+
size 5729225
|
data/arzwiki-001639.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:164c856764b55707ea20144a43b67b7b9a89ca4114a55935ace11688308161a2
|
| 3 |
+
size 4949103
|
data/arzwiki-001640.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5ac36965e614c0807665e8edbc57b26d6a8e379f652279f9992c74d662dd4e7e
|
| 3 |
+
size 4111918
|
metadata/source-and-quality.json
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"data_directory_manifest_sha256": "8e37b767667eaf0797ea294cd56a2beca1d763740e3e46bfb505cbcfa4b24da2",
|
| 3 |
+
"editions": {
|
| 4 |
+
"arwiki": {
|
| 5 |
+
"audit_counts": {
|
| 6 |
+
"pre_2023_06_07_revision_timestamps": 43681,
|
| 7 |
+
"raw_utf8_bytes": 9010274973,
|
| 8 |
+
"rows": 1334057,
|
| 9 |
+
"sampled_sections": 1306,
|
| 10 |
+
"sections": 5786684
|
| 11 |
+
},
|
| 12 |
+
"full_source_provenance_checked": true,
|
| 13 |
+
"quality": {
|
| 14 |
+
"article_markup_probe_fraction": 0.12275187641907355,
|
| 15 |
+
"article_raw_utf8_bytes_nearest_rank": {
|
| 16 |
+
"p50": 3333,
|
| 17 |
+
"p90": 13021,
|
| 18 |
+
"p99": 59669
|
| 19 |
+
},
|
| 20 |
+
"article_raw_utf8_length_bins": {
|
| 21 |
+
"0-99": 135,
|
| 22 |
+
"100-499": 25914,
|
| 23 |
+
"10000-49999": 172567,
|
| 24 |
+
"2000-9999": 849071,
|
| 25 |
+
"500-1999": 269004,
|
| 26 |
+
"50000+": 17366
|
| 27 |
+
},
|
| 28 |
+
"article_section_count_bins": {
|
| 29 |
+
"1": 39211,
|
| 30 |
+
"10-49": 76613,
|
| 31 |
+
"2-4": 912922,
|
| 32 |
+
"5-9": 304233,
|
| 33 |
+
"50+": 1078
|
| 34 |
+
},
|
| 35 |
+
"article_section_text_codepoint_length_bins": {
|
| 36 |
+
"0-99": 26616,
|
| 37 |
+
"100-499": 510634,
|
| 38 |
+
"10000-49999": 32041,
|
| 39 |
+
"2000-9999": 246976,
|
| 40 |
+
"500-1999": 515669,
|
| 41 |
+
"50000+": 2121
|
| 42 |
+
},
|
| 43 |
+
"article_section_text_codepoints_nearest_rank": {
|
| 44 |
+
"p50": 648,
|
| 45 |
+
"p90": 3928,
|
| 46 |
+
"p99": 18053
|
| 47 |
+
},
|
| 48 |
+
"articles_under_200_codepoints_fraction": 0.08610576609545169,
|
| 49 |
+
"empty_sections_fraction": 0.0008657808167855718,
|
| 50 |
+
"revision_years": {
|
| 51 |
+
"2009": 3,
|
| 52 |
+
"2010": 5,
|
| 53 |
+
"2011": 2,
|
| 54 |
+
"2012": 21,
|
| 55 |
+
"2013": 10,
|
| 56 |
+
"2014": 14,
|
| 57 |
+
"2015": 62,
|
| 58 |
+
"2016": 85,
|
| 59 |
+
"2017": 79,
|
| 60 |
+
"2018": 66,
|
| 61 |
+
"2019": 174,
|
| 62 |
+
"2020": 1877,
|
| 63 |
+
"2021": 586,
|
| 64 |
+
"2022": 13321,
|
| 65 |
+
"2023": 55573,
|
| 66 |
+
"2024": 89257,
|
| 67 |
+
"2025": 133951,
|
| 68 |
+
"2026": 1038971
|
| 69 |
+
},
|
| 70 |
+
"section_markup_probe_fraction": 0.048245074381113605,
|
| 71 |
+
"section_text_codepoint_length_bins": {
|
| 72 |
+
"0-99": 1966424,
|
| 73 |
+
"100-499": 2468610,
|
| 74 |
+
"10000-49999": 3911,
|
| 75 |
+
"2000-9999": 177078,
|
| 76 |
+
"500-1999": 1170530,
|
| 77 |
+
"50000+": 131
|
| 78 |
+
},
|
| 79 |
+
"totals": {
|
| 80 |
+
"articles": 1334057,
|
| 81 |
+
"articles_all_sections_empty_after_strip": 1986,
|
| 82 |
+
"articles_markup_probe_match": 163758,
|
| 83 |
+
"articles_with_section_text_under_200_codepoints": 114870,
|
| 84 |
+
"raw_wikitext_utf8_bytes": 9010274973,
|
| 85 |
+
"revisions_at_or_after_2023_06_07_utc": 1290376,
|
| 86 |
+
"revisions_before_2023_06_07_utc": 43681,
|
| 87 |
+
"section_empty_after_strip": 5010,
|
| 88 |
+
"section_text_unicode_codepoints": 2445544159,
|
| 89 |
+
"section_text_utf8_bytes": 4223343814,
|
| 90 |
+
"sections": 5786684,
|
| 91 |
+
"sections_markup_probe_match": 279179
|
| 92 |
+
}
|
| 93 |
+
},
|
| 94 |
+
"section_reproduction_sample_policy": "SHA256(wiki:page_id) modulo 1024 equals 0; deterministic parser reproduction only",
|
| 95 |
+
"source": {
|
| 96 |
+
"bytes": 2023850490,
|
| 97 |
+
"dump_date": "20261001",
|
| 98 |
+
"official_dumpstatus_url": "https://dumps.wikimedia.org/arwiki/20261001/dumpstatus.json",
|
| 99 |
+
"official_sha1": "3fbfb6ba83c9370abc0df33987f59ce6018188f7",
|
| 100 |
+
"sha256": "3871abbd0240f7b2293e2a58d5911c97390333ba23428b49f1e6c5adb350d843",
|
| 101 |
+
"url": "https://dumps.wikimedia.org/arwiki/20261001/arwiki-20261001-pages-articles.xml.bz2",
|
| 102 |
+
"wiki": "arwiki"
|
| 103 |
+
},
|
| 104 |
+
"source_census": {
|
| 105 |
+
"excluded_non_main_namespace": 1467419,
|
| 106 |
+
"excluded_redirect": 1117224,
|
| 107 |
+
"retained": 1334057,
|
| 108 |
+
"source_pages": 3918700
|
| 109 |
+
}
|
| 110 |
+
},
|
| 111 |
+
"arzwiki": {
|
| 112 |
+
"audit_counts": {
|
| 113 |
+
"pre_2023_06_07_revision_timestamps": 768,
|
| 114 |
+
"raw_utf8_bytes": 2498512982,
|
| 115 |
+
"rows": 1633717,
|
| 116 |
+
"sampled_sections": 1645,
|
| 117 |
+
"sections": 8454059
|
| 118 |
+
},
|
| 119 |
+
"full_source_provenance_checked": true,
|
| 120 |
+
"quality": {
|
| 121 |
+
"article_markup_probe_fraction": 0.16625768110388764,
|
| 122 |
+
"article_raw_utf8_bytes_nearest_rank": {
|
| 123 |
+
"p50": 799,
|
| 124 |
+
"p90": 4118,
|
| 125 |
+
"p99": 5518
|
| 126 |
+
},
|
| 127 |
+
"article_raw_utf8_length_bins": {
|
| 128 |
+
"0-99": 6,
|
| 129 |
+
"100-499": 62856,
|
| 130 |
+
"10000-49999": 5278,
|
| 131 |
+
"2000-9999": 263552,
|
| 132 |
+
"500-1999": 1300369,
|
| 133 |
+
"50000+": 1656
|
| 134 |
+
},
|
| 135 |
+
"article_section_count_bins": {
|
| 136 |
+
"1": 4256,
|
| 137 |
+
"10-49": 7404,
|
| 138 |
+
"2-4": 498176,
|
| 139 |
+
"5-9": 1123793,
|
| 140 |
+
"50+": 88
|
| 141 |
+
},
|
| 142 |
+
"article_section_text_codepoint_length_bins": {
|
| 143 |
+
"0-99": 1695,
|
| 144 |
+
"100-499": 1293404,
|
| 145 |
+
"10000-49999": 2722,
|
| 146 |
+
"2000-9999": 13972,
|
| 147 |
+
"500-1999": 321480,
|
| 148 |
+
"50000+": 444
|
| 149 |
+
},
|
| 150 |
+
"article_section_text_codepoints_nearest_rank": {
|
| 151 |
+
"p50": 311,
|
| 152 |
+
"p90": 1088,
|
| 153 |
+
"p99": 2057
|
| 154 |
+
},
|
| 155 |
+
"articles_under_200_codepoints_fraction": 0.13134465761205888,
|
| 156 |
+
"empty_sections_fraction": 0.00011911438044139507,
|
| 157 |
+
"revision_years": {
|
| 158 |
+
"2023": 57126,
|
| 159 |
+
"2024": 324043,
|
| 160 |
+
"2025": 1087945,
|
| 161 |
+
"2026": 164603
|
| 162 |
+
},
|
| 163 |
+
"section_markup_probe_fraction": 0.03408658491737519,
|
| 164 |
+
"section_text_codepoint_length_bins": {
|
| 165 |
+
"0-99": 6959560,
|
| 166 |
+
"100-499": 1186355,
|
| 167 |
+
"10000-49999": 1094,
|
| 168 |
+
"2000-9999": 13072,
|
| 169 |
+
"500-1999": 293770,
|
| 170 |
+
"50000+": 208
|
| 171 |
+
},
|
| 172 |
+
"totals": {
|
| 173 |
+
"articles": 1633717,
|
| 174 |
+
"articles_all_sections_empty_after_strip": 2,
|
| 175 |
+
"articles_markup_probe_match": 271618,
|
| 176 |
+
"articles_with_section_text_under_200_codepoints": 214580,
|
| 177 |
+
"raw_wikitext_utf8_bytes": 2498512982,
|
| 178 |
+
"revisions_at_or_after_2023_06_07_utc": 1632949,
|
| 179 |
+
"revisions_before_2023_06_07_utc": 768,
|
| 180 |
+
"section_empty_after_strip": 1007,
|
| 181 |
+
"section_text_unicode_codepoints": 841469638,
|
| 182 |
+
"section_text_utf8_bytes": 1434489689,
|
| 183 |
+
"sections": 8454059,
|
| 184 |
+
"sections_markup_probe_match": 288170
|
| 185 |
+
}
|
| 186 |
+
},
|
| 187 |
+
"section_reproduction_sample_policy": "SHA256(wiki:page_id) modulo 1024 equals 0; deterministic parser reproduction only",
|
| 188 |
+
"source": {
|
| 189 |
+
"bytes": 299281321,
|
| 190 |
+
"dump_date": "20261001",
|
| 191 |
+
"official_dumpstatus_url": "https://dumps.wikimedia.org/arzwiki/20261001/dumpstatus.json",
|
| 192 |
+
"official_sha1": "8e13d9b2235163d878fef1cf62e9c462c294a040",
|
| 193 |
+
"sha256": "99ceab5a4c02f103da22ea59c4a3dc64bdec4d379d2886021766f335177d54f9",
|
| 194 |
+
"url": "https://dumps.wikimedia.org/arzwiki/20261001/arzwiki-20261001-pages-articles.xml.bz2",
|
| 195 |
+
"wiki": "arzwiki"
|
| 196 |
+
},
|
| 197 |
+
"source_census": {
|
| 198 |
+
"excluded_non_main_namespace": 249528,
|
| 199 |
+
"excluded_redirect": 31686,
|
| 200 |
+
"retained": 1633717,
|
| 201 |
+
"source_pages": 1914931
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
},
|
| 205 |
+
"parser_tree_sha256": "374ed925c2433d5a31444a36d1ed947b6c2ed2e0719ee5446db0d5886a085ce3",
|
| 206 |
+
"quality_definitions": {
|
| 207 |
+
"article_clean_length": "Sum of Python Unicode codepoint lengths of heuristic section text fields; no added separators.",
|
| 208 |
+
"article_under_200": "Section text length <200 codepoints: a mechanical short-text proxy, not Wikipedia stub classification or a quality judgment.",
|
| 209 |
+
"empty_section": "Section text is empty or whitespace under Python str.strip().",
|
| 210 |
+
"markup_probe": "Regex detects literal [[, ]], {{, }}, ref tags, file/image namespace mentions, or thumb/تصغير caption fragments. It can miss or falsely flag markup; it does not measure extraction accuracy.",
|
| 211 |
+
"quantiles": "Exact nearest-rank quantiles computed on every retained article.",
|
| 212 |
+
"revision_era": "Lexicographic UTC revision timestamp split at 2023-06-07T00:00:00Z; source license is not independently inferred for each row."
|
| 213 |
+
},
|
| 214 |
+
"quality_limitations": [
|
| 215 |
+
"Mechanically derived measures, not judgments of language, correctness or human authorship.",
|
| 216 |
+
"Edition name is source wiki identity, not verified language or dialect.",
|
| 217 |
+
"Historical Wikipedia revisions can contain third-party quotations and errors.",
|
| 218 |
+
"No near-duplicate, semantic relevance or extraction quality review is implied.",
|
| 219 |
+
"Source hashes are carried from completion receipts; this quality analysis does not rehash source dumps."
|
| 220 |
+
],
|
| 221 |
+
"quality_script_sha256": "8eb291619cba7c6a45f6b9a41f7f237331eecf10e35676e9f5a1f977f355d8db",
|
| 222 |
+
"source_audit_builder_sha256": "d8c06c0580f00702f7bd125c04d18fe864170deb2a683312b250289e61cff2fa",
|
| 223 |
+
"source_audit_scope": "all raw article source and provenance fields; section reproduction sampled deterministically"
|
| 224 |
+
}
|
source/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
Apache License
|
| 3 |
+
Version 2.0, January 2004
|
| 4 |
+
http://www.apache.org/licenses/
|
| 5 |
+
|
| 6 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 7 |
+
|
| 8 |
+
1. Definitions.
|
| 9 |
+
|
| 10 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 11 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 12 |
+
|
| 13 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 14 |
+
the copyright owner that is granting the License.
|
| 15 |
+
|
| 16 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 17 |
+
other entities that control, are controlled by, or are under common
|
| 18 |
+
control with that entity. For the purposes of this definition,
|
| 19 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 20 |
+
direction or management of such entity, whether by contract or
|
| 21 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 22 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 23 |
+
|
| 24 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 25 |
+
exercising permissions granted by this License.
|
| 26 |
+
|
| 27 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 28 |
+
including but not limited to software source code, documentation
|
| 29 |
+
source, and configuration files.
|
| 30 |
+
|
| 31 |
+
"Object" form shall mean any form resulting from mechanical
|
| 32 |
+
transformation or translation of a Source form, including but
|
| 33 |
+
not limited to compiled object code, generated documentation,
|
| 34 |
+
and conversions to other media types.
|
| 35 |
+
|
| 36 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 37 |
+
Object form, made available under the License, as indicated by a
|
| 38 |
+
copyright notice that is included in or attached to the work
|
| 39 |
+
(an example is provided in the Appendix below).
|
| 40 |
+
|
| 41 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 42 |
+
form, that is based on (or derived from) the Work and for which the
|
| 43 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 44 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 45 |
+
of this License, Derivative Works shall not include works that remain
|
| 46 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 47 |
+
the Work and Derivative Works thereof.
|
| 48 |
+
|
| 49 |
+
"Contribution" shall mean any work of authorship, including
|
| 50 |
+
the original version of the Work and any modifications or additions
|
| 51 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 52 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 53 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 54 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 55 |
+
means any form of electronic, verbal, or written communication sent
|
| 56 |
+
to the Licensor or its representatives, including but not limited to
|
| 57 |
+
communication on electronic mailing lists, source code control systems,
|
| 58 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 59 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 60 |
+
excluding communication that is conspicuously marked or otherwise
|
| 61 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 62 |
+
|
| 63 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 64 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 65 |
+
subsequently incorporated within the Work.
|
| 66 |
+
|
| 67 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 68 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 69 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 70 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 71 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 72 |
+
Work and such Derivative Works in Source or Object form.
|
| 73 |
+
|
| 74 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 75 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 76 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 77 |
+
(except as stated in this section) patent license to make, have made,
|
| 78 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 79 |
+
where such license applies only to those patent claims licensable
|
| 80 |
+
by such Contributor that are necessarily infringed by their
|
| 81 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 82 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 83 |
+
institute patent litigation against any entity (including a
|
| 84 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 85 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 86 |
+
or contributory patent infringement, then any patent licenses
|
| 87 |
+
granted to You under this License for that Work shall terminate
|
| 88 |
+
as of the date such litigation is filed.
|
| 89 |
+
|
| 90 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 91 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 92 |
+
modifications, and in Source or Object form, provided that You
|
| 93 |
+
meet the following conditions:
|
| 94 |
+
|
| 95 |
+
(a) You must give any other recipients of the Work or
|
| 96 |
+
Derivative Works a copy of this License; and
|
| 97 |
+
|
| 98 |
+
(b) You must cause any modified files to carry prominent notices
|
| 99 |
+
stating that You changed the files; and
|
| 100 |
+
|
| 101 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 102 |
+
that You distribute, all copyright, patent, trademark, and
|
| 103 |
+
attribution notices from the Source form of the Work,
|
| 104 |
+
excluding those notices that do not pertain to any part of
|
| 105 |
+
the Derivative Works; and
|
| 106 |
+
|
| 107 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 108 |
+
distribution, then any Derivative Works that You distribute must
|
| 109 |
+
include a readable copy of the attribution notices contained
|
| 110 |
+
within such NOTICE file, excluding those notices that do not
|
| 111 |
+
pertain to any part of the Derivative Works, in at least one
|
| 112 |
+
of the following places: within a NOTICE text file distributed
|
| 113 |
+
as part of the Derivative Works; within the Source form or
|
| 114 |
+
documentation, if provided along with the Derivative Works; or,
|
| 115 |
+
within a display generated by the Derivative Works, if and
|
| 116 |
+
wherever such third-party notices normally appear. The contents
|
| 117 |
+
of the NOTICE file are for informational purposes only and
|
| 118 |
+
do not modify the License. You may add Your own attribution
|
| 119 |
+
notices within Derivative Works that You distribute, alongside
|
| 120 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 121 |
+
that such additional attribution notices cannot be construed
|
| 122 |
+
as modifying the License.
|
| 123 |
+
|
| 124 |
+
You may add Your own copyright statement to Your modifications and
|
| 125 |
+
may provide additional or different license terms and conditions
|
| 126 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 127 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 128 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 129 |
+
the conditions stated in this License.
|
| 130 |
+
|
| 131 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 132 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 133 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 134 |
+
this License, without any additional terms or conditions.
|
| 135 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 136 |
+
the terms of any separate license agreement you may have executed
|
| 137 |
+
with Licensor regarding such Contributions.
|
| 138 |
+
|
| 139 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 140 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 141 |
+
except as required for reasonable and customary use in describing the
|
| 142 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 143 |
+
|
| 144 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 145 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 146 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 147 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 148 |
+
implied, including, without limitation, any warranties or conditions
|
| 149 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 150 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 151 |
+
appropriateness of using or redistributing the Work and assume any
|
| 152 |
+
risks associated with Your exercise of permissions under this License.
|
| 153 |
+
|
| 154 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 155 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 156 |
+
unless required by applicable law (such as deliberate and grossly
|
| 157 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 158 |
+
liable to You for damages, including any direct, indirect, special,
|
| 159 |
+
incidental, or consequential damages of any character arising as a
|
| 160 |
+
result of this License or out of the use or inability to use the
|
| 161 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 162 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 163 |
+
other commercial damages or losses), even if such Contributor
|
| 164 |
+
has been advised of the possibility of such damages.
|
| 165 |
+
|
| 166 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 167 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 168 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 169 |
+
or other liability obligations and/or rights consistent with this
|
| 170 |
+
License. However, in accepting such obligations, You may act only
|
| 171 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 172 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 173 |
+
defend, and hold each Contributor harmless for any liability
|
| 174 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 175 |
+
of your accepting any such warranty or additional liability.
|
| 176 |
+
|
| 177 |
+
END OF TERMS AND CONDITIONS
|
| 178 |
+
|
| 179 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 180 |
+
|
| 181 |
+
To apply the Apache License to your work, attach the following
|
| 182 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 183 |
+
replaced with your own identifying information. (Don't include
|
| 184 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 185 |
+
comment syntax for the file format. We also recommend that a
|
| 186 |
+
file or class name and description of purpose be included on the
|
| 187 |
+
same "printed page" as the copyright notice for easier
|
| 188 |
+
identification within third-party archives.
|
| 189 |
+
|
| 190 |
+
Copyright [yyyy] [name of copyright owner]
|
| 191 |
+
|
| 192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 193 |
+
you may not use this file except in compliance with the License.
|
| 194 |
+
You may obtain a copy of the License at
|
| 195 |
+
|
| 196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 197 |
+
|
| 198 |
+
Unless required by applicable law or agreed to in writing, software
|
| 199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 201 |
+
See the License for the specific language governing permissions and
|
| 202 |
+
limitations under the License.
|
source/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Processing source
|
| 2 |
+
|
| 3 |
+
`build_corpus.py` and `fetch_dump.py` are copies of the reviewed production scripts with their original machine-specific root replaced by `BAYANAT_WIKI_ROOT`; this substitution changes their file hashes. `metadata/source-and-quality.json` records the original production builder hash. The transformation does not otherwise change the script. Paths and operator receipts expected by the builder remain explicit in the code; this is source for inspection and adaptation, not a one-command portable reproduction guarantee.
|
| 4 |
+
|
| 5 |
+
The production runtime was Python 3.14.7, PyArrow 26.0.0, Requests 2.34.2 and mwparserfromhell 0.7.2. Install the parser into `$BAYANAT_WIKI_ROOT/private/vendor` as required by the script, use a clean owned root with the published source topology and receipts, and review the exact lock, disk-floor and restart behavior before executing. Original dump URLs, sizes and hashes are in `../metadata/source-and-quality.json`; the dated source files can disappear, so verify availability and checksums. The code is Apache-2.0; mwparserfromhell is a separately licensed MIT dependency.
|
source/build_corpus.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Stream pinned MediaWiki XML into recoverable, per-article Parquet shards.
|
| 3 |
+
|
| 4 |
+
Preserves raw wikitext and provides heuristic sections with no template expansion.
|
| 5 |
+
Never expands a dump to disk. Shares exclusive owned-writer.lock with fetcher.
|
| 6 |
+
"""
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
import bz2,fcntl,hashlib,json,os,shutil,sys,time,xml.etree.ElementTree as ET
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from urllib.parse import quote
|
| 11 |
+
ROOT=Path(os.environ['BAYANAT_WIKI_ROOT']).resolve();sys.path.insert(0,str(ROOT/'private/vendor'))
|
| 12 |
+
import mwparserfromhell as mw
|
| 13 |
+
import pyarrow as pa
|
| 14 |
+
import pyarrow.parquet as pq
|
| 15 |
+
VENDOR=ROOT/'private/vendor/mwparserfromhell'
|
| 16 |
+
PRIVATE=ROOT/'private';PROJECT=ROOT/'projects/arabic-wikipedia-articles-sections';RELEASE=PROJECT/'release'; FLOOR=4*1024**3; RESERVE=512*1024**2
|
| 17 |
+
LIMIT_ROWS=1000;LIMIT_UTF8=16*1024**2;MAX_ARTICLE_UTF8=8*1024**2
|
| 18 |
+
CONFIG={'arwiki':(2023850490,'3fbfb6ba83c9370abc0df33987f59ce6018188f7','ar'),'arzwiki':(299281321,'8e13d9b2235163d878fef1cf62e9c462c294a040','arz')}
|
| 19 |
+
SECTIONS=pa.list_(pa.struct([('section_index',pa.int32()),('heading',pa.string()),('heading_level',pa.int8()),('text',pa.string())]))
|
| 20 |
+
SCHEMA=pa.schema([('wiki',pa.string()),('page_id',pa.int64()),('revision_id',pa.int64()),('revision_timestamp',pa.string()),('title',pa.string()),('article_url',pa.string()),('revision_url',pa.string()),('history_url',pa.string()),('raw_wikitext',pa.string()),('wikitext_sha256',pa.string()),('sections',SECTIONS),('source_dump_date',pa.string()),('source_dump_sha256',pa.string())])
|
| 21 |
+
def sha(path,algorithm='sha256'):
|
| 22 |
+
h=hashlib.new(algorithm)
|
| 23 |
+
with path.open('rb') as f:
|
| 24 |
+
for b in iter(lambda:f.read(4*1024**2),b''):h.update(b)
|
| 25 |
+
return h.hexdigest()
|
| 26 |
+
def syncdir(p):
|
| 27 |
+
fd=os.open(p,os.O_RDONLY)
|
| 28 |
+
try:os.fsync(fd)
|
| 29 |
+
finally:os.close(fd)
|
| 30 |
+
def create_json(path,obj):
|
| 31 |
+
fd=os.open(path,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)
|
| 32 |
+
with os.fdopen(fd,'w') as f:json.dump(obj,f,ensure_ascii=False,indent=2);f.write('\n');f.flush();os.fsync(f.fileno())
|
| 33 |
+
syncdir(path.parent)
|
| 34 |
+
def sections(text):
|
| 35 |
+
code=mw.parse(text);out=[]
|
| 36 |
+
for i,section in enumerate(code.get_sections(flat=True,include_lead=True,include_headings=True)):
|
| 37 |
+
headings=section.filter_headings(recursive=False);h=headings[0] if headings else None
|
| 38 |
+
title=h.title.strip_code(normalize=True,collapse=True).strip() if h else ''
|
| 39 |
+
out.append({'section_index':i,'heading':title,'heading_level':h.level if h else 0,'text':section.strip_code(normalize=True,collapse=True)})
|
| 40 |
+
return out
|
| 41 |
+
|
| 42 |
+
def article(elem,wiki,source_sha):
|
| 43 |
+
def val(el,name):
|
| 44 |
+
p=el.find('{*}'+name);return p.text if p is not None and p.text is not None else ''
|
| 45 |
+
if val(elem,'ns')!='0' or elem.find('{*}redirect') is not None:return None
|
| 46 |
+
rev=elem.find('{*}revision')
|
| 47 |
+
if rev is None:return None
|
| 48 |
+
if val(rev,'model') not in ('','wikitext'):return None
|
| 49 |
+
txt=rev.find('{*}text');raw=txt.text if txt is not None and txt.text is not None else ''
|
| 50 |
+
if not raw:return None
|
| 51 |
+
title=val(elem,'title');page_id=int(val(elem,'id'));rid=int(val(rev,'id'));raw_bytes=len(raw.encode());
|
| 52 |
+
if raw_bytes>MAX_ARTICLE_UTF8:raise ValueError(f'oversized source article {wiki}:{page_id} revision {rid}: {raw_bytes} bytes; stopped without omission')
|
| 53 |
+
language=CONFIG[wiki][2];host=f'https://{language}.wikipedia.org';url=host+'/wiki/'+quote(title.replace(' ','_'),safe='')
|
| 54 |
+
return {'wiki':wiki,'page_id':page_id,'revision_id':rid,'revision_timestamp':val(rev,'timestamp'),'title':title,'article_url':url,'revision_url':f'{host}/w/index.php?oldid={rid}','history_url':host+'/w/index.php?title='+quote(title.replace(' ','_'),safe='')+'&action=history','raw_wikitext':raw,'wikitext_sha256':hashlib.sha256(raw.encode()).hexdigest(),'sections':sections(raw),'source_dump_date':'20261001','source_dump_sha256':source_sha}
|
| 55 |
+
|
| 56 |
+
def binding_for(wiki,source_sha):
|
| 57 |
+
vendor=VENDOR;h=hashlib.sha256()
|
| 58 |
+
if not vendor.is_dir() or not Path(mw.__file__).resolve().is_relative_to(vendor.resolve()):raise ValueError('reviewed parser vendor not bound')
|
| 59 |
+
for path in sorted(vendor.rglob('*')):
|
| 60 |
+
if path.is_symlink():raise ValueError('symlink in parser vendor forbidden')
|
| 61 |
+
if path.is_file() and '__pycache__' not in path.parts and path.suffix not in ('.pyc',):
|
| 62 |
+
h.update(str(path.relative_to(vendor)).encode()+b'\0');h.update(bytes.fromhex(sha(path)))
|
| 63 |
+
return {'wiki':wiki,'source_sha256':source_sha,'builder_sha256':sha(Path(__file__)),'mwparserfromhell_version':mw.__version__,'mwparserfromhell_tree_sha256':h.hexdigest(),'pyarrow_version':pa.__version__,'python_version':sys.version,'row_limit':LIMIT_ROWS,'utf8_limit':LIMIT_UTF8,'max_article_utf8':MAX_ARTICLE_UTF8,'section_policy':'mwparserfromhell flat include lead headings, strip_code normalize collapse, no template expansion v1'}
|
| 64 |
+
|
| 65 |
+
def bind(wiki,source_sha):
|
| 66 |
+
path=PRIVATE/f'{wiki}-run-binding.json'; value=binding_for(wiki,source_sha)
|
| 67 |
+
if path.exists():
|
| 68 |
+
if json.loads(path.read_text())!=value:raise ValueError('run source, builder or dependency binding differs')
|
| 69 |
+
else:create_json(path,value)
|
| 70 |
+
|
| 71 |
+
def reconcile(wiki):
|
| 72 |
+
state=PRIVATE/'batches'/wiki;state.mkdir(parents=True,exist_ok=True);data=RELEASE/'data';data.mkdir(parents=True,exist_ok=True)
|
| 73 |
+
import re
|
| 74 |
+
known={};pattern=re.compile(r'^(\d{6})\.(intent\.json|ack\.json|parquet\.part)$')
|
| 75 |
+
for p in state.iterdir():
|
| 76 |
+
m=pattern.fullmatch(p.name)
|
| 77 |
+
if not m or not p.is_file() or p.is_symlink():raise ValueError('unknown per-wiki batch state')
|
| 78 |
+
known.setdefault(int(m.group(1)),set()).add(m.group(2))
|
| 79 |
+
for p in data.glob(wiki+'-*.parquet'):
|
| 80 |
+
m=re.fullmatch(re.escape(wiki)+r'-(\d{6})\.parquet',p.name)
|
| 81 |
+
if not m or not p.is_file() or p.is_symlink():raise ValueError('unknown per-wiki output state')
|
| 82 |
+
known.setdefault(int(m.group(1)),set()).add('target')
|
| 83 |
+
if known and sorted(known)!=list(range(max(known)+1)):raise ValueError('gapped per-wiki batch inventory')
|
| 84 |
+
if any('intent.json' not in parts for parts in known.values()):raise ValueError('unrecorded batch inventory')
|
| 85 |
+
cursor=0;index=0;total=0
|
| 86 |
+
while True:
|
| 87 |
+
intent=state/f'{index:06d}.intent.json';ack=state/f'{index:06d}.ack.json';name=f'{wiki}-{index:06d}.parquet';stage=state/f'{index:06d}.parquet.part';target=data/name
|
| 88 |
+
if not intent.exists():
|
| 89 |
+
if ack.exists() or stage.exists() or target.exists():raise ValueError('unrecorded batch state requires review')
|
| 90 |
+
break
|
| 91 |
+
meta=json.loads(intent.read_text());
|
| 92 |
+
if meta['index']!=index or meta['wiki']!=wiki or meta['target']!=name or meta['cursor']<=cursor:raise ValueError('batch intent chain mismatch')
|
| 93 |
+
if ack.exists() and json.loads(ack.read_text())!=meta:raise ValueError('batch acknowledgement mismatch')
|
| 94 |
+
if target.exists():
|
| 95 |
+
if sha(target)!=meta['sha256'] or target.stat().st_size!=meta['bytes']:raise ValueError('target hash mismatch')
|
| 96 |
+
if stage.exists():raise ValueError('both staged and final batch exist; preserve for review')
|
| 97 |
+
elif stage.exists() and not ack.exists():
|
| 98 |
+
if sha(stage)!=meta['sha256'] or stage.stat().st_size!=meta['bytes']:raise ValueError('staging hash mismatch')
|
| 99 |
+
os.rename(stage,target);syncdir(data)
|
| 100 |
+
else:raise ValueError('recorded batch file missing; preserve for review')
|
| 101 |
+
if not ack.exists():create_json(ack,meta)
|
| 102 |
+
cursor=meta['cursor'];total+=meta['rows'];index+=1
|
| 103 |
+
return cursor,index,total
|
| 104 |
+
|
| 105 |
+
def commit(wiki,cursor,index,rows):
|
| 106 |
+
state=PRIVATE/'batches'/wiki;data=RELEASE/'data';stage=state/f'{index:06d}.parquet.part';target=data/f'{wiki}-{index:06d}.parquet';intent=state/f'{index:06d}.intent.json';ack=state/f'{index:06d}.ack.json'
|
| 107 |
+
if any(p.exists() for p in (stage,target,intent,ack)):raise ValueError('unexpected preexisting batch files')
|
| 108 |
+
table=pa.Table.from_pylist(rows,schema=SCHEMA);write_reserve=max(64*1024**2,3*table.nbytes+16*1024**2)
|
| 109 |
+
if shutil.disk_usage(ROOT).free<FLOOR+RESERVE+write_reserve:raise RuntimeError('4 GiB floor plus dynamic Arrow write headroom reached')
|
| 110 |
+
pq.write_table(table,stage,compression='zstd',row_group_size=100)
|
| 111 |
+
with stage.open('rb') as f:os.fsync(f.fileno())
|
| 112 |
+
meta={'wiki':wiki,'index':index,'cursor':cursor,'rows':len(rows),'target':target.name,'bytes':stage.stat().st_size,'sha256':sha(stage)}
|
| 113 |
+
create_json(intent,meta);os.rename(stage,target);syncdir(data);create_json(ack,meta)
|
| 114 |
+
|
| 115 |
+
def run(wiki):
|
| 116 |
+
if wiki not in CONFIG:raise ValueError('unknown source')
|
| 117 |
+
if (PRIVATE/f'{wiki}-build-complete.json').exists():raise ValueError('completion exists; reconcile instead of restarting')
|
| 118 |
+
size,s1,_=CONFIG[wiki];p=PRIVATE/f'{wiki}-20261001-pages-articles.xml.bz2';r=PRIVATE/f'{wiki}-source-receipt.json';rec=json.loads(r.read_text())
|
| 119 |
+
if p.stat().st_size!=size or rec['official_sha1']!=s1 or sha(p,'sha1')!=s1 or sha(p)!=rec['sha256']:raise ValueError('source binding mismatch')
|
| 120 |
+
bind(wiki,rec['sha256']);cursor,index,total=reconcile(wiki);start=time.monotonic();ordinal=0;buf=[];nbytes=0
|
| 121 |
+
with bz2.open(p,'rb') as src:
|
| 122 |
+
events=ET.iterparse(src,events=('start','end'));_,root=next(events)
|
| 123 |
+
for ev,elem in events:
|
| 124 |
+
if ev!='end' or not elem.tag.endswith('}page'):continue
|
| 125 |
+
ordinal+=1
|
| 126 |
+
if ordinal>cursor:
|
| 127 |
+
row=article(elem,wiki,rec['sha256'])
|
| 128 |
+
if row:
|
| 129 |
+
buf.append(row);nbytes+=len(row['raw_wikitext'].encode())+sum(len(s['text'].encode()) for s in row['sections'])
|
| 130 |
+
if buf and (len(buf)>=LIMIT_ROWS or nbytes>=LIMIT_UTF8):
|
| 131 |
+
commit(wiki,ordinal,index,buf);total+=len(buf);index+=1;buf=[];nbytes=0
|
| 132 |
+
print(json.dumps({'wiki':wiki,'ordinal':ordinal,'articles':total,'elapsed_seconds':round(time.monotonic()-start,1)}),flush=True)
|
| 133 |
+
elem.clear();root.clear()
|
| 134 |
+
if buf:commit(wiki,ordinal,index,buf);total+=len(buf)
|
| 135 |
+
complete=PRIVATE/f'{wiki}-build-complete.json'
|
| 136 |
+
if complete.exists():raise ValueError('completion exists; reconcile instead of overwriting')
|
| 137 |
+
create_json(complete,{'wiki':wiki,'source_sha256':rec['sha256'],'source_pages_scanned':ordinal,'articles':total,'elapsed_seconds':round(time.monotonic()-start,1),'completed_unix':time.time()})
|
| 138 |
+
print(json.dumps({'wiki':wiki,'complete':True,'articles':total,'source_pages_scanned':ordinal}),flush=True)
|
| 139 |
+
|
| 140 |
+
def main():
|
| 141 |
+
wiki=sys.argv[1]; PRIVATE.mkdir(parents=True,exist_ok=True)
|
| 142 |
+
with (PRIVATE/'owned-writer.lock').open('a+') as lock:
|
| 143 |
+
os.chmod(lock.name,0o600);fcntl.flock(lock.fileno(),fcntl.LOCK_EX|fcntl.LOCK_NB);run(wiki)
|
| 144 |
+
if __name__=='__main__':main()
|
source/fetch_dump.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Pinned Wikimedia download with owned writer locks and durable reconciliation."""
|
| 3 |
+
import os,sys,json,hashlib,shutil,time,fcntl
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import requests
|
| 6 |
+
ROOT=Path(os.environ['BAYANAT_WIKI_ROOT']).resolve();PRIVATE=ROOT/'private';FLOOR=4*1024**3;RESERVE=512*1024**2
|
| 7 |
+
CONFIG={'arwiki':(2023850490,'3fbfb6ba83c9370abc0df33987f59ce6018188f7'),'arzwiki':(299281321,'8e13d9b2235163d878fef1cf62e9c462c294a040')}
|
| 8 |
+
UA='BayanatLabsResearch/1.0 (dataset preparation; https://www.bayanatlabs.com)'
|
| 9 |
+
def fsync_dir(path):
|
| 10 |
+
fd=os.open(path,os.O_RDONLY)
|
| 11 |
+
try:os.fsync(fd)
|
| 12 |
+
finally:os.close(fd)
|
| 13 |
+
def write_exclusive(path,value):
|
| 14 |
+
fd=os.open(path,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)
|
| 15 |
+
with os.fdopen(fd,'w') as f:json.dump(value,f,indent=2);f.write('\n');f.flush();os.fsync(f.fileno())
|
| 16 |
+
fsync_dir(path.parent)
|
| 17 |
+
def hash_file(path):
|
| 18 |
+
a=hashlib.sha1();b=hashlib.sha256();n=0
|
| 19 |
+
with path.open('rb') as f:
|
| 20 |
+
for chunk in iter(lambda:f.read(4*1024**2),b''):a.update(chunk);b.update(chunk);n+=len(chunk)
|
| 21 |
+
return n,a,b
|
| 22 |
+
def execute(wiki):
|
| 23 |
+
if wiki not in CONFIG:raise ValueError('unrecognized source')
|
| 24 |
+
size,sha1=CONFIG[wiki];name=f'{wiki}-20261001-pages-articles.xml.bz2';path=PRIVATE/name;part=path.with_suffix(path.suffix+'.part');receipt=PRIVATE/f'{wiki}-source-receipt.json';intent=PRIVATE/f'{wiki}-source-intent.json';url=f'https://dumps.wikimedia.org/{wiki}/20261001/{name}';status=f'https://dumps.wikimedia.org/{wiki}/20261001/dumpstatus.json'
|
| 25 |
+
response=requests.get(status,headers={'User-Agent':UA},timeout=30);response.raise_for_status();j=response.json();matches=[(v,job.get('status')) for job in j['jobs'].values() for k,v in (job.get('files') or {}).items() if k==name]
|
| 26 |
+
if not any(v.get('sha1')==sha1 and v.get('size')==size and s=='done' for v,s in matches):raise ValueError('pinned Wikimedia status mismatch')
|
| 27 |
+
binding={'wiki':wiki,'source_url':url,'official_dumpstatus_url':status,'dump_date':'20261001','bytes':size,'official_sha1':sha1}
|
| 28 |
+
if intent.exists():
|
| 29 |
+
if json.loads(intent.read_text())!=binding:raise ValueError('existing intent mismatch')
|
| 30 |
+
else:write_exclusive(intent,binding)
|
| 31 |
+
if path.exists():
|
| 32 |
+
if part.exists():raise ValueError('final and partial file both present; preserve for review')
|
| 33 |
+
n,h1,h2=hash_file(path)
|
| 34 |
+
if n!=size or h1.hexdigest()!=sha1:raise ValueError('existing finalized source mismatch; preserve for review')
|
| 35 |
+
res={**binding,'sha256':h2.hexdigest(),'verified_at_unix':time.time(),'method':'existing finalized exact bytes reconciled'}
|
| 36 |
+
if receipt.exists():
|
| 37 |
+
existing=json.loads(receipt.read_text())
|
| 38 |
+
if any(existing.get(k)!=v for k,v in binding.items()) or existing.get('sha256')!=res['sha256']:raise ValueError('existing receipt mismatch')
|
| 39 |
+
else:write_exclusive(receipt,res)
|
| 40 |
+
print(json.dumps(res),flush=True);return
|
| 41 |
+
if receipt.exists():raise ValueError('receipt present without final source; preserve for review')
|
| 42 |
+
n=part.stat().st_size if part.exists() else 0
|
| 43 |
+
if n>size:raise ValueError('partial file is larger than pinned source')
|
| 44 |
+
if shutil.disk_usage(ROOT).free < FLOOR+RESERVE+(size-n):raise RuntimeError('insufficient space for remaining download plus floor and reserve')
|
| 45 |
+
if n:n,h1,h2=hash_file(part)
|
| 46 |
+
else:h1=hashlib.sha1();h2=hashlib.sha256()
|
| 47 |
+
if n<size:
|
| 48 |
+
hdr={'User-Agent':UA};
|
| 49 |
+
if n:hdr['Range']=f'bytes={n}-'
|
| 50 |
+
with requests.get(url,headers=hdr,timeout=(30,90),stream=True) as r:
|
| 51 |
+
if n:
|
| 52 |
+
if r.status_code!=206 or r.headers.get('Content-Range')!=f'bytes {n}-{size-1}/{size}':raise ValueError('range resume mismatch')
|
| 53 |
+
elif r.status_code!=200:raise ValueError('unexpected response')
|
| 54 |
+
with part.open('ab') as f:
|
| 55 |
+
for chunk in r.iter_content(1024**2):
|
| 56 |
+
if not chunk:continue
|
| 57 |
+
if shutil.disk_usage(ROOT).free-len(chunk)<FLOOR+RESERVE:raise RuntimeError('4 GiB floor plus 512 MiB reserve reached')
|
| 58 |
+
f.write(chunk);h1.update(chunk);h2.update(chunk);n+=len(chunk)
|
| 59 |
+
if n>size:raise ValueError('bytes beyond pinned length')
|
| 60 |
+
f.flush();os.fsync(f.fileno())
|
| 61 |
+
if n!=size or h1.hexdigest()!=sha1:raise ValueError('download failed pinned size/SHA1; preserve partial')
|
| 62 |
+
os.replace(part,path);fsync_dir(PRIVATE)
|
| 63 |
+
res={**binding,'sha256':h2.hexdigest(),'verified_at_unix':time.time(),'method':'downloaded and verified pinned bytes'};write_exclusive(receipt,res);print(json.dumps(res),flush=True)
|
| 64 |
+
def main():
|
| 65 |
+
wiki=sys.argv[1]
|
| 66 |
+
if wiki not in CONFIG:raise ValueError('unrecognized source')
|
| 67 |
+
PRIVATE.mkdir(parents=True,exist_ok=True)
|
| 68 |
+
with (PRIVATE/'owned-writer.lock').open('a+') as project_lock, (PRIVATE/f'{wiki}-fetch.lock').open('a+') as wiki_lock:
|
| 69 |
+
for f in (project_lock,wiki_lock):os.chmod(f.name,0o600);fcntl.flock(f.fileno(),fcntl.LOCK_EX|fcntl.LOCK_NB)
|
| 70 |
+
execute(wiki)
|
| 71 |
+
if __name__=='__main__':main()
|
source/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mwparserfromhell==0.7.2
|
| 2 |
+
pyarrow==26.0.0
|
| 3 |
+
requests==2.34.2
|