Datasets:
Download src/make_docs.py from SlayerLab/polish-dynaword: direct link, hf CLI and curl.
- Browser
- Download file 9.18 kB
-
https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/d9a31e20a218a5171a4ce88802378c3e1e5fc056/src/make_docs.py
- Command line
-
hf download hf://datasets/SlayerLab/polish-dynaword@d9a31e20a218a5171a4ce88802378c3e1e5fc056/src/make_docs.py
-
curl -L -o make_docs.py https://huggingface.co/datasets/SlayerLab/polish-dynaword/resolve/d9a31e20a218a5171a4ce88802378c3e1e5fc056/src/make_docs.py
9.18 kB
| #!/usr/bin/env python3 | |
| """Generate Dynaword documentation: per-source datasheets + README + CHANGELOG + LICENSE. | |
| Reads sources.py + data/<source>/<source>.stats.json (written by build_dynaword.py). | |
| Implements the "Documented" principle (datasheets, Gebru et al. 2021) and the | |
| aggregate README table (paper 2508.02271). | |
| """ | |
| from __future__ import annotations | |
| import json, sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | |
| from sources import SOURCES, EXCLUDED, ADDED | |
| ROOT = Path(__file__).resolve().parent.parent | |
| VERSION = "0.2.0" | |
| CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests | |
| # Dupochron: documented good-faith provenance + no-warranty + takedown + PII. | |
| DISCLAIMER = f"""## Personal & sensitive data | |
| This corpus contains **only** text that its upstream sources already published | |
| under open licenses or as official public-domain record. It therefore includes | |
| names and statements of **public figures acting in a public capacity** — e.g. | |
| parliamentary speakers (PPC), authorities named in legal acts (EUR-Lex), and | |
| people described in encyclopedic articles (Wikipedia/Wikisource). No private, | |
| non-public personal data was collected or added. If you are a data subject and | |
| want content concerning you removed, contact **{CONTACT}** — it will be dropped | |
| from the next version (see retroactive-removal policy below). | |
| ## Disclaimer & legal | |
| - **Provenance in good faith.** Per-source licenses are reproduced *as documented | |
| by the upstream sources and by SpeakLeash* (the intermediate aggregator), to the | |
| best of our knowledge. We make no independent legal warranty about the copyright | |
| status of any individual document. | |
| - **No ownership claim.** This release is a *curated, license-reviewed, documented | |
| aggregation*. We claim no ownership of the underlying texts; rights remain with | |
| the original authors/rightsholders under their respective licenses. | |
| - **Provided "as is"**, without warranty of any kind, express or implied. This is | |
| not legal advice. | |
| - **Your compliance is yours.** Downstream users must satisfy each upstream | |
| license themselves — in particular **CC-BY-SA-4.0 attribution and share-alike** | |
| for derivatives of this dataset, and attribution to the upstream sources and to | |
| SpeakLeash. | |
| - **Notice-and-takedown.** Any source or rightsholder raising a substantiated | |
| objection can have material removed: contact **{CONTACT}**; it is dropped from | |
| the next version and recorded in the CHANGELOG. Removal is retroactive | |
| going-forward (prior immutable snapshots/commits may persist). | |
| """ | |
| def load_stats(name): | |
| f = ROOT / "data" / name / f"{name}.stats.json" | |
| return json.loads(f.read_text()) if f.exists() else None | |
| def datasheet(name, cfg, st): | |
| return f"""# {name} | |
| {cfg['pretty']} | |
| ## Dataset description | |
| - **Source (upstream):** {cfg['upstream']} | |
| - **Domain:** {cfg['domain']} | |
| - **Language:** Polish (pl) | |
| - **License:** `{cfg['license']}` | |
| - **Created (range):** {cfg['created']} | |
| - **Added:** {ADDED} | |
| ## Licensing — traceable basis | |
| {cfg['traceable']} | |
| ## Provenance | |
| {cfg.get('provenance', f"Pulled from SpeakLeash's public redistribution " | |
| f"(`speakleash-ds-pub`, key `{cfg.get('speakleash_key')}`) of the upstream source " | |
| f"above. SpeakLeash credited as intermediate aggregator; upstream " | |
| f"license/attribution preserved.")} | |
| ## Statistics | |
| | documents | characters | tokens (tiktoken proxy) | | |
| |---:|---:|---:| | |
| | {st['kept']:,} | {st['chars']:,} | {st['tokens']:,} | | |
| ## Filters applied (build_dynaword.py) | |
| Minimal, per Dynaword guidelines (heavy filtering left to downstream use): | |
| - drop documents < 200 chars: **{st['drop_short']:,}** | |
| - drop non-Polish (diacritic ratio): **{st['drop_lang']:,}** | |
| - exact cross-source dedup (sha1): **{st['drop_dup']:,}** | |
| - OCR alpha-ratio < 0.70 (OCR sources only): **{st['drop_ocr']:,}** | |
| - read {st['read']:,} → kept {st['kept']:,} | |
| Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical | |
| Llama-3 count is computed at release. | |
| """ | |
| def main(): | |
| rows, tot_doc, tot_tok, tot_chr = [], 0, 0, 0 | |
| for name, cfg in SOURCES.items(): | |
| st = load_stats(name) | |
| if not st: | |
| print(f" ! no stats for {name}"); continue | |
| (ROOT / "data" / name / f"{name}.md").write_text(datasheet(name, cfg, st)) | |
| rows.append((name, cfg, st)) | |
| tot_doc += st["kept"]; tot_tok += st["tokens"]; tot_chr += st["chars"] | |
| rows.sort(key=lambda r: -r[2]["tokens"]) | |
| tbl = "\n".join( | |
| f"| [{n}](data/{n}/{n}.md) | {c['pretty']} | `{c['license']}` | " | |
| f"{s['kept']:,} | {s['tokens']/1e6:,.1f}M |" | |
| for n, c, s in rows) | |
| excl = "\n".join(f"| `{k}` | {v} |" for k, v in EXCLUDED.items()) | |
| readme = f"""--- | |
| license: cc-by-sa-4.0 | |
| language: | |
| - pl | |
| pretty_name: Polish DynaWord | |
| task_categories: | |
| - text-generation | |
| size_categories: | |
| - 1M<n<10M | |
| tags: | |
| - polish | |
| - pretraining | |
| - dynaword | |
| --- | |
| # Polish DynaWord | |
| A continuously developed, **openly-licensed**, human-text Polish corpus — a Polish | |
| edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword) | |
| family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)). | |
| > **v{VERSION}** · {tot_doc:,} documents · **{tot_tok/1e9:.2f}B tokens** (tiktoken proxy; | |
| > canonical Llama-3 count at release) · {len(rows)} sources | |
| ## What this dataset contributes | |
| The raw texts come from existing open corpora (redistributed via SpeakLeash and, | |
| where applicable, fetched from upstream). **The value added here is the curation, | |
| not the bytes**, following the Dynaword methodology: | |
| 1. **License review per source** — each source vetted for an *openly-licensed, | |
| traceable* legal basis (documented in its datasheet); sources that fail the | |
| review are **excluded with a stated reason** (see table below), not silently | |
| kept. This is the core editorial work. | |
| 2. **Filtering & normalization** — minimal, reproducible gates (short-doc, | |
| non-Polish, exact cross-source dedup, OCR garble) applied uniformly to one | |
| clean schema: `id, text, source, added, created, token_count`. | |
| 3. **Documentation** — a datasheet per source (Gebru et al. 2021) + this card, | |
| so provenance and licensing are auditable rather than assumed. | |
| 4. **Reproducibility & versioning** — `src/` rebuilds the corpus from sources; | |
| new sources and removals are tracked in the CHANGELOG. | |
| Credit for the underlying texts belongs to the upstream sources and to SpeakLeash | |
| as the redistributing aggregator; this release does not claim ownership of them | |
| (see Disclaimer). | |
| ## Guiding principles | |
| 1. **Open & traceable licensing** — every source is *openly licensed* with a documented | |
| legal basis (see each datasheet's "traceable basis"), not a vague "public domain". | |
| 2. **Reproducibility** — `src/build_dynaword.py` rebuilds the corpus from sources. | |
| 3. **Documented** — a datasheet per source under `data/<source>/`. | |
| 4. **Extensibility** — versioned; new sources via PR. | |
| ## Sources | |
| | source | description | license | documents | tokens | | |
| |---|---|---|---:|---:| | |
| {tbl} | |
| | **total** | | | **{tot_doc:,}** | **{tot_tok/1e6:,.1f}M** | | |
| ## Method | |
| Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed | |
| data. Gates are intentionally minimal (drop short docs, non-Polish, exact duplicates, | |
| OCR garble); heavy quality filtering and mix-weighting are left to downstream training. | |
| Evaluation-set decontamination is applied/marked separately. Schema: | |
| `id, text, source, added, created, token_count`. | |
| ## Excluded sources (transparency) | |
| Sources we reviewed and **deliberately left out** — part of the curation: | |
| | source | reason | | |
| |---|---| | |
| {excl} | |
| {DISCLAIMER} | |
| ## License & attribution | |
| Released under **CC-BY-SA-4.0** (copyleft inherited from CC-BY-SA sources such as | |
| Wikipedia/Wikisource/Wolne Lektury). Attribution due to each upstream (see datasheets) | |
| and to **SpeakLeash** as the intermediate aggregator. Retroactive-removal policy: a | |
| source that raises an objection is dropped from subsequent versions, recorded in the | |
| CHANGELOG. | |
| ## Reproduce | |
| ```bash | |
| python3 src/build_dynaword.py --all --speakleash-dir <speakleash_zst_dir> --out . | |
| python3 src/make_docs.py | |
| ``` | |
| """ | |
| (ROOT / "README.md").write_text(readme) | |
| (ROOT / "CHANGELOG.md").write_text( | |
| f"# Changelog\n\n## v{VERSION} ({ADDED})\n\n" | |
| f"- Initial release: {len(rows)} openly-licensed sources, " | |
| f"{tot_doc:,} docs, {tot_tok/1e9:.2f}B tokens (tiktoken proxy).\n" | |
| f"- Sources: {', '.join(n for n, _, _ in rows)}.\n" | |
| f"- Excluded (see README): {', '.join(EXCLUDED)}.\n") | |
| (ROOT / "LICENSE").write_text( | |
| "Polish DynaWord is released under Creative Commons Attribution-ShareAlike 4.0\n" | |
| "International (CC-BY-SA-4.0): https://creativecommons.org/licenses/by-sa/4.0/\n\n" | |
| "Per-source upstream licenses and attribution are documented in each\n" | |
| "data/<source>/<source>.md datasheet.\n") | |
| print(f"docs written: README + CHANGELOG + LICENSE + {len(rows)} datasheets") | |
| print(f"TOTAL {tot_doc:,} docs | {tot_tok/1e9:.2f}B tok | {tot_chr/1e9:.1f}B chars") | |
| if __name__ == "__main__": | |
| main() | |