Datasets:
Commit ·
b2fb895
1
Parent(s): 3c0bb29
Add European HPLT Polish web filtering workflow
Browse files- README.md +9 -0
- artifacts/hf_readmes/ashtok897__european-hplt-v1__README.md +288 -0
- artifacts/source_candidate_audit_v0_3.json +105 -0
- artifacts/source_candidate_audit_v0_3.md +18 -0
- artifacts/source_license_review_v0_3.md +7 -5
- artifacts/source_scouting_v0_3.md +8 -6
- configs/source_candidates_v0_3.json +7 -0
- src/filter_common_corpus.py +299 -0
- src/filter_european_hplt.py +328 -0
README.md
CHANGED
|
@@ -91,6 +91,15 @@ workflow therefore separates **source inclusion** from **training mix**:
|
|
| 91 |
- evaluate per-source perplexity and style contamination, not only global loss;
|
| 92 |
- treat GPT-2 124M as a cheap dataset probe, not proof of final model quality.
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
Current review artifacts:
|
| 95 |
|
| 96 |
- `configs/source_candidates_v0_3.json` — candidate decisions and license policy.
|
|
|
|
| 91 |
- evaluate per-source perplexity and style contamination, not only global loss;
|
| 92 |
- treat GPT-2 124M as a cheap dataset probe, not proof of final model quality.
|
| 93 |
|
| 94 |
+
Primary v0.3 web candidate: `ashtok897/european-hplt-v1`. Its card reports
|
| 95 |
+
Polish `pl` coverage of **1,891,358 documents** and **~1.98B estimated tokens**
|
| 96 |
+
with HPLT WDS quality scores, language confidence, URL provenance, MIME type,
|
| 97 |
+
and web-register metadata. The helper `src/filter_european_hplt.py` streams this
|
| 98 |
+
dataset and filters for Polish, non-machine-translated, non-boilerplate,
|
| 99 |
+
domain-filtered natural web text. The dataset card marks it `CC0-1.0`, inherited
|
| 100 |
+
from HPLT v3, but because it is web-crawl derived it remains subject to
|
| 101 |
+
source/provenance review before a final release.
|
| 102 |
+
|
| 103 |
Current review artifacts:
|
| 104 |
|
| 105 |
- `configs/source_candidates_v0_3.json` — candidate decisions and license policy.
|
artifacts/hf_readmes/ashtok897__european-hplt-v1__README.md
ADD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
- ru
|
| 23 |
+
- ca
|
| 24 |
+
- lt
|
| 25 |
+
- lv
|
| 26 |
+
- sl
|
| 27 |
+
- hr
|
| 28 |
+
- sr
|
| 29 |
+
- mk
|
| 30 |
+
- bs
|
| 31 |
+
- be
|
| 32 |
+
- gl
|
| 33 |
+
- eu
|
| 34 |
+
- nn
|
| 35 |
+
- is
|
| 36 |
+
- cy
|
| 37 |
+
- mt
|
| 38 |
+
- lb
|
| 39 |
+
- ga
|
| 40 |
+
- ast
|
| 41 |
+
- fo
|
| 42 |
+
- gd
|
| 43 |
+
- oc
|
| 44 |
+
license: cc0-1.0
|
| 45 |
+
task_categories:
|
| 46 |
+
- text-generation
|
| 47 |
+
- fill-mask
|
| 48 |
+
pretty_name: "European HPLT v1 — 45M docs, 41 languages"
|
| 49 |
+
size_categories:
|
| 50 |
+
- 10M<n<100M
|
| 51 |
+
source_datasets:
|
| 52 |
+
- hplt-project/hplt_monolingual_v3
|
| 53 |
+
tags:
|
| 54 |
+
- european
|
| 55 |
+
- multilingual
|
| 56 |
+
- pretraining
|
| 57 |
+
- hplt
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
# European HPLT v1
|
| 61 |
+
|
| 62 |
+
A multilingual pretraining corpus of **45,031,396 documents** (~50.9B estimated tokens, ~190 GB raw JSONL) across **41 European languages**, built from [HPLT Monolingual v3](https://hplt-project.org/datasets/v3) high-quality web crawl data.
|
| 63 |
+
|
| 64 |
+
The corpus spans Germanic, Romance, Slavic, Celtic, Baltic, Finno-Ugric, Greek, and other European language families. Every document has an HPLT WDS quality score of 10 or higher (the top of the quality distribution).
|
| 65 |
+
|
| 66 |
+
## Quick Start
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from datasets import load_dataset
|
| 70 |
+
|
| 71 |
+
# Streaming (recommended — corpus is ~190 GB)
|
| 72 |
+
ds = load_dataset("ashtok897/european-hplt-v1", split="train", streaming=True)
|
| 73 |
+
for row in ds.take(3):
|
| 74 |
+
print(row["lang"], row["text"][:100])
|
| 75 |
+
|
| 76 |
+
# Filter by language
|
| 77 |
+
de_ds = ds.filter(lambda x: x["lang"] == "de")
|
| 78 |
+
|
| 79 |
+
# Full training split (requires disk space)
|
| 80 |
+
ds = load_dataset("ashtok897/european-hplt-v1", split="train")
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
## Language Distribution
|
| 84 |
+
|
| 85 |
+
| Language | BCP-47 | Documents | % | Est. Tokens | Avg Words/Doc |
|
| 86 |
+
|---|---|---:|---:|---:|---:|
|
| 87 |
+
| English | `en` | 3,080,434 | 6.84% | ~4.44B | 955 |
|
| 88 |
+
| French | `fr` | 2,726,717 | 6.06% | ~4.56B | 1,073 |
|
| 89 |
+
| German | `de` | 2,723,089 | 6.05% | ~5.23B | 1,051 |
|
| 90 |
+
| Spanish | `es` | 2,463,158 | 5.47% | ~2.91B | 768 |
|
| 91 |
+
| Portuguese | `pt` | 2,171,285 | 4.82% | ~2.46B | 728 |
|
| 92 |
+
| Italian | `it` | 2,168,007 | 4.81% | ~2.88B | 820 |
|
| 93 |
+
| Dutch | `nl` | 1,902,030 | 4.22% | ~1.64B | 538 |
|
| 94 |
+
| Polish | `pl` | 1,891,358 | 4.20% | ~1.98B | 591 |
|
| 95 |
+
| Czech | `cs` | 1,600,788 | 3.55% | ~1.34B | 516 |
|
| 96 |
+
| Ukrainian | `uk` | 1,577,030 | 3.50% | ~1.08B | 381 |
|
| 97 |
+
| Swedish | `sv` | 1,362,129 | 3.02% | ~1.58B | 721 |
|
| 98 |
+
| Romanian | `ro` | 1,329,418 | 2.95% | ~1.29B | 617 |
|
| 99 |
+
| Hungarian | `hu` | 1,328,026 | 2.95% | ~1.36B | 555 |
|
| 100 |
+
| Greek | `el` | 1,322,934 | 2.94% | ~1.41B | 639 |
|
| 101 |
+
| Danish | `da` | 1,085,979 | 2.41% | ~1.16B | 668 |
|
| 102 |
+
| Norwegian Bokmål | `nb` | 1,081,349 | 2.40% | ~0.99B | 586 |
|
| 103 |
+
| Slovak | `sk` | 1,063,235 | 2.36% | ~0.72B | 413 |
|
| 104 |
+
| Finnish | `fi` | 1,062,298 | 2.36% | ~1.64B | 751 |
|
| 105 |
+
| Bulgarian | `bg` | 1,060,225 | 2.35% | ~0.73B | 434 |
|
| 106 |
+
| Russian | `ru` | 1,046,533 | 2.32% | ~3.62B | 1,847 |
|
| 107 |
+
| Catalan | `ca` | 792,769 | 1.76% | ~0.60B | 499 |
|
| 108 |
+
| Lithuanian | `lt` | 792,614 | 1.76% | ~0.52B | 352 |
|
| 109 |
+
| Latvian | `lv` | 784,033 | 1.74% | ~0.55B | 391 |
|
| 110 |
+
| Slovenian | `sl` | 783,987 | 1.74% | ~0.57B | 449 |
|
| 111 |
+
| Croatian | `hr` | 771,689 | 1.71% | ~0.56B | 448 |
|
| 112 |
+
| Serbian | `sr` | 759,832 | 1.69% | ~0.54B | 440 |
|
| 113 |
+
| Macedonian | `mk` | 648,038 | 1.44% | ~0.34B | 333 |
|
| 114 |
+
| Bosnian | `bs` | 642,025 | 1.43% | ~0.44B | 427 |
|
| 115 |
+
| Belarusian | `be` | 639,982 | 1.42% | ~0.38B | 337 |
|
| 116 |
+
| Galician | `gl` | 639,327 | 1.42% | ~0.42B | 424 |
|
| 117 |
+
| Basque | `eu` | 636,441 | 1.41% | ~0.36B | 294 |
|
| 118 |
+
| Norwegian Nynorsk | `nn` | 535,072 | 1.19% | ~0.36B | 437 |
|
| 119 |
+
| Icelandic | `is` | 432,802 | 0.96% | ~0.82B | 1,073 |
|
| 120 |
+
| Welsh | `cy` | 431,246 | 0.96% | ~0.25B | 390 |
|
| 121 |
+
| Maltese | `mt` | 326,736 | 0.73% | ~0.21B | 358 |
|
| 122 |
+
| Luxembourgish | `lb` | 324,914 | 0.72% | ~0.22B | 417 |
|
| 123 |
+
| Irish | `ga` | 321,842 | 0.71% | ~0.21B | 431 |
|
| 124 |
+
| Asturian | `ast` | 215,942 | 0.48% | ~0.19B | 555 |
|
| 125 |
+
| Faroese | `fo` | 209,925 | 0.47% | ~0.10B | 292 |
|
| 126 |
+
| Scottish Gaelic | `gd` | 197,604 | 0.44% | ~0.15B | 502 |
|
| 127 |
+
| Occitan | `oc` | 98,554 | 0.22% | ~0.08B | 530 |
|
| 128 |
+
| **Total** | | **45,031,396** | **100%** | **~50.88B** | **681** |
|
| 129 |
+
|
| 130 |
+
> Token estimates use chars÷4. Actual count varies by tokenizer.
|
| 131 |
+
|
| 132 |
+
### Notable observations
|
| 133 |
+
|
| 134 |
+
- **Russian** has the highest average doc length (1,847 words) — Russian web articles in HPLT v3 tend to be substantially longer than other languages.
|
| 135 |
+
- **Icelandic** has unusually long average doc length (1,073 words) for its size tier, similar to Tier 1 languages.
|
| 136 |
+
- **German** has the highest total token share among Latin-script languages (~5.23B) despite ranking 3rd by doc count.
|
| 137 |
+
- **Estonian** (`et` / `est_Latn`) was targeted but is **not present in HPLT v3 sorted collection** and was excluded.
|
| 138 |
+
|
| 139 |
+
## Dataset Fields
|
| 140 |
+
|
| 141 |
+
| Field | Type | Description |
|
| 142 |
+
|---|---|---|
|
| 143 |
+
| `text` | string | Document text |
|
| 144 |
+
| `lang` | string | BCP-47 language code |
|
| 145 |
+
| `url` | string | Source URL |
|
| 146 |
+
| `score` | float | HPLT WDS quality score (raw integer, higher = better; all docs ≥ 10) |
|
| 147 |
+
| `collection` | string | Source MIME type (e.g. `text/html`) |
|
| 148 |
+
| `web-register` | string | Document register/genre code (see Web Registers section) |
|
| 149 |
+
| `prob` | float | Language detection confidence |
|
| 150 |
+
| `char_count` | int | Character count |
|
| 151 |
+
| `word_count` | int | Whitespace-split word count |
|
| 152 |
+
| `doc_id` | string | Unique per-language ID, e.g. `de_0000001` |
|
| 153 |
+
|
| 154 |
+
## Data Splits
|
| 155 |
+
|
| 156 |
+
Split ratios are 98% / 1% / 1% over Parquet shards (250,000 rows per shard, ~180 shards total).
|
| 157 |
+
|
| 158 |
+
| Split | Documents | Shards |
|
| 159 |
+
|---|---:|---:|
|
| 160 |
+
| train | ~44.13M | ~176 |
|
| 161 |
+
| validation | ~450K | ~2 |
|
| 162 |
+
| test | ~450K | ~2 |
|
| 163 |
+
|
| 164 |
+
### Note on Data Completeness
|
| 165 |
+
|
| 166 |
+
One shard (`train-00107-of-00181.parquet`) was removed from the published train
|
| 167 |
+
split because Hugging Face's ClamAV scanner flagged a false-positive malware
|
| 168 |
+
signature (`Email.Trojan.Trojan-939`) on email-like text within the crawled web
|
| 169 |
+
content. Parquet files contain only data and cannot execute code — the flag was
|
| 170 |
+
a byte-pattern match against text in the `text` column, not executable malware.
|
| 171 |
+
As a result, the train split contains 176 shards (~44.0M documents) rather than
|
| 172 |
+
177. Remaining file names keep their original `of-00181` suffix for consistency;
|
| 173 |
+
the `datasets` loader globs all available shards, so this does not affect loading.
|
| 174 |
+
|
| 175 |
+
## How It Was Built
|
| 176 |
+
|
| 177 |
+
**Source:** HPLT v3 sorted shards (`https://data.hplt-project.org/three/sorted`), which order documents by WDS quality score descending — every document in this corpus has a WDS score of 10 or higher.
|
| 178 |
+
|
| 179 |
+
**Quality filtering** (applied inline during download):
|
| 180 |
+
- 50–100,000 characters per document
|
| 181 |
+
- Max 50% non-alphabetic characters (Unicode-aware)
|
| 182 |
+
- Min average word length 2.0 characters
|
| 183 |
+
|
| 184 |
+
**Deduplication:**
|
| 185 |
+
- Exact SHA-256 hash dedup on all languages
|
| 186 |
+
- MinHash near-duplicate removal **disabled** for this release — HPLT v3 already applies global near-deduplication, so re-running MinHash on Indo-European languages adds significant compute for marginal gain. May be re-enabled in a future release.
|
| 187 |
+
|
| 188 |
+
**Merge:** Languages are interleaved according to configured fractions targeting a balanced multilingual corpus. The `merge.py` step uses an adaptive quota algorithm that:
|
| 189 |
+
- Caps each language at its available document count
|
| 190 |
+
- Auto-excludes languages with less than 10% of their target quota (none were excluded in this release except Estonian, which had 0 data)
|
| 191 |
+
- Redistributes excluded quota across the remaining languages
|
| 192 |
+
- Shuffles the final output (deterministic, seed=42)
|
| 193 |
+
|
| 194 |
+
**Pipeline code:** [github.com/ashtok/build-multilingual-corpus](https://github.com/ashtok/build-multilingual-corpus)
|
| 195 |
+
|
| 196 |
+
## Web Register Distribution
|
| 197 |
+
|
| 198 |
+
HPLT v3 labels documents with a register/genre code:
|
| 199 |
+
|
| 200 |
+
| Register | Count | % | Meaning |
|
| 201 |
+
|---|---:|---:|---|
|
| 202 |
+
| IP | 14,245,000 | 31.6% | Informational persuasion |
|
| 203 |
+
| NA | 10,847,574 | 24.1% | Narrative |
|
| 204 |
+
| IN | 8,232,732 | 18.3% | Informational description |
|
| 205 |
+
| MT | 3,810,850 | 8.5% | Machine-translated |
|
| 206 |
+
| ID | 1,926,908 | 4.3% | Interactive discussion |
|
| 207 |
+
| OP | 1,823,791 | 4.1% | Opinion |
|
| 208 |
+
| HI | 1,220,284 | 2.7% | How-to / instructional |
|
| 209 |
+
| unknown | 1,176,071 | 2.6% | Unclassified |
|
| 210 |
+
| LY | 233,724 | 0.5% | Lyrical |
|
| 211 |
+
|
| 212 |
+
> To exclude machine-translated content, filter on `web-register != "MT"` (drops ~8.5%).
|
| 213 |
+
|
| 214 |
+
## Source Collection Types
|
| 215 |
+
|
| 216 |
+
| Collection | Count |
|
| 217 |
+
|---|---:|
|
| 218 |
+
| `text/html` | 44,927,249 |
|
| 219 |
+
| `application/atom+xml` | 46,512 |
|
| 220 |
+
| `application/xml` | 22,690 |
|
| 221 |
+
| (empty) | 16,567 |
|
| 222 |
+
| `application/xhtml+xml` | 6,492 |
|
| 223 |
+
| `application/vnd.oasis.opendocument.text` | 2,708 |
|
| 224 |
+
| `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` | 2,643 |
|
| 225 |
+
| `text/plain` | 1,771 |
|
| 226 |
+
| `application/rss+xml` | 1,700 |
|
| 227 |
+
| `application/epub+zip` | 1,407 |
|
| 228 |
+
|
| 229 |
+
99.8% of documents are HTML.
|
| 230 |
+
|
| 231 |
+
## Corpus Statistics Summary
|
| 232 |
+
|
| 233 |
+
| Metric | Value |
|
| 234 |
+
|---|---:|
|
| 235 |
+
| Total documents | 45,031,396 |
|
| 236 |
+
| Total characters | 203.5B |
|
| 237 |
+
| Total words | 30.7B |
|
| 238 |
+
| Estimated tokens | ~50.9B |
|
| 239 |
+
| Avg doc length (words) | 681 |
|
| 240 |
+
| Median doc length (words) | 264 |
|
| 241 |
+
| Min doc length (words) | 6 |
|
| 242 |
+
| Max doc length (words) | 26,373 |
|
| 243 |
+
|
| 244 |
+
## Limitations
|
| 245 |
+
|
| 246 |
+
- **Web text only** — no books, Wikipedia, or structured data
|
| 247 |
+
- **~8.5% machine-translated content** — identifiable via `web-register: MT`
|
| 248 |
+
- **No Estonian** — language unavailable in HPLT v3 sorted collection at corpus build time
|
| 249 |
+
- **No MinHash near-dedup** — exact dedup only (HPLT v3 already applies global near-dedup)
|
| 250 |
+
- **Tier-6 languages are data-limited** — Occitan, Scottish Gaelic, Faroese, Asturian have <250K docs each
|
| 251 |
+
- **Russian has only 1.05M docs** — substantially less than other Tier-1 languages because HPLT v3 sorted shards exhausted at this quality level
|
| 252 |
+
- **No PII filtering beyond HPLT defaults**
|
| 253 |
+
- **Language proportions are partially balanced, not natural** — high-resource languages are slightly down-weighted versus their raw web share to give more space to mid/low-resource languages
|
| 254 |
+
|
| 255 |
+
## Comparison with Related Corpora
|
| 256 |
+
|
| 257 |
+
| Corpus | Docs | Languages | Quality bar | Source |
|
| 258 |
+
|---|---:|---:|---|---|
|
| 259 |
+
| **European HPLT v1** | **45.0M** | **41** | WDS ≥ 10 | HPLT v3 |
|
| 260 |
+
| HPLT v3 (raw) | ~21B | 191 | None | HPLT v3 |
|
| 261 |
+
| CulturaX | 6.3T tokens | 167 | Heuristic | mC4 + OSCAR |
|
| 262 |
+
| RedPajama-v2 | 30T tokens | 5 | Quality signals | Common Crawl |
|
| 263 |
+
| OSCAR 23.01 | ~9.8B | 151 | None | Common Crawl |
|
| 264 |
+
|
| 265 |
+
This corpus trades scale for quality: every document is pre-filtered to the top WDS tier and the language mix is tilted to include lower-resource European languages that are underrepresented in other multilingual corpora.
|
| 266 |
+
|
| 267 |
+
## Citation
|
| 268 |
+
|
| 269 |
+
```bibtex
|
| 270 |
+
@dataset{europeanHPLTv1_2026,
|
| 271 |
+
author = {Mahajan, Ashutosh},
|
| 272 |
+
title = {European {HPLT} v1: A 45M-document Multilingual Corpus for 41 European Languages},
|
| 273 |
+
year = {2026},
|
| 274 |
+
publisher = {Hugging Face},
|
| 275 |
+
url = {https://huggingface.co/datasets/ashtok897/european-hplt-v1}
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
@article{oepen2025hplt,
|
| 279 |
+
title = {{HPLT} 3.0: Very Large-Scale Multilingual Resources for {LLM} and {MT}},
|
| 280 |
+
author = {Oepen, Stephan and others},
|
| 281 |
+
journal = {arXiv preprint arXiv:2511.01066},
|
| 282 |
+
year = {2025}
|
| 283 |
+
}
|
| 284 |
+
```
|
| 285 |
+
|
| 286 |
+
## License
|
| 287 |
+
|
| 288 |
+
[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) — inherited from HPLT v3.
|
artifacts/source_candidate_audit_v0_3.json
CHANGED
|
@@ -1,4 +1,109 @@
|
|
| 1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
{
|
| 3 |
"repo_id": "PleIAs/common_corpus",
|
| 4 |
"configured_decision": "accept_after_subset_review",
|
|
|
|
| 1 |
[
|
| 2 |
+
{
|
| 3 |
+
"repo_id": "ashtok897/european-hplt-v1",
|
| 4 |
+
"configured_decision": "accept_after_web_review",
|
| 5 |
+
"target_bucket": "bulk_pretraining_web",
|
| 6 |
+
"priority": "high",
|
| 7 |
+
"notes": "European HPLT v1 has Polish web data (~1.89M docs / ~1.98B estimated tokens) with WDS quality score, language confidence, URL, MIME type, and web-register metadata. HF card/license says CC0-1.0 inherited from HPLT v3; keep web-crawl caveat, URL provenance, domain filtering, machine-translation filtering, and downstream dedup.",
|
| 8 |
+
"gated": false,
|
| 9 |
+
"private": false,
|
| 10 |
+
"downloads": 749,
|
| 11 |
+
"license_tags": [
|
| 12 |
+
"cc0-1.0"
|
| 13 |
+
],
|
| 14 |
+
"language_tags": [
|
| 15 |
+
"en",
|
| 16 |
+
"fr",
|
| 17 |
+
"de",
|
| 18 |
+
"es",
|
| 19 |
+
"pt",
|
| 20 |
+
"it",
|
| 21 |
+
"nl",
|
| 22 |
+
"pl",
|
| 23 |
+
"cs",
|
| 24 |
+
"uk",
|
| 25 |
+
"sv",
|
| 26 |
+
"ro",
|
| 27 |
+
"hu",
|
| 28 |
+
"el",
|
| 29 |
+
"da",
|
| 30 |
+
"nb",
|
| 31 |
+
"sk",
|
| 32 |
+
"fi",
|
| 33 |
+
"bg",
|
| 34 |
+
"ru",
|
| 35 |
+
"ca",
|
| 36 |
+
"lt",
|
| 37 |
+
"lv",
|
| 38 |
+
"sl",
|
| 39 |
+
"hr",
|
| 40 |
+
"sr",
|
| 41 |
+
"mk",
|
| 42 |
+
"bs",
|
| 43 |
+
"be",
|
| 44 |
+
"gl",
|
| 45 |
+
"eu",
|
| 46 |
+
"nn",
|
| 47 |
+
"is",
|
| 48 |
+
"cy",
|
| 49 |
+
"mt",
|
| 50 |
+
"lb",
|
| 51 |
+
"ga",
|
| 52 |
+
"ast",
|
| 53 |
+
"fo",
|
| 54 |
+
"gd",
|
| 55 |
+
"oc"
|
| 56 |
+
],
|
| 57 |
+
"size_tags": [
|
| 58 |
+
"10M<n<100M"
|
| 59 |
+
],
|
| 60 |
+
"task_tags": [
|
| 61 |
+
"text-generation",
|
| 62 |
+
"fill-mask"
|
| 63 |
+
],
|
| 64 |
+
"readme_license_lines": [
|
| 65 |
+
"license: cc0-1.0",
|
| 66 |
+
"## Limitations",
|
| 67 |
+
"- **Tier-6 languages are data-limited** — Occitan, Scottish Gaelic, Faroese, Asturian have <250K docs each",
|
| 68 |
+
"## License",
|
| 69 |
+
"[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) — inherited from HPLT v3."
|
| 70 |
+
],
|
| 71 |
+
"warnings": [
|
| 72 |
+
"unknown"
|
| 73 |
+
],
|
| 74 |
+
"sample_files": [
|
| 75 |
+
".gitattributes",
|
| 76 |
+
"README.md",
|
| 77 |
+
"data/test/train-00179-of-00181.parquet",
|
| 78 |
+
"data/test/train-00180-of-00181.parquet",
|
| 79 |
+
"data/train/train-00000-of-00181.parquet",
|
| 80 |
+
"data/train/train-00001-of-00181.parquet",
|
| 81 |
+
"data/train/train-00002-of-00181.parquet",
|
| 82 |
+
"data/train/train-00003-of-00181.parquet",
|
| 83 |
+
"data/train/train-00004-of-00181.parquet",
|
| 84 |
+
"data/train/train-00005-of-00181.parquet",
|
| 85 |
+
"data/train/train-00006-of-00181.parquet",
|
| 86 |
+
"data/train/train-00007-of-00181.parquet",
|
| 87 |
+
"data/train/train-00008-of-00181.parquet",
|
| 88 |
+
"data/train/train-00009-of-00181.parquet",
|
| 89 |
+
"data/train/train-00010-of-00181.parquet",
|
| 90 |
+
"data/train/train-00011-of-00181.parquet",
|
| 91 |
+
"data/train/train-00012-of-00181.parquet",
|
| 92 |
+
"data/train/train-00013-of-00181.parquet",
|
| 93 |
+
"data/train/train-00014-of-00181.parquet",
|
| 94 |
+
"data/train/train-00015-of-00181.parquet",
|
| 95 |
+
"data/train/train-00016-of-00181.parquet",
|
| 96 |
+
"data/train/train-00017-of-00181.parquet",
|
| 97 |
+
"data/train/train-00018-of-00181.parquet",
|
| 98 |
+
"data/train/train-00019-of-00181.parquet",
|
| 99 |
+
"data/train/train-00020-of-00181.parquet",
|
| 100 |
+
"data/train/train-00021-of-00181.parquet",
|
| 101 |
+
"data/train/train-00022-of-00181.parquet",
|
| 102 |
+
"data/train/train-00023-of-00181.parquet",
|
| 103 |
+
"data/train/train-00024-of-00181.parquet",
|
| 104 |
+
"data/train/train-00025-of-00181.parquet"
|
| 105 |
+
]
|
| 106 |
+
},
|
| 107 |
{
|
| 108 |
"repo_id": "PleIAs/common_corpus",
|
| 109 |
"configured_decision": "accept_after_subset_review",
|
artifacts/source_candidate_audit_v0_3.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
| repo | decision | bucket | license tags | gated | warnings |
|
| 4 |
|---|---|---|---|---:|---|
|
|
|
|
| 5 |
| `PleIAs/common_corpus` | `accept_after_subset_review` | `bulk_pretraining` | `none` | `False` | `-` |
|
| 6 |
| `PleIAs/Polish-PD` | `accept_after_ocr_review` | `bulk_pretraining` | `none` | `False` | `-` |
|
| 7 |
| `pelcra/PLLuMIC` | `accept_gated` | `final_phase_sft` | `cc-by-sa-4.0` | `auto` | `-` |
|
|
@@ -19,6 +20,23 @@
|
|
| 19 |
| `allegro/summarization-polish-summaries-corpus` | `reject_until_license` | `summarization` | `none` | `False` | `-` |
|
| 20 |
| `allegro/polish-question-passage-pairs` | `reject_until_license` | `qa_eval_final_phase` | `none` | `False` | `-` |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
## PleIAs/common_corpus
|
| 23 |
|
| 24 |
- decision: `accept_after_subset_review`
|
|
|
|
| 2 |
|
| 3 |
| repo | decision | bucket | license tags | gated | warnings |
|
| 4 |
|---|---|---|---|---:|---|
|
| 5 |
+
| `ashtok897/european-hplt-v1` | `accept_after_web_review` | `bulk_pretraining_web` | `cc0-1.0` | `False` | `unknown` |
|
| 6 |
| `PleIAs/common_corpus` | `accept_after_subset_review` | `bulk_pretraining` | `none` | `False` | `-` |
|
| 7 |
| `PleIAs/Polish-PD` | `accept_after_ocr_review` | `bulk_pretraining` | `none` | `False` | `-` |
|
| 8 |
| `pelcra/PLLuMIC` | `accept_gated` | `final_phase_sft` | `cc-by-sa-4.0` | `auto` | `-` |
|
|
|
|
| 20 |
| `allegro/summarization-polish-summaries-corpus` | `reject_until_license` | `summarization` | `none` | `False` | `-` |
|
| 21 |
| `allegro/polish-question-passage-pairs` | `reject_until_license` | `qa_eval_final_phase` | `none` | `False` | `-` |
|
| 22 |
|
| 23 |
+
## ashtok897/european-hplt-v1
|
| 24 |
+
|
| 25 |
+
- decision: `accept_after_web_review`
|
| 26 |
+
- bucket: `bulk_pretraining_web`
|
| 27 |
+
- priority: `high`
|
| 28 |
+
- license tags: `cc0-1.0`
|
| 29 |
+
- language tags: `en, fr, de, es, pt, it, nl, pl, cs, uk, sv, ro, hu, el, da, nb, sk, fi, bg, ru, ca, lt, lv, sl, hr, sr, mk, bs, be, gl, eu, nn, is, cy, mt, lb, ga, ast, fo, gd, oc`
|
| 30 |
+
- gated: `False`
|
| 31 |
+
- notes: European HPLT v1 has Polish web data (~1.89M docs / ~1.98B estimated tokens) with WDS quality score, language confidence, URL, MIME type, and web-register metadata. HF card/license says CC0-1.0 inherited from HPLT v3; keep web-crawl caveat, URL provenance, domain filtering, machine-translation filtering, and downstream dedup.
|
| 32 |
+
|
| 33 |
+
README/license signals:
|
| 34 |
+
- license: cc0-1.0
|
| 35 |
+
- ## Limitations
|
| 36 |
+
- - **Tier-6 languages are data-limited** — Occitan, Scottish Gaelic, Faroese, Asturian have <250K docs each
|
| 37 |
+
- ## License
|
| 38 |
+
- [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) — inherited from HPLT v3.
|
| 39 |
+
|
| 40 |
## PleIAs/common_corpus
|
| 41 |
|
| 42 |
- decision: `accept_after_subset_review`
|
artifacts/source_license_review_v0_3.md
CHANGED
|
@@ -8,6 +8,7 @@ Scope: candidate sources for a larger, more diverse, more natural Polish DynaWor
|
|
| 8 |
|
| 9 |
| source | bucket | decision | license evidence | main risk / condition |
|
| 10 |
|---|---|---|---|---|
|
|
|
|
| 11 |
| `PleIAs/common_corpus` | bulk pretraining | `accept_after_subset_review` | Card says Common Corpus contains only uncopyrighted or freely licensed data, document-level contextual/license metadata, and commercial/non-commercial use. | Filter Polish records by `license`, source/domain, quality, and duplicate overlap. |
|
| 12 |
| `PleIAs/Polish-PD` | bulk pretraining | `accept_after_ocr_review` | Card says entire collection is public domain in all regions and describes EU public-domain criteria. | Strong OCR-noise risk; sample first, then aggressive OCR filtering. |
|
| 13 |
| `pelcra/PLLuMIC` | final phase / SFT | `accept_gated` | HF card: `CC-BY-SA-4.0`, Polish, hand-crafted instructions, professional annotators and review. | Gated; small and instruction-formatted, so not bulk pretraining. |
|
|
@@ -40,11 +41,12 @@ Operational result: keep `WiktorS/polish-news` out of the clean open corpus. Rev
|
|
| 40 |
|
| 41 |
## Import order
|
| 42 |
|
| 43 |
-
1. `
|
| 44 |
-
2. `PleIAs/
|
| 45 |
-
3. `
|
| 46 |
-
4. `
|
| 47 |
-
5. `
|
|
|
|
| 48 |
|
| 49 |
## Required gates before publish
|
| 50 |
|
|
|
|
| 8 |
|
| 9 |
| source | bucket | decision | license evidence | main risk / condition |
|
| 10 |
|---|---|---|---|---|
|
| 11 |
+
| `ashtok897/european-hplt-v1` | bulk pretraining web | `accept_after_web_review` | HF card/license says `CC0-1.0`, inherited from HPLT v3. The card reports Polish `pl`: 1,891,358 docs and ~1.98B estimated tokens, with URL, WDS score, language confidence, MIME type, and web-register metadata. | Web-crawl provenance/copyright risk remains; require URL retention, domain filtering, MT filtering, exact/near dedup, and quality/style probes. |
|
| 12 |
| `PleIAs/common_corpus` | bulk pretraining | `accept_after_subset_review` | Card says Common Corpus contains only uncopyrighted or freely licensed data, document-level contextual/license metadata, and commercial/non-commercial use. | Filter Polish records by `license`, source/domain, quality, and duplicate overlap. |
|
| 13 |
| `PleIAs/Polish-PD` | bulk pretraining | `accept_after_ocr_review` | Card says entire collection is public domain in all regions and describes EU public-domain criteria. | Strong OCR-noise risk; sample first, then aggressive OCR filtering. |
|
| 14 |
| `pelcra/PLLuMIC` | final phase / SFT | `accept_gated` | HF card: `CC-BY-SA-4.0`, Polish, hand-crafted instructions, professional annotators and review. | Gated; small and instruction-formatted, so not bulk pretraining. |
|
|
|
|
| 41 |
|
| 42 |
## Import order
|
| 43 |
|
| 44 |
+
1. `ashtok897/european-hplt-v1`: stream-filter `lang=pl`, remove machine-translated/high-boilerplate/domain-blacklisted records, keep URL provenance.
|
| 45 |
+
2. `PleIAs/common_corpus`: inspect Polish subset metadata and select natural, non-legal, non-code records with acceptable license values.
|
| 46 |
+
3. `PleIAs/Polish-PD`: sample OCR quality and filter aggressively.
|
| 47 |
+
4. `pelcra/PLLuMIC`: accept gated terms and import as `dialogue_sft` / final-phase source.
|
| 48 |
+
5. `ipipan/polqa`, `clarin-pl/poquad`, `clarin-pl/PUGG`, `clarin-pl/ComplexQA`: import as QA/eval/final-phase buckets after dedup.
|
| 49 |
+
6. `oscar-corpus/mOSCAR`: only if the above is not enough for modern web diversity and legal review is acceptable.
|
| 50 |
|
| 51 |
## Required gates before publish
|
| 52 |
|
artifacts/source_scouting_v0_3.md
CHANGED
|
@@ -6,6 +6,7 @@ Goal: improve training quality by adding contemporary, diverse Polish while keep
|
|
| 6 |
|
| 7 |
| candidate | type | license/status | why useful | action |
|
| 8 |
|---|---|---|---|---|
|
|
|
|
| 9 |
| `PleIAs/common_corpus` | multilingual open corpus | open/traceable per card | large Polish component, diverse domains, provenance-oriented | inspect Polish subset metadata, dedup against existing data |
|
| 10 |
| `PleIAs/Polish-PD` | Polish public-domain books/newspapers | public-domain collection, license must be verified per card/source | large, traceable cultural/news-ish historical text; already separate Polish subset | sample OCR quality before inclusion |
|
| 11 |
| `pelcra/PLLuMIC` | Polish instruction/dialogue | `CC-BY-SA-4.0`, gated | high-quality hand-crafted Polish instructions/dialogues | use for SFT/final quality phase, not bulk pretraining |
|
|
@@ -41,12 +42,13 @@ Goal: improve training quality by adding contemporary, diverse Polish while keep
|
|
| 41 |
|
| 42 |
## Next import order
|
| 43 |
|
| 44 |
-
1.
|
| 45 |
-
2. Inspect and sample `PleIAs/
|
| 46 |
-
3.
|
| 47 |
-
4. Add
|
| 48 |
-
5.
|
| 49 |
-
6.
|
|
|
|
| 50 |
|
| 51 |
## TVP Info review note
|
| 52 |
|
|
|
|
| 6 |
|
| 7 |
| candidate | type | license/status | why useful | action |
|
| 8 |
|---|---|---|---|---|
|
| 9 |
+
| `ashtok897/european-hplt-v1` | high-quality European web crawl | `CC0-1.0` per HF card, inherited from HPLT v3; web-crawl caveat | strongest current candidate for modern/natural Polish: ~1.89M PL docs / ~1.98B estimated PL tokens, URL + score + register metadata | stream-filter `pl`, exclude MT, spam, boilerplate, legalish, domain-blacklisted records; keep URL provenance |
|
| 10 |
| `PleIAs/common_corpus` | multilingual open corpus | open/traceable per card | large Polish component, diverse domains, provenance-oriented | inspect Polish subset metadata, dedup against existing data |
|
| 11 |
| `PleIAs/Polish-PD` | Polish public-domain books/newspapers | public-domain collection, license must be verified per card/source | large, traceable cultural/news-ish historical text; already separate Polish subset | sample OCR quality before inclusion |
|
| 12 |
| `pelcra/PLLuMIC` | Polish instruction/dialogue | `CC-BY-SA-4.0`, gated | high-quality hand-crafted Polish instructions/dialogues | use for SFT/final quality phase, not bulk pretraining |
|
|
|
|
| 42 |
|
| 43 |
## Next import order
|
| 44 |
|
| 45 |
+
1. Filter `ashtok897/european-hplt-v1` Polish web records with `src/filter_european_hplt.py`.
|
| 46 |
+
2. Inspect and sample `PleIAs/common_corpus` Polish records.
|
| 47 |
+
3. Inspect and sample `PleIAs/Polish-PD`; measure OCR garbage and duplicate overlap.
|
| 48 |
+
4. Add `pelcra/PLLuMIC` as `dialogue_sft` / high-quality final-phase source after accepting HF access terms.
|
| 49 |
+
5. Add QA/eval buckets from `ipipan/polqa`, `clarin-pl/poquad`, `clarin-pl/PUGG`, `clarin-pl/ComplexQA`.
|
| 50 |
+
6. Review `WiktorS/polish-news` provenance before considering contemporary news.
|
| 51 |
+
7. Treat OSCAR/mOSCAR as fallback web source only after license review, boilerplate removal, language filtering, URL/domain filtering, and near-dedup.
|
| 52 |
|
| 53 |
## TVP Info review note
|
| 54 |
|
configs/source_candidates_v0_3.json
CHANGED
|
@@ -27,6 +27,13 @@
|
|
| 27 |
]
|
| 28 |
},
|
| 29 |
"candidates": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
{
|
| 31 |
"repo_id": "PleIAs/common_corpus",
|
| 32 |
"target_bucket": "bulk_pretraining",
|
|
|
|
| 27 |
]
|
| 28 |
},
|
| 29 |
"candidates": [
|
| 30 |
+
{
|
| 31 |
+
"repo_id": "ashtok897/european-hplt-v1",
|
| 32 |
+
"target_bucket": "bulk_pretraining_web",
|
| 33 |
+
"priority": "high",
|
| 34 |
+
"decision": "accept_after_web_review",
|
| 35 |
+
"notes": "European HPLT v1 has Polish web data (~1.89M docs / ~1.98B estimated tokens) with WDS quality score, language confidence, URL, MIME type, and web-register metadata. HF card/license says CC0-1.0 inherited from HPLT v3; keep web-crawl caveat, URL provenance, domain filtering, machine-translation filtering, and downstream dedup."
|
| 36 |
+
},
|
| 37 |
{
|
| 38 |
"repo_id": "PleIAs/common_corpus",
|
| 39 |
"target_bucket": "bulk_pretraining",
|
src/filter_common_corpus.py
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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- keep Polish records with acceptable open licenses,
|
| 6 |
+
- default to natural/diverse written text,
|
| 7 |
+
- skip legal/government, code, semantic data, and existing Wikipedia duplicates,
|
| 8 |
+
- write bounded parquet shards without downloading the full 4.5 TB dataset.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import argparse
|
| 14 |
+
import json
|
| 15 |
+
import re
|
| 16 |
+
import time
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
import pyarrow as pa
|
| 20 |
+
import pyarrow.parquet as pq
|
| 21 |
+
from datasets import load_dataset
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
ADDED = "2026-06-16"
|
| 25 |
+
DEFAULT_ALLOWED_LICENSES = {
|
| 26 |
+
"CC0",
|
| 27 |
+
"CC-By",
|
| 28 |
+
"CC-By-SA",
|
| 29 |
+
"Public Domain",
|
| 30 |
+
"MIT",
|
| 31 |
+
"Apache",
|
| 32 |
+
"Apache-2.0",
|
| 33 |
+
"BSD",
|
| 34 |
+
"Open License",
|
| 35 |
+
}
|
| 36 |
+
DEFAULT_EXCLUDED_OPEN_TYPES = {
|
| 37 |
+
"Open Government",
|
| 38 |
+
"Open Source",
|
| 39 |
+
"Semantic data",
|
| 40 |
+
}
|
| 41 |
+
DEFAULT_EXCLUDED_COLLECTIONS = {
|
| 42 |
+
"Wikipedia",
|
| 43 |
+
"Wikidata",
|
| 44 |
+
"VoxPopuli",
|
| 45 |
+
}
|
| 46 |
+
LEGALISH_RE = re.compile(
|
| 47 |
+
r"\b("
|
| 48 |
+
r"court|cour|tribunal|judgment|judgement|hansard|parliament|commission|"
|
| 49 |
+
r"european parliament|legal|law|case law|eur-lex|sejm|senat|"
|
| 50 |
+
r"sąd|trybunał|wyrok|ustawa|rozporządzenie|parlament"
|
| 51 |
+
r")\b",
|
| 52 |
+
re.I,
|
| 53 |
+
)
|
| 54 |
+
BOILERPLATE_RE = re.compile(
|
| 55 |
+
r"(cookies?|privacy policy|terms of use|all rights reserved|"
|
| 56 |
+
r"polityka prywatności|regulamin|wszelkie prawa zastrzeżone)",
|
| 57 |
+
re.I,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
SCHEMA = pa.schema(
|
| 61 |
+
[
|
| 62 |
+
("id", pa.string()),
|
| 63 |
+
("text", pa.string()),
|
| 64 |
+
("source", pa.string()),
|
| 65 |
+
("added", pa.string()),
|
| 66 |
+
("created", pa.string()),
|
| 67 |
+
("token_count", pa.int64()),
|
| 68 |
+
("common_corpus_identifier", pa.string()),
|
| 69 |
+
("common_corpus_collection", pa.string()),
|
| 70 |
+
("common_corpus_open_type", pa.string()),
|
| 71 |
+
("common_corpus_license", pa.string()),
|
| 72 |
+
("common_corpus_title", pa.string()),
|
| 73 |
+
("common_corpus_creator", pa.string()),
|
| 74 |
+
]
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def parse_csv_set(value: str | None) -> set[str]:
|
| 79 |
+
if not value:
|
| 80 |
+
return set()
|
| 81 |
+
return {item.strip() for item in value.split(",") if item.strip()}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def license_allowed(license_value: str | None, allowed: set[str]) -> bool:
|
| 85 |
+
if not license_value:
|
| 86 |
+
return False
|
| 87 |
+
normalized = license_value.strip().lower()
|
| 88 |
+
return any(normalized == item.lower() or normalized.startswith(item.lower()) for item in allowed)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def is_legalish(row: dict) -> bool:
|
| 92 |
+
fields = " ".join(
|
| 93 |
+
str(row.get(k) or "")
|
| 94 |
+
for k in ["collection", "open_type", "title", "creator", "identifier"]
|
| 95 |
+
)
|
| 96 |
+
return bool(LEGALISH_RE.search(fields))
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def is_boilerplate_heavy(text: str) -> bool:
|
| 100 |
+
sample = text[:5000]
|
| 101 |
+
hits = len(BOILERPLATE_RE.findall(sample))
|
| 102 |
+
return hits >= 3
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def keep_row(row: dict, args: argparse.Namespace, allowed_licenses: set[str]) -> tuple[bool, str]:
|
| 106 |
+
if row.get("language") != "Polish":
|
| 107 |
+
return False, "language"
|
| 108 |
+
if args.written_only and row.get("language_type") != "Written":
|
| 109 |
+
return False, "language_type"
|
| 110 |
+
if not license_allowed(row.get("license"), allowed_licenses):
|
| 111 |
+
return False, "license"
|
| 112 |
+
if row.get("open_type") in args.exclude_open_type:
|
| 113 |
+
return False, "open_type"
|
| 114 |
+
if row.get("collection") in args.exclude_collection:
|
| 115 |
+
return False, "collection"
|
| 116 |
+
if not args.include_legalish and is_legalish(row):
|
| 117 |
+
return False, "legalish"
|
| 118 |
+
|
| 119 |
+
text = (row.get("text") or "").strip()
|
| 120 |
+
if len(text) < args.min_chars:
|
| 121 |
+
return False, "short"
|
| 122 |
+
if row.get("token_count") and int(row["token_count"]) < args.min_tokens:
|
| 123 |
+
return False, "few_tokens"
|
| 124 |
+
if is_boilerplate_heavy(text):
|
| 125 |
+
return False, "boilerplate"
|
| 126 |
+
return True, "kept"
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
def write_batch(writer: pq.ParquetWriter, batch: list[dict], source_name: str) -> int:
|
| 130 |
+
records = {
|
| 131 |
+
"id": [],
|
| 132 |
+
"text": [],
|
| 133 |
+
"source": [],
|
| 134 |
+
"added": [],
|
| 135 |
+
"created": [],
|
| 136 |
+
"token_count": [],
|
| 137 |
+
"common_corpus_identifier": [],
|
| 138 |
+
"common_corpus_collection": [],
|
| 139 |
+
"common_corpus_open_type": [],
|
| 140 |
+
"common_corpus_license": [],
|
| 141 |
+
"common_corpus_title": [],
|
| 142 |
+
"common_corpus_creator": [],
|
| 143 |
+
}
|
| 144 |
+
for idx, row in batch:
|
| 145 |
+
records["id"].append(f"{source_name}_{idx}")
|
| 146 |
+
records["text"].append((row.get("text") or "").strip())
|
| 147 |
+
records["source"].append(source_name)
|
| 148 |
+
records["added"].append(ADDED)
|
| 149 |
+
records["created"].append(str(row.get("date") or ""))
|
| 150 |
+
records["token_count"].append(int(row.get("token_count") or 0))
|
| 151 |
+
records["common_corpus_identifier"].append(str(row.get("identifier") or ""))
|
| 152 |
+
records["common_corpus_collection"].append(str(row.get("collection") or ""))
|
| 153 |
+
records["common_corpus_open_type"].append(str(row.get("open_type") or ""))
|
| 154 |
+
records["common_corpus_license"].append(str(row.get("license") or ""))
|
| 155 |
+
records["common_corpus_title"].append(str(row.get("title") or ""))
|
| 156 |
+
records["common_corpus_creator"].append(str(row.get("creator") or ""))
|
| 157 |
+
|
| 158 |
+
table = pa.table(records, schema=SCHEMA)
|
| 159 |
+
writer.write_table(table)
|
| 160 |
+
return sum(records["token_count"])
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def parse_args() -> argparse.Namespace:
|
| 164 |
+
ap = argparse.ArgumentParser()
|
| 165 |
+
ap.add_argument("--repo-id", default="PleIAs/common_corpus")
|
| 166 |
+
ap.add_argument("--split", default="train")
|
| 167 |
+
ap.add_argument(
|
| 168 |
+
"--data-files",
|
| 169 |
+
default="hf://datasets/PleIAs/common_corpus/common_corpus_*/*.parquet",
|
| 170 |
+
help="Parquet glob. The dataset default loader only exposes one shard; use this glob for the full corpus.",
|
| 171 |
+
)
|
| 172 |
+
ap.add_argument("--out-dir", type=Path, default=Path("data/common_corpus_pl"))
|
| 173 |
+
ap.add_argument("--source-name", default="common_corpus_pl")
|
| 174 |
+
ap.add_argument("--max-records", type=int, default=10000)
|
| 175 |
+
ap.add_argument("--max-tokens", type=int, default=50_000_000)
|
| 176 |
+
ap.add_argument("--batch-size", type=int, default=1000)
|
| 177 |
+
ap.add_argument("--min-chars", type=int, default=300)
|
| 178 |
+
ap.add_argument("--min-tokens", type=int, default=80)
|
| 179 |
+
ap.add_argument("--allowed-licenses", default=",".join(sorted(DEFAULT_ALLOWED_LICENSES)))
|
| 180 |
+
ap.add_argument("--exclude-open-type", default=",".join(sorted(DEFAULT_EXCLUDED_OPEN_TYPES)))
|
| 181 |
+
ap.add_argument("--exclude-collection", default=",".join(sorted(DEFAULT_EXCLUDED_COLLECTIONS)))
|
| 182 |
+
ap.add_argument("--include-legalish", action="store_true")
|
| 183 |
+
ap.add_argument("--include-wikipedia", action="store_true")
|
| 184 |
+
ap.add_argument("--include-government", action="store_true")
|
| 185 |
+
ap.add_argument("--written-only", action=argparse.BooleanOptionalAction, default=True)
|
| 186 |
+
ap.add_argument("--dry-run", action="store_true")
|
| 187 |
+
return ap.parse_args()
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def main() -> None:
|
| 191 |
+
args = parse_args()
|
| 192 |
+
args.exclude_open_type = parse_csv_set(args.exclude_open_type)
|
| 193 |
+
args.exclude_collection = parse_csv_set(args.exclude_collection)
|
| 194 |
+
if args.include_wikipedia:
|
| 195 |
+
args.exclude_collection.discard("Wikipedia")
|
| 196 |
+
if args.include_government:
|
| 197 |
+
args.exclude_open_type.discard("Open Government")
|
| 198 |
+
args.exclude_collection.discard("VoxPopuli")
|
| 199 |
+
allowed_licenses = parse_csv_set(args.allowed_licenses)
|
| 200 |
+
|
| 201 |
+
args.out_dir.mkdir(parents=True, exist_ok=True)
|
| 202 |
+
out_parquet = args.out_dir / f"{args.source_name}.parquet"
|
| 203 |
+
out_stats = args.out_dir / f"{args.source_name}.stats.json"
|
| 204 |
+
out_datasheet = args.out_dir / f"{args.source_name}.md"
|
| 205 |
+
|
| 206 |
+
if args.data_files:
|
| 207 |
+
ds = load_dataset("parquet", data_files=args.data_files, split=args.split, streaming=True)
|
| 208 |
+
else:
|
| 209 |
+
ds = load_dataset(args.repo_id, split=args.split, streaming=True)
|
| 210 |
+
stats = {
|
| 211 |
+
"read": 0,
|
| 212 |
+
"kept": 0,
|
| 213 |
+
"tokens": 0,
|
| 214 |
+
"chars": 0,
|
| 215 |
+
"drop": {},
|
| 216 |
+
"licenses": {},
|
| 217 |
+
"collections": {},
|
| 218 |
+
"open_types": {},
|
| 219 |
+
"source_repo": args.repo_id,
|
| 220 |
+
"license": "per-record open license from PleIAs/common_corpus metadata",
|
| 221 |
+
"allowed_licenses": sorted(allowed_licenses),
|
| 222 |
+
"excluded_open_types": sorted(args.exclude_open_type),
|
| 223 |
+
"excluded_collections": sorted(args.exclude_collection),
|
| 224 |
+
}
|
| 225 |
+
t0 = time.time()
|
| 226 |
+
writer = None
|
| 227 |
+
batch: list[tuple[int, dict]] = []
|
| 228 |
+
next_id = 0
|
| 229 |
+
try:
|
| 230 |
+
if not args.dry_run:
|
| 231 |
+
writer = pq.ParquetWriter(out_parquet, SCHEMA, compression="zstd")
|
| 232 |
+
for row in ds:
|
| 233 |
+
stats["read"] += 1
|
| 234 |
+
keep, reason = keep_row(row, args, allowed_licenses)
|
| 235 |
+
if not keep:
|
| 236 |
+
stats["drop"][reason] = stats["drop"].get(reason, 0) + 1
|
| 237 |
+
continue
|
| 238 |
+
|
| 239 |
+
batch.append((next_id, row))
|
| 240 |
+
next_id += 1
|
| 241 |
+
stats["kept"] += 1
|
| 242 |
+
stats["chars"] += len((row.get("text") or "").strip())
|
| 243 |
+
stats["licenses"][row.get("license") or ""] = stats["licenses"].get(row.get("license") or "", 0) + 1
|
| 244 |
+
stats["collections"][row.get("collection") or ""] = stats["collections"].get(row.get("collection") or "", 0) + 1
|
| 245 |
+
stats["open_types"][row.get("open_type") or ""] = stats["open_types"].get(row.get("open_type") or "", 0) + 1
|
| 246 |
+
|
| 247 |
+
if len(batch) >= args.batch_size:
|
| 248 |
+
stats["tokens"] += sum(int(item[1].get("token_count") or 0) for item in batch)
|
| 249 |
+
if writer:
|
| 250 |
+
write_batch(writer, batch, args.source_name)
|
| 251 |
+
batch.clear()
|
| 252 |
+
|
| 253 |
+
if stats["kept"] >= args.max_records or stats["tokens"] >= args.max_tokens:
|
| 254 |
+
break
|
| 255 |
+
finally:
|
| 256 |
+
if batch:
|
| 257 |
+
stats["tokens"] += sum(int(item[1].get("token_count") or 0) for item in batch)
|
| 258 |
+
if writer:
|
| 259 |
+
write_batch(writer, batch, args.source_name)
|
| 260 |
+
if writer:
|
| 261 |
+
writer.close()
|
| 262 |
+
|
| 263 |
+
stats["secs"] = round(time.time() - t0, 1)
|
| 264 |
+
stats["out_parquet"] = str(out_parquet) if not args.dry_run else None
|
| 265 |
+
out_stats.write_text(json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
| 266 |
+
out_datasheet.write_text(
|
| 267 |
+
"\n".join(
|
| 268 |
+
[
|
| 269 |
+
f"# {args.source_name}",
|
| 270 |
+
"",
|
| 271 |
+
"Filtered Polish subset of `PleIAs/common_corpus`.",
|
| 272 |
+
"",
|
| 273 |
+
f"- source repo: `{args.repo_id}`",
|
| 274 |
+
"- license basis: per-record `license` metadata from Common Corpus",
|
| 275 |
+
f"- allowed licenses: `{', '.join(sorted(allowed_licenses))}`",
|
| 276 |
+
f"- excluded open types: `{', '.join(sorted(args.exclude_open_type))}`",
|
| 277 |
+
f"- excluded collections: `{', '.join(sorted(args.exclude_collection))}`",
|
| 278 |
+
f"- records kept: `{stats['kept']:,}`",
|
| 279 |
+
f"- tokens kept: `{stats['tokens']:,}`",
|
| 280 |
+
"",
|
| 281 |
+
"This source must still pass corpus-level exact/near dedup before release.",
|
| 282 |
+
]
|
| 283 |
+
)
|
| 284 |
+
+ "\n",
|
| 285 |
+
encoding="utf-8",
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
print(f"read={stats['read']:,} kept={stats['kept']:,} tokens={stats['tokens']:,} secs={stats['secs']}")
|
| 289 |
+
print(f"licenses={stats['licenses']}")
|
| 290 |
+
print(f"collections={stats['collections']}")
|
| 291 |
+
print(f"open_types={stats['open_types']}")
|
| 292 |
+
print(f"wrote: {out_stats}")
|
| 293 |
+
if not args.dry_run:
|
| 294 |
+
print(f"wrote: {out_parquet}")
|
| 295 |
+
print(f"wrote: {out_datasheet}")
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
if __name__ == "__main__":
|
| 299 |
+
main()
|
src/filter_european_hplt.py
AD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european-hplt-v1.
|
| 3 |
+
|
| 4 |
+
This source is attractive for v0.3 because it adds modern web Polish at scale
|
| 5 |
+
with HPLT quality scores and web-register metadata. It still needs downstream
|
| 6 |
+
dedup and legal/provenance review because it is web-crawl derived data.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import argparse
|
| 12 |
+
import json
|
| 13 |
+
import os
|
| 14 |
+
import re
|
| 15 |
+
import sys
|
| 16 |
+
import time
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
from urllib.parse import urlparse
|
| 19 |
+
|
| 20 |
+
import pyarrow as pa
|
| 21 |
+
import pyarrow.parquet as pq
|
| 22 |
+
from datasets import load_dataset
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
ADDED = "2026-06-16"
|
| 26 |
+
SOURCE_NAME = "european_hplt_pl"
|
| 27 |
+
BOILERPLATE_RE = re.compile(
|
| 28 |
+
r"(cookies?|privacy policy|terms of service|all rights reserved|"
|
| 29 |
+
r"polityka prywatności|regulamin|wszelkie prawa zastrzeżone|"
|
| 30 |
+
r"zaloguj|rejestracja|newsletter)",
|
| 31 |
+
re.I,
|
| 32 |
+
)
|
| 33 |
+
ADULT_SPAM_RE = re.compile(
|
| 34 |
+
r"(porn|sex|escort|casino|viagra|cialis|bukmacher|hazard|"
|
| 35 |
+
r"porno|seks|erotycz|kasyno|randki)",
|
| 36 |
+
re.I,
|
| 37 |
+
)
|
| 38 |
+
LEGALISH_RE = re.compile(
|
| 39 |
+
r"\b(ustawa|rozporządzenie|dz\\.u\\.|sejm|senat|parlament|eur-lex|"
|
| 40 |
+
r"trybunał|sąd|wyrok|kodeks|komisja europejska)\b",
|
| 41 |
+
re.I,
|
| 42 |
+
)
|
| 43 |
+
DEFAULT_EXCLUDED_DOMAIN_PARTS = {
|
| 44 |
+
".bip.",
|
| 45 |
+
"bip.",
|
| 46 |
+
"docplayer.pl",
|
| 47 |
+
"mapa-kodow-pocztowych.pl",
|
| 48 |
+
"slideplayer.pl",
|
| 49 |
+
"wikipedia.org",
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
SCHEMA = pa.schema(
|
| 53 |
+
[
|
| 54 |
+
("id", pa.string()),
|
| 55 |
+
("text", pa.string()),
|
| 56 |
+
("source", pa.string()),
|
| 57 |
+
("added", pa.string()),
|
| 58 |
+
("created", pa.string()),
|
| 59 |
+
("token_count", pa.int64()),
|
| 60 |
+
("hplt_doc_id", pa.string()),
|
| 61 |
+
("hplt_url", pa.string()),
|
| 62 |
+
("hplt_domain", pa.string()),
|
| 63 |
+
("hplt_score", pa.float64()),
|
| 64 |
+
("hplt_lang_prob", pa.float64()),
|
| 65 |
+
("hplt_collection", pa.string()),
|
| 66 |
+
("hplt_register_top", pa.string()),
|
| 67 |
+
("hplt_register_top_prob", pa.float64()),
|
| 68 |
+
("hplt_mt_prob", pa.float64()),
|
| 69 |
+
("hplt_char_count", pa.int64()),
|
| 70 |
+
("hplt_word_count", pa.int64()),
|
| 71 |
+
]
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def top_register(registers: dict | None) -> tuple[str, float]:
|
| 76 |
+
if not isinstance(registers, dict) or not registers:
|
| 77 |
+
return "", 0.0
|
| 78 |
+
key, value = max(registers.items(), key=lambda kv: kv[1] or 0.0)
|
| 79 |
+
return str(key), float(value or 0.0)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def lang_prob(row: dict) -> float:
|
| 83 |
+
prob = row.get("prob")
|
| 84 |
+
if isinstance(prob, list) and prob:
|
| 85 |
+
return float(prob[0] or 0.0)
|
| 86 |
+
if isinstance(prob, (int, float)):
|
| 87 |
+
return float(prob)
|
| 88 |
+
return 0.0
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def domain(url: str | None) -> str:
|
| 92 |
+
if not url:
|
| 93 |
+
return ""
|
| 94 |
+
host = urlparse(url).netloc.lower()
|
| 95 |
+
return host[4:] if host.startswith("www.") else host
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def is_bad_text(text: str, args: argparse.Namespace) -> tuple[bool, str]:
|
| 99 |
+
sample = text[:5000]
|
| 100 |
+
if len(BOILERPLATE_RE.findall(sample)) >= args.max_boilerplate_hits:
|
| 101 |
+
return True, "boilerplate"
|
| 102 |
+
if ADULT_SPAM_RE.search(sample):
|
| 103 |
+
return True, "adult_spam"
|
| 104 |
+
if not args.include_legalish and LEGALISH_RE.search(sample):
|
| 105 |
+
return True, "legalish"
|
| 106 |
+
return False, ""
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def keep_row(row: dict, args: argparse.Namespace) -> tuple[bool, str]:
|
| 110 |
+
if row.get("lang") != "pl":
|
| 111 |
+
return False, "language"
|
| 112 |
+
if row.get("collection") not in args.allowed_collections:
|
| 113 |
+
return False, "collection"
|
| 114 |
+
host = domain(row.get("url"))
|
| 115 |
+
if any(part in host for part in args.exclude_domain_contains):
|
| 116 |
+
return False, "domain"
|
| 117 |
+
if args.max_per_domain and args.domain_counts.get(host, 0) >= args.max_per_domain:
|
| 118 |
+
return False, "domain_cap"
|
| 119 |
+
if float(row.get("score") or 0.0) < args.min_score:
|
| 120 |
+
return False, "score"
|
| 121 |
+
if lang_prob(row) < args.min_lang_prob:
|
| 122 |
+
return False, "lang_prob"
|
| 123 |
+
|
| 124 |
+
registers = row.get("web-register") or {}
|
| 125 |
+
mt_prob = float(registers.get("MT", 0.0)) if isinstance(registers, dict) else 0.0
|
| 126 |
+
if mt_prob >= args.max_mt_prob:
|
| 127 |
+
return False, "machine_translated"
|
| 128 |
+
|
| 129 |
+
reg, reg_prob = top_register(registers)
|
| 130 |
+
if args.allowed_registers and reg not in args.allowed_registers:
|
| 131 |
+
return False, "register"
|
| 132 |
+
if reg_prob < args.min_register_prob:
|
| 133 |
+
return False, "register_prob"
|
| 134 |
+
|
| 135 |
+
text = (row.get("text") or "").strip()
|
| 136 |
+
if len(text) < args.min_chars:
|
| 137 |
+
return False, "short"
|
| 138 |
+
if int(row.get("word_count") or 0) < args.min_words:
|
| 139 |
+
return False, "few_words"
|
| 140 |
+
|
| 141 |
+
bad, reason = is_bad_text(text, args)
|
| 142 |
+
if bad:
|
| 143 |
+
return False, reason
|
| 144 |
+
return True, "kept"
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def parse_csv(value: str | None) -> set[str]:
|
| 148 |
+
if not value:
|
| 149 |
+
return set()
|
| 150 |
+
return {item.strip() for item in value.split(",") if item.strip()}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def estimate_tokens(row: dict) -> int:
|
| 154 |
+
# HPLT card estimates tokens as chars / 4. Keep the proxy explicit.
|
| 155 |
+
return max(1, int((row.get("char_count") or len(row.get("text") or "")) / 4))
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def write_batch(writer: pq.ParquetWriter, batch: list[tuple[int, dict]], source_name: str) -> int:
|
| 159 |
+
records = {name: [] for name in SCHEMA.names}
|
| 160 |
+
token_sum = 0
|
| 161 |
+
for idx, row in batch:
|
| 162 |
+
registers = row.get("web-register") or {}
|
| 163 |
+
reg, reg_prob = top_register(registers)
|
| 164 |
+
tok = estimate_tokens(row)
|
| 165 |
+
token_sum += tok
|
| 166 |
+
url = row.get("url") or ""
|
| 167 |
+
records["id"].append(f"{source_name}_{idx}")
|
| 168 |
+
records["text"].append((row.get("text") or "").strip())
|
| 169 |
+
records["source"].append(source_name)
|
| 170 |
+
records["added"].append(ADDED)
|
| 171 |
+
records["created"].append("")
|
| 172 |
+
records["token_count"].append(tok)
|
| 173 |
+
records["hplt_doc_id"].append(str(row.get("doc_id") or ""))
|
| 174 |
+
records["hplt_url"].append(url)
|
| 175 |
+
records["hplt_domain"].append(domain(url))
|
| 176 |
+
records["hplt_score"].append(float(row.get("score") or 0.0))
|
| 177 |
+
records["hplt_lang_prob"].append(lang_prob(row))
|
| 178 |
+
records["hplt_collection"].append(str(row.get("collection") or ""))
|
| 179 |
+
records["hplt_register_top"].append(reg)
|
| 180 |
+
records["hplt_register_top_prob"].append(reg_prob)
|
| 181 |
+
records["hplt_mt_prob"].append(float(registers.get("MT", 0.0)) if isinstance(registers, dict) else 0.0)
|
| 182 |
+
records["hplt_char_count"].append(int(row.get("char_count") or len(row.get("text") or "")))
|
| 183 |
+
records["hplt_word_count"].append(int(row.get("word_count") or 0))
|
| 184 |
+
writer.write_table(pa.table(records, schema=SCHEMA))
|
| 185 |
+
return token_sum
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def parse_args() -> argparse.Namespace:
|
| 189 |
+
ap = argparse.ArgumentParser()
|
| 190 |
+
ap.add_argument("--repo-id", default="ashtok897/european-hplt-v1")
|
| 191 |
+
ap.add_argument("--split", default="train")
|
| 192 |
+
ap.add_argument("--out-dir", type=Path, default=Path("data/european_hplt_pl"))
|
| 193 |
+
ap.add_argument("--source-name", default=SOURCE_NAME)
|
| 194 |
+
ap.add_argument("--max-records", type=int, default=100_000)
|
| 195 |
+
ap.add_argument("--max-tokens", type=int, default=100_000_000)
|
| 196 |
+
ap.add_argument("--batch-size", type=int, default=1000)
|
| 197 |
+
ap.add_argument("--min-score", type=float, default=10.0)
|
| 198 |
+
ap.add_argument("--min-lang-prob", type=float, default=0.80)
|
| 199 |
+
ap.add_argument("--max-mt-prob", type=float, default=0.20)
|
| 200 |
+
ap.add_argument("--min-register-prob", type=float, default=0.0)
|
| 201 |
+
ap.add_argument("--allowed-registers", default="ID,OP,HI,IN,NA")
|
| 202 |
+
ap.add_argument("--allowed-collections", default="text/html,text/plain,application/xhtml+xml")
|
| 203 |
+
ap.add_argument("--exclude-domain-contains", default=",".join(sorted(DEFAULT_EXCLUDED_DOMAIN_PARTS)))
|
| 204 |
+
ap.add_argument("--max-per-domain", type=int, default=250)
|
| 205 |
+
ap.add_argument("--min-chars", type=int, default=400)
|
| 206 |
+
ap.add_argument("--min-words", type=int, default=80)
|
| 207 |
+
ap.add_argument("--max-boilerplate-hits", type=int, default=3)
|
| 208 |
+
ap.add_argument("--include-legalish", action="store_true")
|
| 209 |
+
ap.add_argument("--dry-run", action="store_true")
|
| 210 |
+
return ap.parse_args()
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def main() -> None:
|
| 214 |
+
args = parse_args()
|
| 215 |
+
args.allowed_registers = parse_csv(args.allowed_registers)
|
| 216 |
+
args.allowed_collections = parse_csv(args.allowed_collections)
|
| 217 |
+
args.exclude_domain_contains = parse_csv(args.exclude_domain_contains)
|
| 218 |
+
args.domain_counts = {}
|
| 219 |
+
args.out_dir.mkdir(parents=True, exist_ok=True)
|
| 220 |
+
out_parquet = args.out_dir / f"{args.source_name}.parquet"
|
| 221 |
+
out_stats = args.out_dir / f"{args.source_name}.stats.json"
|
| 222 |
+
out_datasheet = args.out_dir / f"{args.source_name}.md"
|
| 223 |
+
|
| 224 |
+
ds = load_dataset(args.repo_id, split=args.split, streaming=True)
|
| 225 |
+
writer = None if args.dry_run else pq.ParquetWriter(out_parquet, SCHEMA, compression="zstd")
|
| 226 |
+
stats = {
|
| 227 |
+
"read": 0,
|
| 228 |
+
"kept": 0,
|
| 229 |
+
"tokens": 0,
|
| 230 |
+
"chars": 0,
|
| 231 |
+
"drop": {},
|
| 232 |
+
"registers": {},
|
| 233 |
+
"collections": {},
|
| 234 |
+
"domains_top_sample": {},
|
| 235 |
+
"source_repo": args.repo_id,
|
| 236 |
+
"license": "CC0-1.0 per dataset card; web-crawl provenance requires review",
|
| 237 |
+
"filters": {
|
| 238 |
+
"allowed_registers": sorted(args.allowed_registers),
|
| 239 |
+
"allowed_collections": sorted(args.allowed_collections),
|
| 240 |
+
"exclude_domain_contains": sorted(args.exclude_domain_contains),
|
| 241 |
+
"max_per_domain": args.max_per_domain,
|
| 242 |
+
"min_score": args.min_score,
|
| 243 |
+
"min_lang_prob": args.min_lang_prob,
|
| 244 |
+
"max_mt_prob": args.max_mt_prob,
|
| 245 |
+
"min_chars": args.min_chars,
|
| 246 |
+
"min_words": args.min_words,
|
| 247 |
+
},
|
| 248 |
+
}
|
| 249 |
+
t0 = time.time()
|
| 250 |
+
batch: list[tuple[int, dict]] = []
|
| 251 |
+
next_id = 0
|
| 252 |
+
try:
|
| 253 |
+
for row in ds:
|
| 254 |
+
stats["read"] += 1
|
| 255 |
+
keep, reason = keep_row(row, args)
|
| 256 |
+
if not keep:
|
| 257 |
+
stats["drop"][reason] = stats["drop"].get(reason, 0) + 1
|
| 258 |
+
continue
|
| 259 |
+
|
| 260 |
+
registers = row.get("web-register") or {}
|
| 261 |
+
reg, _ = top_register(registers)
|
| 262 |
+
stats["registers"][reg] = stats["registers"].get(reg, 0) + 1
|
| 263 |
+
coll = row.get("collection") or ""
|
| 264 |
+
stats["collections"][coll] = stats["collections"].get(coll, 0) + 1
|
| 265 |
+
host = domain(row.get("url"))
|
| 266 |
+
args.domain_counts[host] = args.domain_counts.get(host, 0) + 1
|
| 267 |
+
if len(stats["domains_top_sample"]) < 500:
|
| 268 |
+
stats["domains_top_sample"][host] = stats["domains_top_sample"].get(host, 0) + 1
|
| 269 |
+
stats["chars"] += int(row.get("char_count") or len(row.get("text") or ""))
|
| 270 |
+
stats["kept"] += 1
|
| 271 |
+
batch.append((next_id, row))
|
| 272 |
+
next_id += 1
|
| 273 |
+
|
| 274 |
+
if len(batch) >= args.batch_size:
|
| 275 |
+
if writer:
|
| 276 |
+
stats["tokens"] += write_batch(writer, batch, args.source_name)
|
| 277 |
+
else:
|
| 278 |
+
stats["tokens"] += sum(estimate_tokens(item[1]) for item in batch)
|
| 279 |
+
batch.clear()
|
| 280 |
+
if stats["kept"] >= args.max_records or stats["tokens"] >= args.max_tokens:
|
| 281 |
+
break
|
| 282 |
+
finally:
|
| 283 |
+
if batch:
|
| 284 |
+
if writer:
|
| 285 |
+
stats["tokens"] += write_batch(writer, batch, args.source_name)
|
| 286 |
+
else:
|
| 287 |
+
stats["tokens"] += sum(estimate_tokens(item[1]) for item in batch)
|
| 288 |
+
if writer:
|
| 289 |
+
writer.close()
|
| 290 |
+
|
| 291 |
+
stats["secs"] = round(time.time() - t0, 1)
|
| 292 |
+
stats["out_parquet"] = None if args.dry_run else str(out_parquet)
|
| 293 |
+
out_stats.write_text(json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
| 294 |
+
out_datasheet.write_text(
|
| 295 |
+
"\n".join(
|
| 296 |
+
[
|
| 297 |
+
f"# {args.source_name}",
|
| 298 |
+
"",
|
| 299 |
+
"Filtered Polish subset of `ashtok897/european-hplt-v1`.",
|
| 300 |
+
"",
|
| 301 |
+
f"- source repo: `{args.repo_id}`",
|
| 302 |
+
"- license tag/card: `CC0-1.0`, inherited from HPLT v3",
|
| 303 |
+
"- caveat: web-crawl derived data; keep URL provenance and run downstream review",
|
| 304 |
+
f"- allowed registers: `{', '.join(sorted(args.allowed_registers))}`",
|
| 305 |
+
f"- records kept: `{stats['kept']:,}`",
|
| 306 |
+
f"- token proxy kept: `{stats['tokens']:,}`",
|
| 307 |
+
"",
|
| 308 |
+
"This source must still pass exact/near dedup, boilerplate review, and per-source style/perplexity checks before release.",
|
| 309 |
+
]
|
| 310 |
+
)
|
| 311 |
+
+ "\n",
|
| 312 |
+
encoding="utf-8",
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
print(f"read={stats['read']:,} kept={stats['kept']:,} tokens={stats['tokens']:,} secs={stats['secs']}")
|
| 316 |
+
print(f"registers={stats['registers']}")
|
| 317 |
+
print(f"collections={stats['collections']}")
|
| 318 |
+
print(f"drops={stats['drop']}")
|
| 319 |
+
print(f"wrote: {out_stats}")
|
| 320 |
+
if not args.dry_run:
|
| 321 |
+
print(f"wrote: {out_parquet}")
|
| 322 |
+
print(f"wrote: {out_datasheet}")
|
| 323 |
+
sys.stdout.flush()
|
| 324 |
+
os._exit(0)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
if __name__ == "__main__":
|
| 328 |
+
main()
|