Datasets:
SJP.PL
#6
by ktalik - opened
- AGENTS.md +0 -74
- CHANGELOG.md +0 -39
- README.md +32 -141
- artifacts/dataset_size_by_version.png +0 -3
- artifacts/pattern_frequency_artykul.png +2 -2
- artifacts/pattern_frequency_dzu.png +2 -2
- artifacts/pattern_frequency_hf_snippet.md +10 -46
- artifacts/pattern_frequency_klasyfikacji.png +2 -2
- artifacts/pattern_frequency_mieszkańców.png +2 -2
- artifacts/pattern_frequency_overall.png +2 -2
- artifacts/pattern_frequency_parlament.png +2 -2
- artifacts/pattern_frequency_rozporządzenie.png +2 -2
- artifacts/pattern_frequency_ustawa.png +2 -2
- artifacts/pattern_frequency_w_pobliżu.png +2 -2
- artifacts/pattern_frequency_w_roku.png +2 -2
- data/biblioteka_nauki/biblioteka_nauki.md +0 -60
- data/biblioteka_nauki/biblioteka_nauki.parquet +0 -3
- data/biblioteka_nauki/biblioteka_nauki.stats.json +0 -12
- data/biblioteka_nauki/recover_attribution.py +0 -125
- data/biblioteka_nauki/recover_licenses.py +0 -171
- data/european_hplt_v3_pl/european_hplt_v3_pl.md +0 -57
- data/european_hplt_v3_pl/european_hplt_v3_pl.parquet +0 -3
- data/european_hplt_v3_pl/european_hplt_v3_pl.stats.json +0 -41
- data/global_voices/NOTICE.md +0 -11
- data/global_voices/global_voices.attribution.jsonl +0 -0
- data/global_voices/global_voices.md +0 -65
- data/global_voices/global_voices.parquet +0 -3
- data/global_voices/global_voices.stats.json +0 -15
- data/govpl/govpl.md +0 -41
- data/govpl/govpl.parquet +0 -3
- data/govpl/govpl.stats.json +0 -16
- data/nkjp1m/nkjp1m.md +0 -42
- data/nkjp1m/nkjp1m.parquet +0 -3
- data/nkjp1m/nkjp1m.stats.json +0 -18
- pattern_frequency_report.md +10 -46
- src/clean_hplt_v3.py +0 -202
- src/discover_govpl.py +0 -194
- src/fetch_govpl.py +0 -183
- src/fetch_njkp.py +0 -342
- src/govpl_subsites.json +0 -684
- src/make_docs.py +35 -104
- src/pattern_frequency_report.py +1 -4
- src/plot_version_growth.py +0 -66
- src/sources.py +1 -95
- src/test_govpl_contract.py +0 -84
- src/test_hplt_v3_contract.py +0 -67
AGENTS.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
| 1 |
-
# AGENTS.md
|
| 2 |
-
|
| 3 |
-
Guidance for agents and contributors adding a source and cutting a release.
|
| 4 |
-
Read this before opening a PR — several recent contributions added data but
|
| 5 |
-
skipped the doc/version bump, forcing a maintainer cleanup release.
|
| 6 |
-
|
| 7 |
-
## How the docs are actually maintained
|
| 8 |
-
|
| 9 |
-
`src/make_docs.py` is a **scaffolding/assembly helper, not a round-trip source
|
| 10 |
-
of truth.** It regenerates the README source table + release totals, `LICENSE`,
|
| 11 |
-
a `CHANGELOG` stub, and *template* datasheets — but it does **not** reproduce the
|
| 12 |
-
committed docs on its own:
|
| 13 |
-
|
| 14 |
-
- It iterates `SOURCES` in `src/sources.py`; any source in `data/` but missing
|
| 15 |
-
from `SOURCES` is silently dropped from the table and totals.
|
| 16 |
-
- It stamps every regenerated datasheet's "Added" with the single global `ADDED`
|
| 17 |
-
constant, overwriting real per-source add dates.
|
| 18 |
-
- It cannot reproduce hand-written README narrative (audit notes, policy notes,
|
| 19 |
-
the phrase-frequency section).
|
| 20 |
-
|
| 21 |
-
So datasheets and the README narrative are **hand/contributor-maintained**.
|
| 22 |
-
Never run `make_docs.py` and commit the result blind — `git diff` first and
|
| 23 |
-
restore anything it dropped or restamped.
|
| 24 |
-
|
| 25 |
-
## Add a source
|
| 26 |
-
|
| 27 |
-
1. Produce the artifact under `data/<key>/`:
|
| 28 |
-
- `<key>.parquet` — built by `src/build_dynaword.py` (LFS-tracked automatically).
|
| 29 |
-
- `<key>.stats.json` — doc/token/char counts (drives all totals).
|
| 30 |
-
- `<key>.md` — datasheet (see below).
|
| 31 |
-
2. Add the ingestion script: `src/fetch_<key>.py` or `src/clean_<key>.py`, so the
|
| 32 |
-
source is reproducible. `build_source` (build_dynaword.py) expects a
|
| 33 |
-
`<file_key|speakleash_key>.jsonl.zst` intermediate.
|
| 34 |
-
3. Register the source in `src/sources.py` (`SOURCES`) — required, or make_docs
|
| 35 |
-
never sees it. Copy an existing entry's shape: `pretty`, `license`,
|
| 36 |
-
`license_spdx`, `traceable`, `upstream`, `domain`, `created`, `is_ocr`, and the
|
| 37 |
-
`speakleash_key`/`file_key`. If the datasheet is hand-authored (rich provenance
|
| 38 |
-
or a fixed add date), add `"custom_datasheet": True` so make_docs leaves it
|
| 39 |
-
alone.
|
| 40 |
-
4. Add a contract test: `src/test_<key>_contract.py` (canonical schema, non-empty
|
| 41 |
-
text, positive token counts, uniform source/license, stats-file consistency).
|
| 42 |
-
Run `python3 -m pytest src/` before committing.
|
| 43 |
-
|
| 44 |
-
## Cut the release (the part that gets skipped)
|
| 45 |
-
|
| 46 |
-
1. In `src/make_docs.py`: bump `VERSION` and `RELEASE_DATE`. Add a row for the new
|
| 47 |
-
version to the version table and a row for yourself to the Contributors table
|
| 48 |
-
(both are literal rows in the template).
|
| 49 |
-
2. Regenerate the phrase-frequency report and charts (registry-independent — it
|
| 50 |
-
globs `data/*/*.parquet`):
|
| 51 |
-
```bash
|
| 52 |
-
python3 src/pattern_frequency_report.py
|
| 53 |
-
```
|
| 54 |
-
Writes `artifacts/pattern_frequency_hf_snippet.md` + 10 PNGs. Splice the tables
|
| 55 |
-
and chart embeds into the README "Results" section by hand.
|
| 56 |
-
3. Update `README.md` by hand: header totals, version table, source table row,
|
| 57 |
-
Contributors row. The document/token totals must equal the sum of the
|
| 58 |
-
per-source `stats.json` files.
|
| 59 |
-
4. Prepend the release notes to `CHANGELOG.md` under a new `## vX.Y.Z (date)`
|
| 60 |
-
heading. History is append-only — never rewrite earlier releases.
|
| 61 |
-
|
| 62 |
-
## Do not commit
|
| 63 |
-
|
| 64 |
-
`*.log` (fetch/build logs), `.DS_Store`, `src/__pycache__/`. Only `logs/` is in
|
| 65 |
-
`.gitignore` — root-level logs and OS cruft are not, so check `git status`
|
| 66 |
-
before staging. `*.parquet` is LFS-tracked; commit the pointer, not the blob.
|
| 67 |
-
|
| 68 |
-
## Known drift / cleanup opportunities
|
| 69 |
-
|
| 70 |
-
- `biblioteka_nauki`, `europeana`, `parlamint_pl` are in `SOURCES` but have no
|
| 71 |
-
`data/` shard (make_docs skips them with `! no stats`). Intentional placeholders
|
| 72 |
-
or stale — confirm before relying on `build_dynaword.py --all`.
|
| 73 |
-
- The global `ADDED` datasheet stamp is a footgun: give datasheets a per-source
|
| 74 |
-
add date (or `custom_datasheet`) before making make_docs regenerate them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHANGELOG.md
CHANGED
|
@@ -1,44 +1,5 @@
|
|
| 1 |
# Changelog
|
| 2 |
|
| 3 |
-
## v0.2.3 (2026-07-26)
|
| 4 |
-
|
| 5 |
-
- Added the community contribution `european_hplt_v3_pl` by Arkadiusz Słota
|
| 6 |
-
(`Maggio33`): HPLT v3.0 Polish WDS quality bins 10+9, 110,590 documents and
|
| 7 |
-
512,383,778 cl100k-proxy tokens under CC0-1.0 packaging.
|
| 8 |
-
- Added the reviewed `global_voices` contribution by Dawid Majewski
|
| 9 |
-
(`dawidmajewski`): 2,040 documents / 3,715,020 tokens with CC-BY-3.0 and
|
| 10 |
-
per-document author attribution metadata.
|
| 11 |
-
- Added `nkjp1m` from contributor `1am`: 18,381 documents / 2,601,201 tokens
|
| 12 |
-
from the manually annotated 1-million-word NKJP subcorpus under the upstream
|
| 13 |
-
version-unspecified CC-BY statement.
|
| 14 |
-
- Revalidated the contributed parquet against the canonical schema, non-empty
|
| 15 |
-
text, positive token counts, uniform source/license metadata, and stats-file
|
| 16 |
-
consistency.
|
| 17 |
-
- Updated the complete 16-source release totals from per-source parquet stats:
|
| 18 |
-
2,710,974 documents and 6,881,277,362 cl100k-proxy tokens.
|
| 19 |
-
- Recomputed the full-corpus phrase-frequency report and charts. Updated the
|
| 20 |
-
Arrow reporting path to use 64-bit string offsets for large row groups.
|
| 21 |
-
- Fixed `src/test_hplt_v3_contract.py` to resolve its fixture relative to the
|
| 22 |
-
repository instead of a contributor-local Windows path.
|
| 23 |
-
- Added public contributor credit for Arkadiusz Słota (`Maggio33`) and Paweł
|
| 24 |
-
Puzio (`ppuzio`, author of the `govpl` contribution released in v0.2.2), plus
|
| 25 |
-
Dawid Majewski (`dawidmajewski`) for Global Voices Polish.
|
| 26 |
-
- HPLT caveat: CC0 applies to the HPLT packaging; underlying web documents can
|
| 27 |
-
carry independent rights. Downstream near-dedup and web-content review remain
|
| 28 |
-
recommended before training.
|
| 29 |
-
|
| 30 |
-
## v0.2.2 (2026-07-19)
|
| 31 |
-
|
| 32 |
-
- Added `govpl` — gov.pl Polish government press releases (CC-BY-SA-4.0),
|
| 33 |
-
88,190 documents / 80.7M tokens, fetched directly from gov.pl across 133
|
| 34 |
-
ministry/agency subsites. New scripts: `src/discover_govpl.py` (discovers each
|
| 35 |
-
subsite's news-section path into the committed `src/govpl_subsites.json`
|
| 36 |
-
manifest) and `src/fetch_govpl.py` (pure-stdlib crawl of that manifest).
|
| 37 |
-
- Stable totals after adding govpl: 13 sources, 2,579,963 docs, 6.36B tokens
|
| 38 |
-
(tiktoken proxy).
|
| 39 |
-
- Article date range 2005-09-26 → 2026-07-19. Build dropped 24 non-Polish and
|
| 40 |
-
deduped 1,926 cross-posted articles (exact sha1).
|
| 41 |
-
|
| 42 |
## v0.3.1-preview (2026-07-10)
|
| 43 |
|
| 44 |
- Added a separate 810-document Europeana direct-ingestion preview parquet at
|
|
|
|
| 1 |
# Changelog
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## v0.3.1-preview (2026-07-10)
|
| 4 |
|
| 5 |
- Added a separate 810-document Europeana direct-ingestion preview parquet at
|
README.md
CHANGED
|
@@ -19,89 +19,29 @@ A continuously developed, **openly-licensed**, human-text Polish corpus — a Po
|
|
| 19 |
edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword)
|
| 20 |
family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)).
|
| 21 |
|
| 22 |
-
> **v0.2.
|
| 23 |
-
> (
|
| 24 |
-
> Updated: **2026-07-
|
| 25 |
|
| 26 |
-
> **v0.3-
|
| 27 |
-
>
|
| 28 |
-
>
|
|
|
|
| 29 |
|
| 30 |
-
> **
|
| 31 |
-
> direct-ingestion shard:
|
| 32 |
> 1,000 API records → 810 quality-gated parquet documents, each preserving
|
| 33 |
> per-record rights and creator metadata. Stored separately under
|
| 34 |
-
>
|
| 35 |
-
>
|
| 36 |
|
| 37 |
-
##
|
| 38 |
-
|
| 39 |
-
### Stable releases
|
| 40 |
|
| 41 |
| version | status | documents | tokens | notes |
|
| 42 |
|---|---|---:|---:|---|
|
| 43 |
-
| `v0.2.
|
| 44 |
-
| `v0.2.2` | previous stable | 2,579,963 | 6.36B | Added community-contributed `govpl`: 88,190 docs / 80.7M tokens fetched directly across 133 ministry/agency subsites. |
|
| 45 |
-
| `v0.2.1` | previous stable | 2,491,773 | 6.28B | 12-source stable corpus with `license` and `author` metadata columns; adds `1000_novels`. |
|
| 46 |
| `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
### Development and validation artifacts
|
| 51 |
-
|
| 52 |
-
| name | type | scope | notes |
|
| 53 |
-
|---|---|---|---|
|
| 54 |
-
| `v0.3-dev` | experimental development track | workflow and candidate audits | Quality remix, legal-source caps, source QA, deduplication and direct-upstream ingestion. Not a corpus release. |
|
| 55 |
-
| `Europeana validation artifact 2026-07-10` | reproducible sample | 810 documents / 140,042 tokens | Stored at the legacy path `previews/v0.3.1/europeana.parquet`; preserves per-record rights and creator metadata. Not a corpus release. |
|
| 56 |
-
|
| 57 |
-
### Version details
|
| 58 |
-
|
| 59 |
-
#### v0.2.3 — current stable
|
| 60 |
-
|
| 61 |
-
Community expansion release. Adds `european_hplt_v3_pl` from
|
| 62 |
-
[PR #5](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/5)
|
| 63 |
-
and `global_voices` from
|
| 64 |
-
[PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7),
|
| 65 |
-
plus `nkjp1m` from
|
| 66 |
-
[PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8).
|
| 67 |
-
The complete 16-source release contains **2,710,974 documents /
|
| 68 |
-
6,881,277,362 cl100k-proxy tokens**, summed from the released per-source parquet
|
| 69 |
-
statistics.
|
| 70 |
-
|
| 71 |
-
#### v0.2.2 — previous stable
|
| 72 |
-
|
| 73 |
-
Added `govpl` from
|
| 74 |
-
[PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9):
|
| 75 |
-
88,190 Polish government press releases collected directly from 133 gov.pl
|
| 76 |
-
ministry and agency subsites. Result: 13 sources, 2,579,963 documents and
|
| 77 |
-
6.36B proxy tokens.
|
| 78 |
-
|
| 79 |
-
#### v0.2.1 — previous stable
|
| 80 |
-
|
| 81 |
-
Introduced the canonical eight-column release schema:
|
| 82 |
-
`id, text, source, added, created, token_count, license, author`. Added the
|
| 83 |
-
CC-BY-4.0 `1000_novels` source from
|
| 84 |
-
[PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1)
|
| 85 |
-
and recomputed all release statistics from parquet files.
|
| 86 |
-
|
| 87 |
-
#### v0.2.0 — initial stable corpus
|
| 88 |
-
|
| 89 |
-
The provenance-first baseline: 11 reviewed open or official sources,
|
| 90 |
-
2,490,773 documents and 6.22B proxy tokens. This version established the
|
| 91 |
-
per-source datasheet, traceable-license and exclusion-policy workflow.
|
| 92 |
-
|
| 93 |
-
#### v0.3-dev — experimental quality workflow
|
| 94 |
-
|
| 95 |
-
Candidate-only work on a better-balanced training mixture: legal-source caps,
|
| 96 |
-
temperature sampling, source QA, deduplication and direct-upstream ingestion.
|
| 97 |
-
It is a workflow and validation track, not a replacement for the stable corpus.
|
| 98 |
-
|
| 99 |
-
#### Europeana validation artifact — 2026-07-10
|
| 100 |
-
|
| 101 |
-
A separate reproducible 810-document Europeana sample preserving per-record
|
| 102 |
-
rights and creator metadata. It validates the direct-ingestion contract without
|
| 103 |
-
changing stable-release totals. `v0.3.1-preview` remains only as the legacy
|
| 104 |
-
storage-path label.
|
| 105 |
|
| 106 |
## What this dataset contributes
|
| 107 |
The raw texts come from existing open corpora (redistributed via SpeakLeash and,
|
|
@@ -126,18 +66,10 @@ as the redistributing aggregator; this release does not claim ownership of them
|
|
| 126 |
|
| 127 |
## Contributors
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
| [Paweł Puzio](https://huggingface.co/ppuzio) | Built `govpl`: subsite discovery, direct ingestion pipeline, dataset artifact, contract tests and documentation. | `v0.2.2`, [PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9) |
|
| 134 |
-
| [Arkadiusz Słota](https://huggingface.co/Maggio33) | Built `european_hplt_v3_pl`: HPLT v3 WDS 10+9 cleaning pipeline, 110,590-document artifact, validation and documentation. | `v0.2.3`, [PR #5](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/5) |
|
| 135 |
-
| [Dawid Majewski](https://huggingface.co/dawidmajewski) | Added the reviewed Global Voices Polish corpus with per-document author attribution and documentation. | `v0.2.3`, [PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7) |
|
| 136 |
-
| [1am](https://huggingface.co/1am) | Added `nkjp1m`: the manually annotated 1-million-word NKJP subcorpus, direct fetch/build pipeline, source documentation and release artifact. | `v0.2.3`, [PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8) |
|
| 137 |
-
|
| 138 |
-
Contributions are credited when they add a verifiable dataset artifact, pipeline,
|
| 139 |
-
validation, documentation or release work. A merged discussion with no resulting
|
| 140 |
-
files is not listed as a data contribution.
|
| 141 |
|
| 142 |
## Guiding principles
|
| 143 |
1. **Open & traceable licensing** — every source is *openly licensed* with a documented
|
|
@@ -153,19 +85,15 @@ files is not listed as a data contribution.
|
|
| 153 |
| [parliamentary](data/parliamentary/parliamentary.md) | Polish Parliamentary Corpus (Sejm/Senat) | `public-domain (official documents)` | 324,622 | 1,646.8M |
|
| 154 |
| [wikisource](data/wikisource/wikisource.md) | Polish Wikisource | `CC-BY-SA-3.0` | 632,005 | 801.9M |
|
| 155 |
| [wikipedia](data/wikipedia/wikipedia.md) | Polish Wikipedia | `CC-BY-SA-3.0` | 1,171,897 | 707.2M |
|
| 156 |
-
| [european_hplt_v3_pl](data/european_hplt_v3_pl/european_hplt_v3_pl.md) | HPLT v3.0 Polish — top WDS quality bins 10+9 | `CC0-1.0` | 110,590 | 512.4M |
|
| 157 |
| [dziennik_ustaw](data/dziennik_ustaw/dziennik_ustaw.md) | Dziennik Ustaw + Monitor Polski (Polish primary legislation) | `public-domain (official documents)` | 35,442 | 486.1M |
|
| 158 |
| [wolne_lektury](data/wolne_lektury/wolne_lektury.md) | Wolne Lektury (school readings) | `CC-BY-SA-4.0 / Wolna Sztuka 1.3` | 6,141 | 103.0M |
|
| 159 |
-
| [govpl](data/govpl/govpl.md) | gov.pl — Polish government press releases | `CC-BY-SA-4.0` | 88,190 | 80.7M |
|
| 160 |
| [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
|
| 161 |
| [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
|
| 162 |
| [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
|
| 163 |
| [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
|
| 164 |
| [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
|
| 165 |
| [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
|
| 166 |
-
|
|
| 167 |
-
| [nkjp1m](data/nkjp1m/nkjp1m.md) | NKJP manually annotated 1-million-word subcorpus | `CC-BY` | 18,381 | 2.6M |
|
| 168 |
-
| **total** | | | **2,710,974** | **6,881.3M** |
|
| 169 |
|
| 170 |
## Method
|
| 171 |
Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
|
|
@@ -216,10 +144,9 @@ Current v0.3 source-ingestion status:
|
|
| 216 |
- Europeana release policy: split conservatively at pre-1929 records for
|
| 217 |
US-sensitive downstream reuse, and keep later/unknown records separately
|
| 218 |
labeled or held until legal review.
|
| 219 |
-
- `
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
recommended before training.
|
| 223 |
|
| 224 |
Current review artifacts:
|
| 225 |
|
|
@@ -287,19 +214,19 @@ python3 src/make_docs.py
|
|
| 287 |
|
| 288 |
Raw counts and token-normalized shares are regenerated from the current parquet files with `src/pattern_frequency_report.py`.
|
| 289 |
|
| 290 |
-
- Total token count (tiktoken proxy): **6,
|
| 291 |
|
| 292 |
| Pattern | Count | Share of all tokens |
|
| 293 |
|---|---:|---:|
|
| 294 |
-
| `w roku` |
|
| 295 |
-
| `klasyfikacji` |
|
| 296 |
-
| `ustawa` |
|
| 297 |
-
| `artykuł` | 2,
|
| 298 |
-
| `parlament` | 1,
|
| 299 |
-
| `rozporządzenie` | 1,
|
| 300 |
-
| `w pobliżu` |
|
| 301 |
-
| `mieszkańców` |
|
| 302 |
-
| `Dz.U.` |
|
| 303 |
|
| 304 |
### Per-source shares
|
| 305 |
|
|
@@ -341,42 +268,6 @@ Raw counts and token-normalized shares are regenerated from the current parquet
|
|
| 341 |
| `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
|
| 342 |
| `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
|
| 343 |
| `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
|
| 344 |
-
| `european_hplt_v3_pl` | `w roku` | 21,067 | 0.00411% |
|
| 345 |
-
| `european_hplt_v3_pl` | `klasyfikacji` | 3,576 | 0.00070% |
|
| 346 |
-
| `european_hplt_v3_pl` | `ustawa` | 5,754 | 0.00112% |
|
| 347 |
-
| `european_hplt_v3_pl` | `artykuł` | 56,295 | 0.01099% |
|
| 348 |
-
| `european_hplt_v3_pl` | `parlament` | 10,618 | 0.00207% |
|
| 349 |
-
| `european_hplt_v3_pl` | `rozporządzenie` | 2,661 | 0.00052% |
|
| 350 |
-
| `european_hplt_v3_pl` | `w pobliżu` | 9,877 | 0.00193% |
|
| 351 |
-
| `european_hplt_v3_pl` | `mieszkańców` | 33,939 | 0.00662% |
|
| 352 |
-
| `european_hplt_v3_pl` | `Dz.U.` | 1,482 | 0.00029% |
|
| 353 |
-
| `global_voices` | `w roku` | 160 | 0.00431% |
|
| 354 |
-
| `global_voices` | `klasyfikacji` | 5 | 0.00013% |
|
| 355 |
-
| `global_voices` | `ustawa` | 157 | 0.00423% |
|
| 356 |
-
| `global_voices` | `artykuł` | 1,047 | 0.02818% |
|
| 357 |
-
| `global_voices` | `parlament` | 366 | 0.00985% |
|
| 358 |
-
| `global_voices` | `rozporządzenie` | 26 | 0.00070% |
|
| 359 |
-
| `global_voices` | `w pobliżu` | 105 | 0.00283% |
|
| 360 |
-
| `global_voices` | `mieszkańców` | 508 | 0.01367% |
|
| 361 |
-
| `global_voices` | `Dz.U.` | 1 | 0.00003% |
|
| 362 |
-
| `govpl` | `w roku` | 3,372 | 0.00418% |
|
| 363 |
-
| `govpl` | `klasyfikacji` | 526 | 0.00065% |
|
| 364 |
-
| `govpl` | `ustawa` | 4,727 | 0.00586% |
|
| 365 |
-
| `govpl` | `artykuł` | 2,417 | 0.00300% |
|
| 366 |
-
| `govpl` | `parlament` | 3,967 | 0.00492% |
|
| 367 |
-
| `govpl` | `rozporządzenie` | 4,102 | 0.00509% |
|
| 368 |
-
| `govpl` | `w pobliżu` | 892 | 0.00111% |
|
| 369 |
-
| `govpl` | `mieszkańców` | 13,105 | 0.01625% |
|
| 370 |
-
| `govpl` | `Dz.U.` | 3,114 | 0.00386% |
|
| 371 |
-
| `nkjp1m` | `w roku` | 109 | 0.00419% |
|
| 372 |
-
| `nkjp1m` | `klasyfikacji` | 9 | 0.00035% |
|
| 373 |
-
| `nkjp1m` | `ustawa` | 79 | 0.00304% |
|
| 374 |
-
| `nkjp1m` | `artykuł` | 153 | 0.00588% |
|
| 375 |
-
| `nkjp1m` | `parlament` | 216 | 0.00830% |
|
| 376 |
-
| `nkjp1m` | `rozporządzenie` | 20 | 0.00077% |
|
| 377 |
-
| `nkjp1m` | `w pobliżu` | 77 | 0.00296% |
|
| 378 |
-
| `nkjp1m` | `mieszkańców` | 159 | 0.00611% |
|
| 379 |
-
| `nkjp1m` | `Dz.U.` | 2 | 0.00008% |
|
| 380 |
| `parliamentary` | `w roku` | 198,192 | 0.01203% |
|
| 381 |
| `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
|
| 382 |
| `parliamentary` | `ustawa` | 459,179 | 0.02788% |
|
|
|
|
| 19 |
edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword)
|
| 20 |
family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)).
|
| 21 |
|
| 22 |
+
> **v0.2.1 stable** · 2,491,773 documents · **6.28B tokens**
|
| 23 |
+
> (tiktoken proxy; canonical Llama-3 count at release) · 12 sources
|
| 24 |
+
> Updated: **2026-07-02**
|
| 25 |
|
| 26 |
+
> **v0.3.0-preview validation release** · live source-gate validation for
|
| 27 |
+
> SpeakLeash shards and direct Europeana candidate data, plus the quality/diversity
|
| 28 |
+
> remix workflow. This is candidate-only metadata and audit work: it does not
|
| 29 |
+
> replace the v0.2.1 stable parquets.
|
| 30 |
|
| 31 |
+
> **v0.3.1-preview** · first reproducible Europeana direct-ingestion shard:
|
|
|
|
| 32 |
> 1,000 API records → 810 quality-gated parquet documents, each preserving
|
| 33 |
> per-record rights and creator metadata. Stored separately under
|
| 34 |
+
> `previews/v0.3.1/europeana.parquet`; the paged Search API run took 59.4 s and
|
| 35 |
+
> does not alter v0.2.1 stable totals.
|
| 36 |
|
| 37 |
+
## Versions
|
|
|
|
|
|
|
| 38 |
|
| 39 |
| version | status | documents | tokens | notes |
|
| 40 |
|---|---|---:|---:|---|
|
| 41 |
+
| `v0.2.1` | stable release | 2,491,773 | 6.28B | 12-source stable corpus with `license` and `author` metadata columns; adds `1000_novels`. |
|
|
|
|
|
|
|
| 42 |
| `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
|
| 43 |
+
| `v0.3.0-preview` | validation release, candidate-only | candidate-only | TBD | Live source gates validated; Biblioteka Nauki, Europeana, and HPLT/Common Corpus expansion remain subject to per-source QA, dedup, and legal review. |
|
| 44 |
+
| `v0.3.1-preview` | reproducible Europeana shard | 810 | 140,042 | 1,000 direct API records sampled; 810 passed short/language/OCR gates, with per-record rights and author metadata. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## What this dataset contributes
|
| 47 |
The raw texts come from existing open corpora (redistributed via SpeakLeash and,
|
|
|
|
| 66 |
|
| 67 |
## Contributors
|
| 68 |
|
| 69 |
+
- **Kacper Wikieł** — corpus curation, release engineering, documentation, and
|
| 70 |
+
reproducible build workflow.
|
| 71 |
+
- **Bart Kobyliński** — source expansion work for Biblioteka Nauki and Europeana,
|
| 72 |
+
including per-document license/author metadata collection and rebuild planning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
## Guiding principles
|
| 75 |
1. **Open & traceable licensing** — every source is *openly licensed* with a documented
|
|
|
|
| 85 |
| [parliamentary](data/parliamentary/parliamentary.md) | Polish Parliamentary Corpus (Sejm/Senat) | `public-domain (official documents)` | 324,622 | 1,646.8M |
|
| 86 |
| [wikisource](data/wikisource/wikisource.md) | Polish Wikisource | `CC-BY-SA-3.0` | 632,005 | 801.9M |
|
| 87 |
| [wikipedia](data/wikipedia/wikipedia.md) | Polish Wikipedia | `CC-BY-SA-3.0` | 1,171,897 | 707.2M |
|
|
|
|
| 88 |
| [dziennik_ustaw](data/dziennik_ustaw/dziennik_ustaw.md) | Dziennik Ustaw + Monitor Polski (Polish primary legislation) | `public-domain (official documents)` | 35,442 | 486.1M |
|
| 89 |
| [wolne_lektury](data/wolne_lektury/wolne_lektury.md) | Wolne Lektury (school readings) | `CC-BY-SA-4.0 / Wolna Sztuka 1.3` | 6,141 | 103.0M |
|
|
|
|
| 90 |
| [1000_novels](data/1000_novels/1000_novels.md) | 1000 Novels Corpus (CLARIN-PL) | `CC-BY-4.0` | 1,000 | 60.5M |
|
| 91 |
| [wikiquote](data/wikiquote/wikiquote.md) | Polish Wikiquote (quotations) | `CC-BY-SA-3.0` | 30,363 | 31.9M |
|
| 92 |
| [eltec_pol](data/eltec_pol/eltec_pol.md) | ELTeC-pol (European Literary Text Collection, Polish) | `CC-BY-4.0` | 100 | 21.5M |
|
| 93 |
| [wikivoyage](data/wikivoyage/wikivoyage.md) | Polish Wikivoyage (travel guides) | `CC-BY-SA-3.0` | 13,645 | 17.1M |
|
| 94 |
| [wikibooks](data/wikibooks/wikibooks.md) | Polish Wikibooks (open textbooks) | `CC-BY-SA-3.0` | 9,112 | 15.6M |
|
| 95 |
| [wikinews](data/wikinews/wikinews.md) | Polish Wikinews | `CC-BY-2.5` | 24,386 | 12.1M |
|
| 96 |
+
| **total** | | | **2,491,773** | **6,281.9M** |
|
|
|
|
|
|
|
| 97 |
|
| 98 |
## Method
|
| 99 |
Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed
|
|
|
|
| 144 |
- Europeana release policy: split conservatively at pre-1929 records for
|
| 145 |
US-sensitive downstream reuse, and keep later/unknown records separately
|
| 146 |
labeled or held until legal review.
|
| 147 |
+
- `ashtok897/european-hplt-v1`: candidate workflow exists, but web-crawl
|
| 148 |
+
provenance, dedup, QA, and final mix weighting are still pending before stable
|
| 149 |
+
inclusion.
|
|
|
|
| 150 |
|
| 151 |
Current review artifacts:
|
| 152 |
|
|
|
|
| 214 |
|
| 215 |
Raw counts and token-normalized shares are regenerated from the current parquet files with `src/pattern_frequency_report.py`.
|
| 216 |
|
| 217 |
+
- Total token count (tiktoken proxy): **6,281,911,234**
|
| 218 |
|
| 219 |
| Pattern | Count | Share of all tokens |
|
| 220 |
|---|---:|---:|
|
| 221 |
+
| `w roku` | 435,541 | 0.0069% |
|
| 222 |
+
| `klasyfikacji` | 129,977 | 0.0021% |
|
| 223 |
+
| `ustawa` | 587,459 | 0.0094% |
|
| 224 |
+
| `artykuł` | 2,036,359 | 0.0324% |
|
| 225 |
+
| `parlament` | 1,201,641 | 0.0191% |
|
| 226 |
+
| `rozporządzenie` | 1,490,464 | 0.0237% |
|
| 227 |
+
| `w pobliżu` | 78,823 | 0.0013% |
|
| 228 |
+
| `mieszkańców` | 241,200 | 0.0038% |
|
| 229 |
+
| `Dz.U.` | 939,966 | 0.0150% |
|
| 230 |
|
| 231 |
### Per-source shares
|
| 232 |
|
|
|
|
| 268 |
| `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
|
| 269 |
| `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
|
| 270 |
| `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
| `parliamentary` | `w roku` | 198,192 | 0.01203% |
|
| 272 |
| `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
|
| 273 |
| `parliamentary` | `ustawa` | 459,179 | 0.02788% |
|
artifacts/dataset_size_by_version.png
DELETED
Git LFS Details
|
artifacts/pattern_frequency_artykul.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_dzu.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_hf_snippet.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
## Phrase frequency in corpus (token-normalized)
|
| 2 |
|
| 3 |
-
- Total token count (tiktoken proxy): **6,
|
| 4 |
|
| 5 |
| Pattern | Count | Share of all tokens |
|
| 6 |
|---|---:|---:|
|
| 7 |
-
| `w roku` |
|
| 8 |
-
| `klasyfikacji` |
|
| 9 |
-
| `ustawa` |
|
| 10 |
-
| `artykuł` | 2,
|
| 11 |
-
| `parlament` | 1,
|
| 12 |
-
| `rozporządzenie` | 1,
|
| 13 |
-
| `w pobliżu` |
|
| 14 |
-
| `mieszkańców` |
|
| 15 |
-
| `Dz.U.` |
|
| 16 |
|
| 17 |
### Per-source shares
|
| 18 |
|
|
@@ -54,42 +54,6 @@
|
|
| 54 |
| `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
|
| 55 |
| `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
|
| 56 |
| `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
|
| 57 |
-
| `european_hplt_v3_pl` | `w roku` | 21,067 | 0.00411% |
|
| 58 |
-
| `european_hplt_v3_pl` | `klasyfikacji` | 3,576 | 0.00070% |
|
| 59 |
-
| `european_hplt_v3_pl` | `ustawa` | 5,754 | 0.00112% |
|
| 60 |
-
| `european_hplt_v3_pl` | `artykuł` | 56,295 | 0.01099% |
|
| 61 |
-
| `european_hplt_v3_pl` | `parlament` | 10,618 | 0.00207% |
|
| 62 |
-
| `european_hplt_v3_pl` | `rozporządzenie` | 2,661 | 0.00052% |
|
| 63 |
-
| `european_hplt_v3_pl` | `w pobliżu` | 9,877 | 0.00193% |
|
| 64 |
-
| `european_hplt_v3_pl` | `mieszkańców` | 33,939 | 0.00662% |
|
| 65 |
-
| `european_hplt_v3_pl` | `Dz.U.` | 1,482 | 0.00029% |
|
| 66 |
-
| `global_voices` | `w roku` | 160 | 0.00431% |
|
| 67 |
-
| `global_voices` | `klasyfikacji` | 5 | 0.00013% |
|
| 68 |
-
| `global_voices` | `ustawa` | 157 | 0.00423% |
|
| 69 |
-
| `global_voices` | `artykuł` | 1,047 | 0.02818% |
|
| 70 |
-
| `global_voices` | `parlament` | 366 | 0.00985% |
|
| 71 |
-
| `global_voices` | `rozporządzenie` | 26 | 0.00070% |
|
| 72 |
-
| `global_voices` | `w pobliżu` | 105 | 0.00283% |
|
| 73 |
-
| `global_voices` | `mieszkańców` | 508 | 0.01367% |
|
| 74 |
-
| `global_voices` | `Dz.U.` | 1 | 0.00003% |
|
| 75 |
-
| `govpl` | `w roku` | 3,372 | 0.00418% |
|
| 76 |
-
| `govpl` | `klasyfikacji` | 526 | 0.00065% |
|
| 77 |
-
| `govpl` | `ustawa` | 4,727 | 0.00586% |
|
| 78 |
-
| `govpl` | `artykuł` | 2,417 | 0.00300% |
|
| 79 |
-
| `govpl` | `parlament` | 3,967 | 0.00492% |
|
| 80 |
-
| `govpl` | `rozporządzenie` | 4,102 | 0.00509% |
|
| 81 |
-
| `govpl` | `w pobliżu` | 892 | 0.00111% |
|
| 82 |
-
| `govpl` | `mieszkańców` | 13,105 | 0.01625% |
|
| 83 |
-
| `govpl` | `Dz.U.` | 3,114 | 0.00386% |
|
| 84 |
-
| `nkjp1m` | `w roku` | 109 | 0.00419% |
|
| 85 |
-
| `nkjp1m` | `klasyfikacji` | 9 | 0.00035% |
|
| 86 |
-
| `nkjp1m` | `ustawa` | 79 | 0.00304% |
|
| 87 |
-
| `nkjp1m` | `artykuł` | 153 | 0.00588% |
|
| 88 |
-
| `nkjp1m` | `parlament` | 216 | 0.00830% |
|
| 89 |
-
| `nkjp1m` | `rozporządzenie` | 20 | 0.00077% |
|
| 90 |
-
| `nkjp1m` | `w pobliżu` | 77 | 0.00296% |
|
| 91 |
-
| `nkjp1m` | `mieszkańców` | 159 | 0.00611% |
|
| 92 |
-
| `nkjp1m` | `Dz.U.` | 2 | 0.00008% |
|
| 93 |
| `parliamentary` | `w roku` | 198,192 | 0.01203% |
|
| 94 |
| `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
|
| 95 |
| `parliamentary` | `ustawa` | 459,179 | 0.02788% |
|
|
|
|
| 1 |
## Phrase frequency in corpus (token-normalized)
|
| 2 |
|
| 3 |
+
- Total token count (tiktoken proxy): **6,281,911,234**
|
| 4 |
|
| 5 |
| Pattern | Count | Share of all tokens |
|
| 6 |
|---|---:|---:|
|
| 7 |
+
| `w roku` | 435,541 | 0.0069% |
|
| 8 |
+
| `klasyfikacji` | 129,977 | 0.0021% |
|
| 9 |
+
| `ustawa` | 587,459 | 0.0094% |
|
| 10 |
+
| `artykuł` | 2,036,359 | 0.0324% |
|
| 11 |
+
| `parlament` | 1,201,641 | 0.0191% |
|
| 12 |
+
| `rozporządzenie` | 1,490,464 | 0.0237% |
|
| 13 |
+
| `w pobliżu` | 78,823 | 0.0013% |
|
| 14 |
+
| `mieszkańców` | 241,200 | 0.0038% |
|
| 15 |
+
| `Dz.U.` | 939,966 | 0.0150% |
|
| 16 |
|
| 17 |
### Per-source shares
|
| 18 |
|
|
|
|
| 54 |
| `eurlex` | `w pobliżu` | 6,088 | 0.00026% |
|
| 55 |
| `eurlex` | `mieszkańców` | 9,441 | 0.00040% |
|
| 56 |
| `eurlex` | `Dz.U.` | 915,707 | 0.03851% |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
| `parliamentary` | `w roku` | 198,192 | 0.01203% |
|
| 58 |
| `parliamentary` | `klasyfikacji` | 12,637 | 0.00077% |
|
| 59 |
| `parliamentary` | `ustawa` | 459,179 | 0.02788% |
|
artifacts/pattern_frequency_klasyfikacji.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_mieszkańców.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_overall.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_parlament.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_rozporządzenie.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_ustawa.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_w_pobliżu.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
artifacts/pattern_frequency_w_roku.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
data/biblioteka_nauki/biblioteka_nauki.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
# biblioteka_nauki
|
| 2 |
-
|
| 3 |
-
Biblioteka Nauki — Polish open-access scholarly corpus (scientific articles, books, chapters)
|
| 4 |
-
|
| 5 |
-
## Dataset description
|
| 6 |
-
- **Source (upstream):** https://bibliotekanauki.pl (operated by ICM, University of Warsaw — Centrum Otwartej Nauki)
|
| 7 |
-
- **Domain:** academic (scientific articles, books, chapters)
|
| 8 |
-
- **Language:** Polish (pl)
|
| 9 |
-
- **License:** per-document — CC BY 4.0 28,335 · CC BY-SA 4.0 13,733 · Public Domain 3
|
| 10 |
-
- **Created (range):** per-document publication year, from each item's bibliotekanauki.pl metadata
|
| 11 |
-
- **Added:** 2026-06-27
|
| 12 |
-
|
| 13 |
-
## Licensing — traceable basis
|
| 14 |
-
The SpeakLeash blob carries no per-document license field, and ~53% of the upstream collection is
|
| 15 |
-
all-rights-reserved, so a per-item gate was mandatory. Each item's license was recovered from the
|
| 16 |
-
bibliotekanauki.pl API (`bibliotekanauki.pl/api/{type}/<id>` → `license.iconId`). Only openly-licensed
|
| 17 |
-
items are kept; all-rights-reserved and unknown items are gated out. Recovery yielded 43,576 clean ids.
|
| 18 |
-
|
| 19 |
-
| license | documents |
|
| 20 |
-
|---|---:|
|
| 21 |
-
| CC BY 4.0 | 28,335 |
|
| 22 |
-
| CC BY-SA 4.0 | 13,733 |
|
| 23 |
-
| Public Domain | 3 |
|
| 24 |
-
|
| 25 |
-
The per-document license is carried in the parquet `license` column.
|
| 26 |
-
|
| 27 |
-
## Attribution
|
| 28 |
-
Per-document attribution (author · year · title · publisher) was re-fetched 1:1 from
|
| 29 |
-
bibliotekanauki.pl (43,576 / 43,576 ok) and is carried in the parquet `attribution` column,
|
| 30 |
-
satisfying the CC BY / CC BY-SA attribution requirement that applies to every document here.
|
| 31 |
-
|
| 32 |
-
## Provenance
|
| 33 |
-
Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key `biblioteka_nauki_pl_corpus`)
|
| 34 |
-
of the upstream source above. SpeakLeash credited as intermediate aggregator; upstream license and
|
| 35 |
-
attribution recovered per document and preserved.
|
| 36 |
-
|
| 37 |
-
## Statistics
|
| 38 |
-
| documents | characters | tokens (tiktoken proxy) |
|
| 39 |
-
|---:|---:|---:|
|
| 40 |
-
| 42,071 | 1,748,333,935 | 673,488,831 |
|
| 41 |
-
|
| 42 |
-
## Filters applied (build_dynaword.py)
|
| 43 |
-
Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
| 44 |
-
- drop documents < 200 chars: **0**
|
| 45 |
-
- drop non-Polish (diacritic ratio): **925**
|
| 46 |
-
- exact cross-source dedup (sha1): **180**
|
| 47 |
-
- OCR alpha-ratio < 0.70 (OCR source): **400**
|
| 48 |
-
- read 43,576 → kept 42,071
|
| 49 |
-
|
| 50 |
-
Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
|
| 51 |
-
Llama-3 count is computed at release.
|
| 52 |
-
|
| 53 |
-
## Limitations
|
| 54 |
-
- **Mixed license.** Roughly one third of the documents are CC BY-SA 4.0 (share-alike); the exact
|
| 55 |
-
per-document license is in the `license` column. Downstream redistribution must respect share-alike
|
| 56 |
-
for those documents.
|
| 57 |
-
- **OCR / extraction noise.** Text is extracted from publisher PDFs; some layout and hyphenation
|
| 58 |
-
artefacts remain after the alpha-ratio filter.
|
| 59 |
-
- **Per-document dates.** `created` is the publication year from upstream metadata; finer-grained
|
| 60 |
-
dates are not available.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/biblioteka_nauki/biblioteka_nauki.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26
|
| 3 |
-
size 1076638904
|
|
|
|
|
|
|
|
|
|
|
|
data/biblioteka_nauki/biblioteka_nauki.stats.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"read": 43576,
|
| 3 |
-
"kept": 42071,
|
| 4 |
-
"drop_short": 0,
|
| 5 |
-
"drop_lang": 925,
|
| 6 |
-
"drop_dup": 180,
|
| 7 |
-
"drop_ocr": 400,
|
| 8 |
-
"chars": 1748333935,
|
| 9 |
-
"tokens": 673488831,
|
| 10 |
-
"secs": 484.1,
|
| 11 |
-
"license": "CC-BY-4.0 / CC-BY-SA-4.0"
|
| 12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/biblioteka_nauki/recover_attribution.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Targeted attribution pass for the CLEAN (CC-BY/CC-BY-SA/PD) Biblioteka Nauki ids ONLY.
|
| 3 |
-
The first recovery pass stored the license correctly but parsed the wrong attribution fields.
|
| 4 |
-
CC-BY/CC-BY-SA legally REQUIRE attribution, so re-fetch just the ~43.6k clean ids and extract:
|
| 5 |
-
authors = contributors[role=AUTHOR] firstName+lastName ; year = dates[PUBLISHED].date.year ;
|
| 6 |
-
title = mainTitle.text ; publisher = publishingCompanyInfo.name
|
| 7 |
-
|
| 8 |
-
licenses.jsonl -> attribution.jsonl {type,id,license,authors,year,title,publisher}
|
| 9 |
-
Resumable, threaded, polite. ~43.6k calls.
|
| 10 |
-
"""
|
| 11 |
-
import json, os, random, sys, threading, time
|
| 12 |
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 13 |
-
import requests
|
| 14 |
-
|
| 15 |
-
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 16 |
-
LIC = os.path.join(HERE, "licenses.jsonl")
|
| 17 |
-
OUT = os.path.join(HERE, "attribution.jsonl")
|
| 18 |
-
PROG = os.path.join(HERE, "attribution_progress.txt")
|
| 19 |
-
CLEAN = {"cc-by", "cc-by-sa", "cc0", "public-domain"}
|
| 20 |
-
WORKERS = 8
|
| 21 |
-
UA = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
|
| 22 |
-
"(KHTML, like Gecko) Chrome/124 Safari/537.36")
|
| 23 |
-
HEADERS = {"User-Agent": UA, "Accept": "application/json", "Referer": "https://bibliotekanauki.pl/"}
|
| 24 |
-
_local = threading.local()
|
| 25 |
-
_wlock = threading.Lock()
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
def session():
|
| 29 |
-
s = getattr(_local, "s", None)
|
| 30 |
-
if s is None:
|
| 31 |
-
s = requests.Session()
|
| 32 |
-
s.headers.update(HEADERS)
|
| 33 |
-
s.mount("https://", requests.adapters.HTTPAdapter(pool_connections=4, pool_maxsize=4))
|
| 34 |
-
_local.s = s
|
| 35 |
-
return s
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
def parse(d):
|
| 39 |
-
authors = []
|
| 40 |
-
for c in (d.get("contributors") or []):
|
| 41 |
-
if c.get("role") == "AUTHOR":
|
| 42 |
-
nm = f"{c.get('firstName','') or ''} {c.get('lastName','') or ''}".strip()
|
| 43 |
-
if nm:
|
| 44 |
-
authors.append(nm)
|
| 45 |
-
year = None
|
| 46 |
-
dates = d.get("dates") or []
|
| 47 |
-
for dt in dates:
|
| 48 |
-
if dt.get("type") == "PUBLISHED":
|
| 49 |
-
year = (dt.get("date") or {}).get("year")
|
| 50 |
-
break
|
| 51 |
-
if not year and dates:
|
| 52 |
-
year = (dates[0].get("date") or {}).get("year")
|
| 53 |
-
title = (d.get("mainTitle") or {}).get("text")
|
| 54 |
-
pub = (d.get("publishingCompanyInfo") or {}).get("name")
|
| 55 |
-
return authors[:20], (str(year) if year else None), title, pub
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
def fetch(item):
|
| 59 |
-
typ, _id, lic = item
|
| 60 |
-
url = f"https://bibliotekanauki.pl/api/{typ}/{_id}"
|
| 61 |
-
for attempt in range(4):
|
| 62 |
-
try:
|
| 63 |
-
r = session().get(url, timeout=25)
|
| 64 |
-
if r.status_code == 200:
|
| 65 |
-
a, y, t, p = parse(r.json())
|
| 66 |
-
return {"type": typ, "id": _id, "license": lic,
|
| 67 |
-
"authors": a, "year": y, "title": t, "publisher": p, "status": "ok"}
|
| 68 |
-
if r.status_code in (403, 404, 410):
|
| 69 |
-
return {"type": typ, "id": _id, "license": lic, "status": f"http{r.status_code}"}
|
| 70 |
-
time.sleep((2 ** attempt) + random.random())
|
| 71 |
-
except Exception as e:
|
| 72 |
-
if attempt == 3:
|
| 73 |
-
return {"type": typ, "id": _id, "license": lic, "status": f"err:{type(e).__name__}"}
|
| 74 |
-
time.sleep((2 ** attempt) + random.random())
|
| 75 |
-
return {"type": typ, "id": _id, "license": lic, "status": "err:retries"}
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
def main():
|
| 79 |
-
best = {}
|
| 80 |
-
for l in open(LIC, encoding="utf-8"):
|
| 81 |
-
try:
|
| 82 |
-
r = json.loads(l)
|
| 83 |
-
except Exception:
|
| 84 |
-
continue
|
| 85 |
-
best[(r["type"], r["id"])] = r
|
| 86 |
-
clean = [(t, i, r["iconId"]) for (t, i), r in best.items()
|
| 87 |
-
if r.get("status") == "ok" and r.get("iconId") in CLEAN]
|
| 88 |
-
done = set()
|
| 89 |
-
if os.path.exists(OUT):
|
| 90 |
-
for l in open(OUT, encoding="utf-8"):
|
| 91 |
-
try:
|
| 92 |
-
r = json.loads(l)
|
| 93 |
-
done.add((r["type"], r["id"]))
|
| 94 |
-
except Exception:
|
| 95 |
-
pass
|
| 96 |
-
todo = [c for c in clean if (c[0], c[1]) not in done]
|
| 97 |
-
print(f"clean={len(clean)} done={len(done)} todo={len(todo)} workers={WORKERS}", flush=True)
|
| 98 |
-
|
| 99 |
-
out = open(OUT, "a", encoding="utf-8")
|
| 100 |
-
n = len(done)
|
| 101 |
-
t0 = time.time()
|
| 102 |
-
counts = {}
|
| 103 |
-
with ThreadPoolExecutor(max_workers=WORKERS) as ex:
|
| 104 |
-
futs = [ex.submit(fetch, c) for c in todo]
|
| 105 |
-
for fut in as_completed(futs):
|
| 106 |
-
res = fut.result()
|
| 107 |
-
with _wlock:
|
| 108 |
-
out.write(json.dumps(res, ensure_ascii=False) + "\n")
|
| 109 |
-
n += 1
|
| 110 |
-
counts[res.get("status")] = counts.get(res.get("status"), 0) + 1
|
| 111 |
-
time.sleep(random.uniform(0.02, 0.10))
|
| 112 |
-
if n % 500 == 0:
|
| 113 |
-
out.flush()
|
| 114 |
-
rate = (n - len(done)) / max(time.time() - t0, 1)
|
| 115 |
-
eta = (len(clean) - n) / max(rate, 0.1) / 60
|
| 116 |
-
msg = f"{n}/{len(clean)} {rate:.1f}/s ETA {eta:.0f}m " + \
|
| 117 |
-
" ".join(f"{k}={v}" for k, v in sorted(counts.items()))
|
| 118 |
-
print(msg, flush=True)
|
| 119 |
-
open(PROG, "w").write(msg + "\n")
|
| 120 |
-
out.flush(); out.close()
|
| 121 |
-
print(f"DONE attribution: {n}/{len(clean)} counts={counts}", flush=True)
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
if __name__ == "__main__":
|
| 125 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/biblioteka_nauki/recover_licenses.py
DELETED
|
@@ -1,171 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Pass 2: recover the per-item license for every Biblioteka Nauki doc via the public API.
|
| 3 |
-
index.jsonl -> GET bibliotekanauki.pl/api/{type}/{id} -> licenses.jsonl
|
| 4 |
-
|
| 5 |
-
Resumable (skips ids already in licenses.jsonl), polite (modest concurrency + jitter + backoff),
|
| 6 |
-
keep-alive sessions, and a circuit-breaker if the host starts blocking us.
|
| 7 |
-
|
| 8 |
-
Output line: {type,id, iconId, cc(bool), restricted(bool), authors, year, source, status}
|
| 9 |
-
status: "ok" | "http404" | "http403" | "err:<Type>"
|
| 10 |
-
"""
|
| 11 |
-
import json, os, random, sys, threading, time
|
| 12 |
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 13 |
-
import requests
|
| 14 |
-
|
| 15 |
-
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 16 |
-
INDEX = os.path.join(HERE, "index.jsonl")
|
| 17 |
-
OUT = os.path.join(HERE, "licenses.jsonl")
|
| 18 |
-
PROG = os.path.join(HERE, "recover_progress.txt")
|
| 19 |
-
|
| 20 |
-
WORKERS = 8
|
| 21 |
-
TIMEOUT = 25
|
| 22 |
-
MAX_RETRY = 4
|
| 23 |
-
UA = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "
|
| 24 |
-
"(KHTML, like Gecko) Chrome/124 Safari/537.36")
|
| 25 |
-
HEADERS = {"User-Agent": UA, "Accept": "application/json", "Referer": "https://bibliotekanauki.pl/"}
|
| 26 |
-
|
| 27 |
-
_local = threading.local()
|
| 28 |
-
_write_lock = threading.Lock()
|
| 29 |
-
_recent = [] # rolling window of recent statuses for the circuit breaker
|
| 30 |
-
_recent_lock = threading.Lock()
|
| 31 |
-
_stop = threading.Event()
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
def session():
|
| 35 |
-
s = getattr(_local, "s", None)
|
| 36 |
-
if s is None:
|
| 37 |
-
s = requests.Session()
|
| 38 |
-
s.headers.update(HEADERS)
|
| 39 |
-
a = requests.adapters.HTTPAdapter(pool_connections=4, pool_maxsize=4)
|
| 40 |
-
s.mount("https://", a)
|
| 41 |
-
_local.s = s
|
| 42 |
-
return s
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
def load_done():
|
| 46 |
-
done = set()
|
| 47 |
-
if os.path.exists(OUT):
|
| 48 |
-
with open(OUT, encoding="utf-8") as f:
|
| 49 |
-
for line in f:
|
| 50 |
-
try:
|
| 51 |
-
r = json.loads(line)
|
| 52 |
-
done.add((r["type"], r["id"]))
|
| 53 |
-
except Exception:
|
| 54 |
-
pass
|
| 55 |
-
return done
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
def fetch(item):
|
| 59 |
-
if _stop.is_set():
|
| 60 |
-
return None
|
| 61 |
-
typ, _id = item["type"], item["id"]
|
| 62 |
-
url = f"https://bibliotekanauki.pl/api/{typ}/{_id}"
|
| 63 |
-
for attempt in range(MAX_RETRY):
|
| 64 |
-
try:
|
| 65 |
-
r = session().get(url, timeout=TIMEOUT)
|
| 66 |
-
if r.status_code == 200:
|
| 67 |
-
d = r.json()
|
| 68 |
-
lic = d.get("license") or {}
|
| 69 |
-
authors = []
|
| 70 |
-
for c in (d.get("contributors") or []):
|
| 71 |
-
nm = (c.get("name") or "").strip()
|
| 72 |
-
if nm:
|
| 73 |
-
authors.append(nm)
|
| 74 |
-
year = None
|
| 75 |
-
for dt in (d.get("dates") or []):
|
| 76 |
-
y = str(dt.get("year") or dt.get("value") or "")[:4]
|
| 77 |
-
if y.isdigit():
|
| 78 |
-
year = y
|
| 79 |
-
break
|
| 80 |
-
insts = d.get("publicationInstitutions") or d.get("journal") or None
|
| 81 |
-
if isinstance(insts, list):
|
| 82 |
-
insts = "; ".join(x.get("name", "") if isinstance(x, dict) else str(x) for x in insts) or None
|
| 83 |
-
return {
|
| 84 |
-
"type": typ, "id": _id,
|
| 85 |
-
"iconId": lic.get("iconId"),
|
| 86 |
-
"cc": bool(lic.get("creativeCommons")),
|
| 87 |
-
"restricted": bool(d.get("restricted")),
|
| 88 |
-
"authors": authors[:12],
|
| 89 |
-
"year": year,
|
| 90 |
-
"source": insts,
|
| 91 |
-
"status": "ok",
|
| 92 |
-
}
|
| 93 |
-
if r.status_code in (403,):
|
| 94 |
-
return {"type": typ, "id": _id, "status": "http403"}
|
| 95 |
-
if r.status_code in (404, 410):
|
| 96 |
-
return {"type": typ, "id": _id, "status": "http404"}
|
| 97 |
-
# 429 / 5xx -> backoff & retry
|
| 98 |
-
time.sleep((2 ** attempt) + random.random())
|
| 99 |
-
except Exception as e:
|
| 100 |
-
if attempt == MAX_RETRY - 1:
|
| 101 |
-
return {"type": typ, "id": _id, "status": f"err:{type(e).__name__}"}
|
| 102 |
-
time.sleep((2 ** attempt) + random.random())
|
| 103 |
-
return {"type": typ, "id": _id, "status": "err:retries"}
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
def note(status):
|
| 107 |
-
with _recent_lock:
|
| 108 |
-
_recent.append(status)
|
| 109 |
-
if len(_recent) > 200:
|
| 110 |
-
_recent.pop(0)
|
| 111 |
-
# circuit breaker: >60% 403 over a full window => host is blocking us
|
| 112 |
-
if len(_recent) == 200 and sum(1 for s in _recent if s == "http403") > 120:
|
| 113 |
-
_stop.set()
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
def main():
|
| 117 |
-
if not os.path.exists(INDEX):
|
| 118 |
-
sys.exit(f"missing {INDEX} — run build_index.py first")
|
| 119 |
-
items = []
|
| 120 |
-
with open(INDEX, encoding="utf-8") as f:
|
| 121 |
-
for line in f:
|
| 122 |
-
try:
|
| 123 |
-
r = json.loads(line)
|
| 124 |
-
items.append({"type": r["type"], "id": r["id"]})
|
| 125 |
-
except Exception:
|
| 126 |
-
pass
|
| 127 |
-
done = load_done()
|
| 128 |
-
todo = [it for it in items if (it["type"], it["id"]) not in done]
|
| 129 |
-
total = len(items)
|
| 130 |
-
print(f"index={total} done={len(done)} todo={len(todo)} workers={WORKERS}", flush=True)
|
| 131 |
-
|
| 132 |
-
n = len(done)
|
| 133 |
-
t0 = time.time()
|
| 134 |
-
out = open(OUT, "a", encoding="utf-8")
|
| 135 |
-
counts = {}
|
| 136 |
-
try:
|
| 137 |
-
with ThreadPoolExecutor(max_workers=WORKERS) as ex:
|
| 138 |
-
futs = [ex.submit(fetch, it) for it in todo]
|
| 139 |
-
for fut in as_completed(futs):
|
| 140 |
-
res = fut.result()
|
| 141 |
-
if res is None:
|
| 142 |
-
continue
|
| 143 |
-
with _write_lock:
|
| 144 |
-
out.write(json.dumps(res, ensure_ascii=False) + "\n")
|
| 145 |
-
n += 1
|
| 146 |
-
st = res.get("status", "?")
|
| 147 |
-
counts[st] = counts.get(st, 0) + 1
|
| 148 |
-
note(st)
|
| 149 |
-
# politeness jitter (per completed task; with 8 workers ~ a few hundred req/min)
|
| 150 |
-
time.sleep(random.uniform(0.02, 0.12))
|
| 151 |
-
if n % 500 == 0:
|
| 152 |
-
out.flush()
|
| 153 |
-
rate = (n - len(done)) / max(time.time() - t0, 1)
|
| 154 |
-
eta = (total - n) / max(rate, 0.1) / 60
|
| 155 |
-
msg = (f"{n}/{total} {rate:.1f}/s ETA {eta:.0f}m "
|
| 156 |
-
+ " ".join(f"{k}={v}" for k, v in sorted(counts.items())))
|
| 157 |
-
print(msg, flush=True)
|
| 158 |
-
with open(PROG, "w") as p:
|
| 159 |
-
p.write(msg + "\n")
|
| 160 |
-
if _stop.is_set():
|
| 161 |
-
print("!! circuit breaker tripped (sustained 403) — stopping. Re-run later to resume.", flush=True)
|
| 162 |
-
break
|
| 163 |
-
finally:
|
| 164 |
-
out.flush()
|
| 165 |
-
out.close()
|
| 166 |
-
print(f"FINISHED pass: wrote {n}/{total}. counts={counts}", flush=True)
|
| 167 |
-
print("Next: build_parquet.py to assemble the CC-BY/SA subset.", flush=True)
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
if __name__ == "__main__":
|
| 171 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/european_hplt_v3_pl/european_hplt_v3_pl.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
# european_hplt_v3_pl
|
| 2 |
-
|
| 3 |
-
Filtered Polish subset of **HPLT v3.0** (`pol_Latn`), top quality bins (WDS = 10 and 9), merged into one file.
|
| 4 |
-
|
| 5 |
-
## Dataset description
|
| 6 |
-
- **Source (upstream):** https://hplt-project.org/datasets/v3.0 (`pol_Latn`, shards `10_1` [WDS=10] + `9_1` prefix [WDS=9])
|
| 7 |
-
- **Domain:** web (modern natural Polish — informational, narrative, opinion, how-to, discussion)
|
| 8 |
-
- **Language:** Polish (pl)
|
| 9 |
-
- **License:** `CC0-1.0` (packaging; see licensing note)
|
| 10 |
-
- **Created (range):** web crawls 2012-2024 (Internet Archive + Common Crawl)
|
| 11 |
-
- **Added:** 2026-07-14
|
| 12 |
-
|
| 13 |
-
## Licensing - traceable basis
|
| 14 |
-
HPLT licenses the **packaging** of these text data under Creative Commons CC0 1.0 ("no rights reserved"),
|
| 15 |
-
per the HPLT v3.0 Terms of Use (hplt-project.org/datasets/v3.0) and the HF card `HPLT/HPLT3.0`.
|
| 16 |
-
HPLT does not own the underlying web text; a notice-and-takedown policy applies and downstream users
|
| 17 |
-
remain responsible for compliance (EU CDSM Directive 2019/790, GDPR). This is a web-crawl source: it is
|
| 18 |
-
offered at parity with the already-listed `european-hplt-v1` (CC0) basis and still needs maintainer
|
| 19 |
-
web/legal review (`accept_after_web_review`), not auto-accept.
|
| 20 |
-
|
| 21 |
-
## Provenance
|
| 22 |
-
Fetched directly from the HPLT distribution (`data.hplt-project.org/three/sorted/pol_Latn/{10_1,9_1}.jsonl.zst`),
|
| 23 |
-
NOT via SpeakLeash. HPLT v3 is globally deduplicated upstream and sorted into Web-Docs-Scorer (WDS) quality
|
| 24 |
-
bins; only the two top bins are used. Per-document URL, WDS score, web-register, MT-probability and PII spans
|
| 25 |
-
are available in the raw HPLT record and were used for filtering (not retained in the released canonical schema).
|
| 26 |
-
|
| 27 |
-
## Statistics
|
| 28 |
-
| documents | characters | tokens (tiktoken cl100k proxy) |
|
| 29 |
-
|---:|---:|---:|
|
| 30 |
-
| 110,590 | 1,426,290,944 | 512,383,778 |
|
| 31 |
-
|
| 32 |
-
Composition (single merged parquet): bin-10 (WDS=10) 55,590 docs / 261,468,813 tok;
|
| 33 |
-
bin-9 (WDS=9) 55,000 docs / 250,914,965 tok. See `european_hplt_v3_pl.stats.json` for the per-bin + drop breakdown.
|
| 34 |
-
|
| 35 |
-
## Per-document license metadata
|
| 36 |
-
| license | documents |
|
| 37 |
-
|---|---:|
|
| 38 |
-
| `CC0-1.0` | 110,590 |
|
| 39 |
-
|
| 40 |
-
## Filters applied (src/clean_hplt_v3.py; thresholds inherited from src/filter_european_hplt.py)
|
| 41 |
-
Per-shard keep: bin-10 55,590/195,874 (28.4%), bin-9 55,000/152,380 (36.1%). Drop reasons:
|
| 42 |
-
`register` (not ID/OP/HI/IN/NA), `machine_translated` (MT>=0.20), `domain`
|
| 43 |
-
(wikipedia/wikisource/wikimedia + file-hosts excluded), `adult_spam`, `legalish` (drops legal/parliamentary
|
| 44 |
-
phrasing - serves the anti-legalese goal), `boilerplate`, `too_long` (>120k chars = book-length copyright/OCR
|
| 45 |
-
risk), `mojibake` (>=3 CJK/replacement chars - upstream HPLT UTF-8->GBK mis-decode), `filehost` (PDF/file-share
|
| 46 |
-
headers), `domain_cap` (>250 docs/domain). MT-probability of kept docs: mean ~0.08. Mojibake residual: 0.
|
| 47 |
-
|
| 48 |
-
## Status & caveats (web-crawl - NOT "release-clean")
|
| 49 |
-
- **Copyright is not fully solved by filtering.** The length cap removes obvious book-length works, but
|
| 50 |
-
in-copyright text recurs in web-crawl at ALL lengths (news reprints, blog reposts, excerpts). Inherent to
|
| 51 |
-
web sources; the reason HPLT ships CC0-on-packaging + notice-and-takedown.
|
| 52 |
-
- **Near-dup NOT removed** (Dynaword leaves heavy filtering downstream). ~11.8% of an HPLT sample's 8-grams
|
| 53 |
-
overlap Polish Wikipedia; wikipedia/wikisource domain exclusion mitigates the largest sources, but
|
| 54 |
-
cross-source near/containment dedup vs the full corpus remains a downstream step.
|
| 55 |
-
- Surface-metric parity with accepted sources: mojibake 0%, boilerplate ~0.2%, diacritic-ratio ~0.066,
|
| 56 |
-
TTR@500 ~0.64 (within the accepted range, ~= parliamentary). ~9% commercial/SEO-adjacent pages (web-inherent).
|
| 57 |
-
- This is 2 top bins merged. The full `pol_Latn` corpus is ~270B raw tokens across WDS bins 10->5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/european_hplt_v3_pl/european_hplt_v3_pl.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6295b3280cef2b99e9bf511a1c48be9c94cd219455d2e9666ebf17363771b714
|
| 3 |
-
size 610242503
|
|
|
|
|
|
|
|
|
|
|
|
data/european_hplt_v3_pl/european_hplt_v3_pl.stats.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"read": 348254,
|
| 3 |
-
"kept": 110590,
|
| 4 |
-
"drop_short": 0,
|
| 5 |
-
"drop_lang": 2,
|
| 6 |
-
"drop_dup": 0,
|
| 7 |
-
"drop_ocr": 0,
|
| 8 |
-
"chars": 1426290944,
|
| 9 |
-
"tokens": 512383778,
|
| 10 |
-
"licenses": {
|
| 11 |
-
"CC0-1.0": 110590
|
| 12 |
-
},
|
| 13 |
-
"authors_with_value": 0,
|
| 14 |
-
"license": "CC0-1.0",
|
| 15 |
-
"stats_recomputed_from_parquet": true,
|
| 16 |
-
"drop_detail": {
|
| 17 |
-
"machine_translated": 46477,
|
| 18 |
-
"adult_spam": 18682,
|
| 19 |
-
"register": 128956,
|
| 20 |
-
"legalish": 15881,
|
| 21 |
-
"domain": 23234,
|
| 22 |
-
"boilerplate": 3183,
|
| 23 |
-
"mojibake": 241,
|
| 24 |
-
"too_long": 216,
|
| 25 |
-
"filehost": 7,
|
| 26 |
-
"lang_prob": 2,
|
| 27 |
-
"domain_cap": 785
|
| 28 |
-
},
|
| 29 |
-
"shards": {
|
| 30 |
-
"bin10_WDS10": {
|
| 31 |
-
"kept": 55590,
|
| 32 |
-
"tokens": 261468813
|
| 33 |
-
},
|
| 34 |
-
"bin9_WDS9": {
|
| 35 |
-
"kept": 55000,
|
| 36 |
-
"tokens": 250914965
|
| 37 |
-
}
|
| 38 |
-
},
|
| 39 |
-
"mt_prob_mean_kept": 0.08,
|
| 40 |
-
"source_repo": "HPLT/HPLT3.0 pol_Latn WDS bins 10+9 (data.hplt-project.org)"
|
| 41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/global_voices/NOTICE.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
# NOTICE — Global Voices source
|
| 2 |
-
|
| 3 |
-
The exported article text is attributed to Global Voices and the credited
|
| 4 |
-
original authors and translators under Creative Commons Attribution 3.0.
|
| 5 |
-
|
| 6 |
-
Source: https://pl.globalvoices.org/
|
| 7 |
-
License: https://creativecommons.org/licenses/by/3.0/
|
| 8 |
-
|
| 9 |
-
Per-record contributor attribution is stored in the `author` column. The accompanying `global_voices.attribution.jsonl` sidecar additionally preserves each released article's title, canonical URL, license URL and modification notice. Twelve historical records had no machine-readable contributor field; full-text review recovered Didem Tali and Khalid Ibrahim for two of them. Ten records without an identifiable contributor use the explicitly organizational attribution `Global Voices`; this must not be interpreted as a known individual author.
|
| 10 |
-
|
| 11 |
-
Binary media files are not included. Articles may nevertheless contain captions, URLs, social-media posts and quotations from third-party works; rights in those materials may remain with their respective authors. Article-level CC BY 3.0 is not asserted independently for photographs, videos, embeds or separately quoted works.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/global_voices/global_voices.attribution.jsonl
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/global_voices/global_voices.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
# global_voices
|
| 2 |
-
|
| 3 |
-
Polish-language civic-media and public-interest journalism from [Global Voices](https://pl.globalvoices.org/), produced by its international community of writers and volunteer translators.
|
| 4 |
-
|
| 5 |
-
## Dataset description
|
| 6 |
-
|
| 7 |
-
- **Source (upstream):** https://pl.globalvoices.org/
|
| 8 |
-
- **Domain:** civic media, news and public-interest journalism
|
| 9 |
-
- **Language:** Polish (pl)
|
| 10 |
-
- **License:** `CC-BY-3.0`
|
| 11 |
-
- **Created (range):** 2008-11-04, 2023-05-24
|
| 12 |
-
- **Added:** 2026-07-15
|
| 13 |
-
|
| 14 |
-
Global Voices describes its Lingua translations as human-made work performed by a volunteer translator community. The dataset primarily represents edited, translated journalism rather than conversational Polish or text necessarily authored originally in Polish.
|
| 15 |
-
|
| 16 |
-
## Statistics
|
| 17 |
-
|
| 18 |
-
| documents | characters | tokens (`cl100k_base` proxy) |
|
| 19 |
-
|---:|---:|---:|
|
| 20 |
-
| 2,040 | 10,073,628 | 3,715,020 |
|
| 21 |
-
|
| 22 |
-
The Parquet schema matches DynaWord:
|
| 23 |
-
|
| 24 |
-
`id, text, source, added, created, token_count, license, author`
|
| 25 |
-
|
| 26 |
-
Published files:
|
| 27 |
-
|
| 28 |
-
- `global_voices.parquet` — cleaned article text and DynaWord metadata;
|
| 29 |
-
- `global_voices.stats.json` — release statistics;
|
| 30 |
-
- `global_voices.attribution.jsonl` — title, canonical article URL, contributor attribution, license URL and modification notice for every document;
|
| 31 |
-
- `NOTICE.md` — licensing and attribution notice.
|
| 32 |
-
|
| 33 |
-
## Provenance
|
| 34 |
-
|
| 35 |
-
Articles were acquired directly from the Polish Global Voices website through its official publication interfaces, rather than from a third-party corpus. Each released ID is linked to the corresponding canonical article URL in `global_voices.attribution.jsonl`.
|
| 36 |
-
|
| 37 |
-
The source release contained 2,044 records. Four records below the minimum quality and length requirements were excluded, leaving 2,040 documents. The final source contains no exact duplicate documents.
|
| 38 |
-
|
| 39 |
-
## Cleaning
|
| 40 |
-
|
| 41 |
-
The release received a reviewed cleaning pass. Redundant source-language passages were removed where the corresponding Polish translation was retained, together with extraction artifacts and obsolete interface text. Intentional quotations and source-language material required for meaning or documentary context were preserved.
|
| 42 |
-
|
| 43 |
-
The cleaning process did not use machine translation or automatic speech transcription. It should not be interpreted as making every document strictly monolingual.
|
| 44 |
-
|
| 45 |
-
## Licensing — traceable basis and attribution
|
| 46 |
-
|
| 47 |
-
CC BY 3.0 was verified from the article-level license link published with each retained Global Voices article. Each released record carries `CC-BY-3.0` metadata. Contributor roles are preserved in the `author` column where available, distinguishing original authors from Polish translators.
|
| 48 |
-
|
| 49 |
-
Because the fixed DynaWord schema does not contain article titles or URLs, the attribution sidecar maps every released `id` to its title, canonical URL, contributor attribution, license URL and modification notice. It contains one unique URL-bearing record for each of the 2,040 Parquet documents.
|
| 50 |
-
|
| 51 |
-
Recommended attribution:
|
| 52 |
-
|
| 53 |
-
> Global Voices; the original author(s) and Polish translator(s) listed in the attribution sidecar; canonical article URL; CC BY 3.0. Article text was extracted and cleaned; redundant source-language passages were removed where a Polish translation was retained.
|
| 54 |
-
|
| 55 |
-
Binary photographs, videos and embedded media are not redistributed. Articles may contain quotations, captions or social-media text whose separate rights remain with their respective authors.
|
| 56 |
-
|
| 57 |
-
## Limitations and recommended use
|
| 58 |
-
|
| 59 |
-
- The dataset represents edited online journalism and human translation, not the full distribution of contemporary Polish.
|
| 60 |
-
- Translationese and source-specific editorial conventions may be present.
|
| 61 |
-
- Some intentional source-language quotations remain inside otherwise Polish articles.
|
| 62 |
-
- Coverage ends in May 2023.
|
| 63 |
-
- Cross-source and near-duplicate removal against other DynaWord sources remains part of the complete corpus build.
|
| 64 |
-
|
| 65 |
-
Global Voices is best used as a complementary source of contemporary civic-media and journalistic Polish, rather than as a standalone representation of colloquial or natively authored Polish.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/global_voices/global_voices.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1ca02fdb6bad32b20757ddcd9b9f072056ff35b68c487143138cc7912b3a45c3
|
| 3 |
-
size 5253559
|
|
|
|
|
|
|
|
|
|
|
|
data/global_voices/global_voices.stats.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"read": 2044,
|
| 3 |
-
"kept": 2040,
|
| 4 |
-
"drop_short": 4,
|
| 5 |
-
"drop_lang": 0,
|
| 6 |
-
"drop_dup": 0,
|
| 7 |
-
"drop_ocr": 0,
|
| 8 |
-
"chars": 10073628,
|
| 9 |
-
"tokens": 3715020,
|
| 10 |
-
"licenses": {
|
| 11 |
-
"CC-BY-3.0": 2040
|
| 12 |
-
},
|
| 13 |
-
"authors_with_value": 2040,
|
| 14 |
-
"stats_recomputed_from_parquet": true
|
| 15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/govpl/govpl.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
# govpl
|
| 2 |
-
|
| 3 |
-
gov.pl — Polish government press releases
|
| 4 |
-
|
| 5 |
-
## Dataset description
|
| 6 |
-
- **Source (upstream):** https://www.gov.pl/
|
| 7 |
-
- **Domain:** government
|
| 8 |
-
- **Language:** Polish (pl)
|
| 9 |
-
- **License:** `CC-BY-SA-4.0`
|
| 10 |
-
- **Created (range):** 2005-09-26, 2026-07-19
|
| 11 |
-
- **Added:** 2026-07-19
|
| 12 |
-
|
| 13 |
-
## Licensing — traceable basis
|
| 14 |
-
All textual content on gov.pl is published under CC-BY-SA 4.0 (site footer: "Treści tekstowe publikowane w serwisie … są udostępniane na licencji CC BY-SA 4.0"). Authored and hosted by the Polish government, which holds the right to license it — same open family as Polish Wikipedia.
|
| 15 |
-
|
| 16 |
-
## Provenance
|
| 17 |
-
Ministry/agency press releases fetched directly from gov.pl (editor-content per article, HTML stripped) by src/fetch_govpl.py. Subsites + their non-uniform news-section paths are enumerated by src/discover_govpl.py into the committed manifest src/govpl_subsites.json (gov.pl has no sitemap/API). Each record's meta.url resolves on gov.pl.
|
| 18 |
-
|
| 19 |
-
## Statistics
|
| 20 |
-
| documents | characters | tokens (tiktoken proxy) |
|
| 21 |
-
|---:|---:|---:|
|
| 22 |
-
| 88,190 | 218,099,000 | 80,666,129 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
## Per-document license metadata
|
| 26 |
-
| license | documents |
|
| 27 |
-
|---|---:|
|
| 28 |
-
| `CC-BY-SA-4.0` | 88,190 |
|
| 29 |
-
|
| 30 |
-
Author metadata present for **0** documents. Empty values mean the upstream record did not expose a machine-readable author field.
|
| 31 |
-
|
| 32 |
-
## Filters applied (build_dynaword.py)
|
| 33 |
-
Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
| 34 |
-
- drop documents < 200 chars: **0**
|
| 35 |
-
- drop non-Polish (diacritic ratio): **24**
|
| 36 |
-
- exact cross-source dedup (sha1): **1,926**
|
| 37 |
-
- OCR alpha-ratio < 0.70 (OCR sources only): **0**
|
| 38 |
-
- read 90,140 → kept 88,190
|
| 39 |
-
|
| 40 |
-
Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
|
| 41 |
-
Llama-3 count is computed at release.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/govpl/govpl.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:9c0310fcdf45804e6547bd197cba55f58f12df618cd3d8b92b8e9077a3720b9f
|
| 3 |
-
size 82940575
|
|
|
|
|
|
|
|
|
|
|
|
data/govpl/govpl.stats.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"read": 90140,
|
| 3 |
-
"kept": 88190,
|
| 4 |
-
"drop_short": 0,
|
| 5 |
-
"drop_lang": 24,
|
| 6 |
-
"drop_dup": 1926,
|
| 7 |
-
"drop_ocr": 0,
|
| 8 |
-
"chars": 218099000,
|
| 9 |
-
"tokens": 80666129,
|
| 10 |
-
"licenses": {
|
| 11 |
-
"CC-BY-SA-4.0": 88190
|
| 12 |
-
},
|
| 13 |
-
"authors_with_value": 0,
|
| 14 |
-
"secs": 2.9,
|
| 15 |
-
"license": "CC-BY-SA-4.0"
|
| 16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/nkjp1m/nkjp1m.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
# nkjp1m
|
| 2 |
-
|
| 3 |
-
The manually annotated 1-million word subcorpus of the National Corpus of Polish
|
| 4 |
-
|
| 5 |
-
## Dataset description
|
| 6 |
-
- **Source (upstream):** https://clip.ipipan.waw.pl/NationalCorpusOfPolish
|
| 7 |
-
- **Domain:** mixed (balanced reference corpus)
|
| 8 |
-
- **Language:** Polish (pl)
|
| 9 |
-
- **License:** `CC-BY`
|
| 10 |
-
- **Created (range):** 1957-2008 (recorded for 6,581 of 18,381 documents; per-document in the created column)
|
| 11 |
-
- **Added:** 2026-06-15
|
| 12 |
-
|
| 13 |
-
## Licensing — traceable basis
|
| 14 |
-
The NKJP download page (clip.ipipan.waw.pl) states the manually annotated 1-million-word subcorpus (Podkorpus Milionowy NKJP 1.2) is available under a CC-BY licence; attribution to the NKJP Consortium (IPI PAN) preserved. The page states 'CC-BY' with no version, normalized to CC-BY-4.0 for SPDX. The CC-BY licence covers the corpus text; NKJP's separate tools are GPL and are not included here.
|
| 15 |
-
|
| 16 |
-
## Provenance
|
| 17 |
-
Downloaded the IPI PAN tarball (NKJP-PodkorpusMilionowy-1.2.tar.gz) directly by src/fetch_njkp.py, one row per TEI <div> passage (its <ab> paragraphs joined by newlines, ellipsis markers stripped). The same minimal gates as build_dynaword.py are applied per passage (drop < 200 chars, drop non-Polish by diacritic ratio, exact sha1 dedup; the OCR gate is inapplicable). Per-document 'created' is the sample's TEI publication date (<date type="published">) where the header records one. Normalized into the DynaWord schema; cl100k token counts via tiktoken (encode_ordinary), and the stats are recomputed from the written parquet.
|
| 18 |
-
|
| 19 |
-
## Statistics
|
| 20 |
-
| documents | characters | tokens (tiktoken proxy) |
|
| 21 |
-
| --------: | ---------: | ----------------------: |
|
| 22 |
-
| 18,381 | 6,824,905 | 2,601,201 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
## Per-document license metadata
|
| 26 |
-
| license | documents |
|
| 27 |
-
| ------- | --------: |
|
| 28 |
-
| `CC-BY` | 18,381 |
|
| 29 |
-
|
| 30 |
-
Author metadata present for **18,381** documents. Empty values mean the upstream record did not expose a machine-readable author field.
|
| 31 |
-
|
| 32 |
-
Statistics were recomputed directly from the released parquet file.
|
| 33 |
-
|
| 34 |
-
## Filters applied (build_dynaword.py)
|
| 35 |
-
Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
| 36 |
-
- drop documents < 200 chars: **92**
|
| 37 |
-
- drop non-Polish (diacritic ratio): **2**
|
| 38 |
-
- exact cross-source dedup (sha1): **9**
|
| 39 |
-
- OCR alpha-ratio < 0.70 (OCR sources only): **0**
|
| 40 |
-
- read 18,484 → kept 18,381
|
| 41 |
-
|
| 42 |
-
Token counts are a fast tiktoken (cl100k) proxy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/nkjp1m/nkjp1m.parquet
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:75f6a0d37c344960baa70e1d582f9908bc60f8bfee75bba97a68cecadbb745c7
|
| 3 |
-
size 3718378
|
|
|
|
|
|
|
|
|
|
|
|
data/nkjp1m/nkjp1m.stats.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"read": 18484,
|
| 3 |
-
"kept": 18381,
|
| 4 |
-
"drop_short": 92,
|
| 5 |
-
"drop_lang": 2,
|
| 6 |
-
"drop_dup": 9,
|
| 7 |
-
"drop_ocr": 0,
|
| 8 |
-
"chars": 6824905,
|
| 9 |
-
"tokens": 2601201,
|
| 10 |
-
"licenses": {
|
| 11 |
-
"CC-BY": 18381
|
| 12 |
-
},
|
| 13 |
-
"authors_with_value": 18381,
|
| 14 |
-
"documents_with_created": 6581,
|
| 15 |
-
"created_range": "1957-2008",
|
| 16 |
-
"license": "CC-BY",
|
| 17 |
-
"stats_recomputed_from_parquet": true
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pattern_frequency_report.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
## Pattern frequency on corpus
|
| 2 |
|
| 3 |
-
- total tokens (tiktoken proxy): `6,
|
| 4 |
|
| 5 |
| pattern | count | share of all tokens |
|
| 6 |
|---|---:|---:|
|
| 7 |
-
| `w roku` |
|
| 8 |
-
| `klasyfikacji` |
|
| 9 |
-
| `ustawa` |
|
| 10 |
-
| `artykuł` | 2,
|
| 11 |
-
| `parlament` | 1,
|
| 12 |
-
| `rozporządzenie` | 1,
|
| 13 |
-
| `w pobliżu` |
|
| 14 |
-
| `mieszkańców` |
|
| 15 |
-
| `Dz.U.` |
|
| 16 |
|
| 17 |
| source | pattern | count | per-token share |
|
| 18 |
|---|---|---:|---:|
|
|
@@ -52,42 +52,6 @@
|
|
| 52 |
| eurlex | `w pobliżu` | 6,088 | 0.00026% |
|
| 53 |
| eurlex | `mieszkańców` | 9,441 | 0.00040% |
|
| 54 |
| eurlex | `Dz.U.` | 915,707 | 0.03851% |
|
| 55 |
-
| european_hplt_v3_pl | `w roku` | 21,067 | 0.00411% |
|
| 56 |
-
| european_hplt_v3_pl | `klasyfikacji` | 3,576 | 0.00070% |
|
| 57 |
-
| european_hplt_v3_pl | `ustawa` | 5,754 | 0.00112% |
|
| 58 |
-
| european_hplt_v3_pl | `artykuł` | 56,295 | 0.01099% |
|
| 59 |
-
| european_hplt_v3_pl | `parlament` | 10,618 | 0.00207% |
|
| 60 |
-
| european_hplt_v3_pl | `rozporządzenie` | 2,661 | 0.00052% |
|
| 61 |
-
| european_hplt_v3_pl | `w pobliżu` | 9,877 | 0.00193% |
|
| 62 |
-
| european_hplt_v3_pl | `mieszkańców` | 33,939 | 0.00662% |
|
| 63 |
-
| european_hplt_v3_pl | `Dz.U.` | 1,482 | 0.00029% |
|
| 64 |
-
| global_voices | `w roku` | 160 | 0.00431% |
|
| 65 |
-
| global_voices | `klasyfikacji` | 5 | 0.00013% |
|
| 66 |
-
| global_voices | `ustawa` | 157 | 0.00423% |
|
| 67 |
-
| global_voices | `artykuł` | 1,047 | 0.02818% |
|
| 68 |
-
| global_voices | `parlament` | 366 | 0.00985% |
|
| 69 |
-
| global_voices | `rozporządzenie` | 26 | 0.00070% |
|
| 70 |
-
| global_voices | `w pobliżu` | 105 | 0.00283% |
|
| 71 |
-
| global_voices | `mieszkańców` | 508 | 0.01367% |
|
| 72 |
-
| global_voices | `Dz.U.` | 1 | 0.00003% |
|
| 73 |
-
| govpl | `w roku` | 3,372 | 0.00418% |
|
| 74 |
-
| govpl | `klasyfikacji` | 526 | 0.00065% |
|
| 75 |
-
| govpl | `ustawa` | 4,727 | 0.00586% |
|
| 76 |
-
| govpl | `artykuł` | 2,417 | 0.00300% |
|
| 77 |
-
| govpl | `parlament` | 3,967 | 0.00492% |
|
| 78 |
-
| govpl | `rozporządzenie` | 4,102 | 0.00509% |
|
| 79 |
-
| govpl | `w pobliżu` | 892 | 0.00111% |
|
| 80 |
-
| govpl | `mieszkańców` | 13,105 | 0.01625% |
|
| 81 |
-
| govpl | `Dz.U.` | 3,114 | 0.00386% |
|
| 82 |
-
| nkjp1m | `w roku` | 109 | 0.00419% |
|
| 83 |
-
| nkjp1m | `klasyfikacji` | 9 | 0.00035% |
|
| 84 |
-
| nkjp1m | `ustawa` | 79 | 0.00304% |
|
| 85 |
-
| nkjp1m | `artykuł` | 153 | 0.00588% |
|
| 86 |
-
| nkjp1m | `parlament` | 216 | 0.00830% |
|
| 87 |
-
| nkjp1m | `rozporządzenie` | 20 | 0.00077% |
|
| 88 |
-
| nkjp1m | `w pobliżu` | 77 | 0.00296% |
|
| 89 |
-
| nkjp1m | `mieszkańców` | 159 | 0.00611% |
|
| 90 |
-
| nkjp1m | `Dz.U.` | 2 | 0.00008% |
|
| 91 |
| parliamentary | `w roku` | 198,192 | 0.01203% |
|
| 92 |
| parliamentary | `klasyfikacji` | 12,637 | 0.00077% |
|
| 93 |
| parliamentary | `ustawa` | 459,179 | 0.02788% |
|
|
|
|
| 1 |
## Pattern frequency on corpus
|
| 2 |
|
| 3 |
+
- total tokens (tiktoken proxy): `6,281,911,234`
|
| 4 |
|
| 5 |
| pattern | count | share of all tokens |
|
| 6 |
|---|---:|---:|
|
| 7 |
+
| `w roku` | 435,541 | 0.0069% |
|
| 8 |
+
| `klasyfikacji` | 129,977 | 0.0021% |
|
| 9 |
+
| `ustawa` | 587,459 | 0.0094% |
|
| 10 |
+
| `artykuł` | 2,036,359 | 0.0324% |
|
| 11 |
+
| `parlament` | 1,201,641 | 0.0191% |
|
| 12 |
+
| `rozporządzenie` | 1,490,464 | 0.0237% |
|
| 13 |
+
| `w pobliżu` | 78,823 | 0.0013% |
|
| 14 |
+
| `mieszkańców` | 241,200 | 0.0038% |
|
| 15 |
+
| `Dz.U.` | 939,966 | 0.0150% |
|
| 16 |
|
| 17 |
| source | pattern | count | per-token share |
|
| 18 |
|---|---|---:|---:|
|
|
|
|
| 52 |
| eurlex | `w pobliżu` | 6,088 | 0.00026% |
|
| 53 |
| eurlex | `mieszkańców` | 9,441 | 0.00040% |
|
| 54 |
| eurlex | `Dz.U.` | 915,707 | 0.03851% |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
| parliamentary | `w roku` | 198,192 | 0.01203% |
|
| 56 |
| parliamentary | `klasyfikacji` | 12,637 | 0.00077% |
|
| 57 |
| parliamentary | `ustawa` | 459,179 | 0.02788% |
|
src/clean_hplt_v3.py
DELETED
|
@@ -1,202 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""clean_hplt_v3.py — filtr Polish HPLT v3 bin-10 (WDS=10) -> kanoniczna schema DynaWord.
|
| 3 |
-
|
| 4 |
-
Adaptacja src/filter_european_hplt.py maintainera do SUROWEGO formatu HPLT v3 (jsonl.zst,
|
| 5 |
-
pobrany z data.hplt-project.org). Te same progi jakosci; mapowanie pol v3 -> pol v1.
|
| 6 |
-
Output: kanoniczna 8-kolumnowa schema (id/text/source/added/created/token_count/license/author)
|
| 7 |
-
+ stats.json (format DynaWord + drop-reasons + register/MT/domain) + karta .md.
|
| 8 |
-
|
| 9 |
-
Pola v3: text, lang[list], prob[list], u(url), doc_scores[list], web-register{dict}, c(mime), id.
|
| 10 |
-
"""
|
| 11 |
-
from __future__ import annotations
|
| 12 |
-
import argparse, json, os, re, sys, time
|
| 13 |
-
from pathlib import Path
|
| 14 |
-
from urllib.parse import urlparse
|
| 15 |
-
import zstandard as zstd
|
| 16 |
-
import pyarrow as pa, pyarrow.parquet as pq
|
| 17 |
-
import tiktoken
|
| 18 |
-
|
| 19 |
-
ADDED = "2026-07-14"
|
| 20 |
-
SOURCE = "european_hplt_v3_pl"
|
| 21 |
-
LICENSE = "CC0-1.0"
|
| 22 |
-
|
| 23 |
-
BOILERPLATE_RE = re.compile(
|
| 24 |
-
r"(cookies?|privacy policy|terms of service|all rights reserved|"
|
| 25 |
-
r"polityka prywatno\u015bci|regulamin|wszelkie prawa zastrze\u017cone|"
|
| 26 |
-
r"zaloguj|rejestracja|newsletter)", re.I)
|
| 27 |
-
ADULT_SPAM_RE = re.compile(
|
| 28 |
-
r"(porn|sex|escort|casino|viagra|cialis|bukmacher|hazard|"
|
| 29 |
-
r"porno|seks|erotycz|kasyno|randki)", re.I)
|
| 30 |
-
LEGALISH_RE = re.compile(
|
| 31 |
-
r"\b(ustawa|rozporz\u0105dzenie|dz\.u\.|sejm|senat|parlament|eur-lex|"
|
| 32 |
-
r"trybuna\u0142|s\u0105d|wyrok|kodeks|komisja europejska)\b", re.I)
|
| 33 |
-
EXCLUDED_DOMAIN_PARTS = {".bip.", "bip.", "docplayer.pl", "mapa-kodow-pocztowych.pl",
|
| 34 |
-
"slideplayer.pl", "wikipedia.org", "wikisource.org", "wikibooks.org",
|
| 35 |
-
"wikiquote.org", "wikivoyage.org", "chomikuj.pl", "scribd.com",
|
| 36 |
-
"pdfcoffee.com", "dokumen.pub", "docer.pl", "ebookpoint", "wolnelektury.pl"}
|
| 37 |
-
# mojibake: polskie znaki UTF-8 zdekodowane jako CJK/inne (upstream HPLT extraction bug)
|
| 38 |
-
MOJIBAKE_RE = re.compile(r"[\u2e00-\u9fff\uff00-\uffef\ufffd]")
|
| 39 |
-
# naglowki serwisow wymiany plikow / PDF-ripow (ryzyko piractwa)
|
| 40 |
-
PDFHOST_RE = re.compile(r"(\d+\s*Pages?\s*[\u2022\u00b7]|Uploaded at|\d+\s*Words?\s*[\u2022\u00b7])", re.I)
|
| 41 |
-
MAX_CHARS = 120000 # ~40k tok: powyzej to ksiazki (copyright/OCR-risk), nie strony web
|
| 42 |
-
ALLOWED_REGISTERS = {"ID", "OP", "HI", "IN", "NA"}
|
| 43 |
-
|
| 44 |
-
CANON = pa.schema([("id", pa.string()), ("text", pa.string()), ("source", pa.string()),
|
| 45 |
-
("added", pa.string()), ("created", pa.string()),
|
| 46 |
-
("token_count", pa.int64()), ("license", pa.string()), ("author", pa.string())])
|
| 47 |
-
|
| 48 |
-
ENC = tiktoken.get_encoding("cl100k_base")
|
| 49 |
-
|
| 50 |
-
def domain(url):
|
| 51 |
-
if not url:
|
| 52 |
-
return ""
|
| 53 |
-
h = urlparse(url).netloc.lower()
|
| 54 |
-
return h[4:] if h.startswith("www.") else h
|
| 55 |
-
|
| 56 |
-
def top_register(reg):
|
| 57 |
-
if not isinstance(reg, dict) or not reg:
|
| 58 |
-
return "", 0.0
|
| 59 |
-
k, v = max(reg.items(), key=lambda kv: kv[1] or 0.0)
|
| 60 |
-
return str(k), float(v or 0.0)
|
| 61 |
-
|
| 62 |
-
def keep(o, min_chars, min_words, min_lang_prob, max_mt, dom_counts, max_per_domain):
|
| 63 |
-
lang = o.get("lang")
|
| 64 |
-
if not (isinstance(lang, list) and lang and lang[0] == "pol_Latn"):
|
| 65 |
-
return None, "language"
|
| 66 |
-
prob = o.get("prob")
|
| 67 |
-
lp = float(prob[0]) if isinstance(prob, list) and prob else 0.0
|
| 68 |
-
if lp < min_lang_prob:
|
| 69 |
-
return None, "lang_prob"
|
| 70 |
-
host = domain(o.get("u"))
|
| 71 |
-
if any(p in host for p in EXCLUDED_DOMAIN_PARTS):
|
| 72 |
-
return None, "domain"
|
| 73 |
-
if max_per_domain and dom_counts.get(host, 0) >= max_per_domain:
|
| 74 |
-
return None, "domain_cap"
|
| 75 |
-
reg = o.get("web-register") or {}
|
| 76 |
-
mt = float(reg.get("MT", 0.0)) if isinstance(reg, dict) else 0.0
|
| 77 |
-
if mt >= max_mt:
|
| 78 |
-
return None, "machine_translated"
|
| 79 |
-
rtop, _ = top_register(reg)
|
| 80 |
-
if ALLOWED_REGISTERS and rtop not in ALLOWED_REGISTERS:
|
| 81 |
-
return None, "register"
|
| 82 |
-
text = (o.get("text") or "").strip()
|
| 83 |
-
if len(text) < min_chars:
|
| 84 |
-
return None, "short"
|
| 85 |
-
if len(text.split()) < min_words:
|
| 86 |
-
return None, "few_words"
|
| 87 |
-
if len(text) > MAX_CHARS:
|
| 88 |
-
return None, "too_long"
|
| 89 |
-
if PDFHOST_RE.search(text[:200]):
|
| 90 |
-
return None, "filehost"
|
| 91 |
-
if len(MOJIBAKE_RE.findall(text[:3000])) >= 3:
|
| 92 |
-
return None, "mojibake"
|
| 93 |
-
s = text[:5000]
|
| 94 |
-
if len(BOILERPLATE_RE.findall(s)) >= 3:
|
| 95 |
-
return None, "boilerplate"
|
| 96 |
-
if ADULT_SPAM_RE.search(s):
|
| 97 |
-
return None, "adult_spam"
|
| 98 |
-
if LEGALISH_RE.search(s):
|
| 99 |
-
return None, "legalish"
|
| 100 |
-
return text, "kept"
|
| 101 |
-
|
| 102 |
-
def open_input(path):
|
| 103 |
-
"""Local file or URL (stream) -> binary readable context manager."""
|
| 104 |
-
if str(path).startswith("http"):
|
| 105 |
-
import urllib.request
|
| 106 |
-
return urllib.request.urlopen(urllib.request.Request(path, headers={"User-Agent": "slayer-dsbench/1.0"}), timeout=120)
|
| 107 |
-
return open(path, "rb")
|
| 108 |
-
|
| 109 |
-
def main():
|
| 110 |
-
ap = argparse.ArgumentParser()
|
| 111 |
-
ap.add_argument("--in", dest="inp", default=r"C:\ProjektyPublic\datasets\hplt_v3_pl\10_1.jsonl.zst")
|
| 112 |
-
ap.add_argument("--out-dir", default=r"C:\ProjektyPublic\datasets\hplt_v3_pl\data\european_hplt_v3_pl")
|
| 113 |
-
ap.add_argument("--source", default="european_hplt_v3_pl", help="wartosc kolumny source")
|
| 114 |
-
ap.add_argument("--out-name", default="", help="basename plikow (domyslnie = source); id prefix")
|
| 115 |
-
ap.add_argument("--bin-label", default="WDS=10")
|
| 116 |
-
ap.add_argument("--min-chars", type=int, default=400)
|
| 117 |
-
ap.add_argument("--min-words", type=int, default=80)
|
| 118 |
-
ap.add_argument("--min-lang-prob", type=float, default=0.80)
|
| 119 |
-
ap.add_argument("--max-mt-prob", type=float, default=0.20)
|
| 120 |
-
ap.add_argument("--max-per-domain", type=int, default=250)
|
| 121 |
-
ap.add_argument("--max-records", type=int, default=0)
|
| 122 |
-
a = ap.parse_args()
|
| 123 |
-
src = a.source; out = a.out_name or a.source
|
| 124 |
-
outd = Path(a.out_dir); outd.mkdir(parents=True, exist_ok=True)
|
| 125 |
-
t0 = time.time()
|
| 126 |
-
|
| 127 |
-
drops = {}; regs = {}; doms = {}; dom_counts = {}
|
| 128 |
-
ids, texts, tokens = [], [], []
|
| 129 |
-
read = kept = chars = toks = 0
|
| 130 |
-
mt_sum = 0.0
|
| 131 |
-
writer = pq.ParquetWriter(outd / f"{out}.parquet", CANON, compression="zstd")
|
| 132 |
-
|
| 133 |
-
def flush():
|
| 134 |
-
nonlocal ids, texts, tokens
|
| 135 |
-
if not ids:
|
| 136 |
-
return
|
| 137 |
-
n = len(ids)
|
| 138 |
-
writer.write_table(pa.table({
|
| 139 |
-
"id": ids, "text": texts, "source": [src]*n, "added": [ADDED]*n,
|
| 140 |
-
"created": [""]*n, "token_count": tokens, "license": [LICENSE]*n, "author": [""]*n},
|
| 141 |
-
schema=CANON))
|
| 142 |
-
ids, texts, tokens = [], [], []
|
| 143 |
-
|
| 144 |
-
with open_input(a.inp) as fh:
|
| 145 |
-
reader = zstd.ZstdDecompressor().stream_reader(fh)
|
| 146 |
-
buf = b""
|
| 147 |
-
while True:
|
| 148 |
-
chunk = reader.read(1 << 20)
|
| 149 |
-
if not chunk:
|
| 150 |
-
break
|
| 151 |
-
buf += chunk
|
| 152 |
-
while b"\n" in buf:
|
| 153 |
-
line, buf = buf.split(b"\n", 1)
|
| 154 |
-
if not line.strip():
|
| 155 |
-
continue
|
| 156 |
-
try:
|
| 157 |
-
o = json.loads(line)
|
| 158 |
-
except Exception:
|
| 159 |
-
continue
|
| 160 |
-
read += 1
|
| 161 |
-
text, reason = keep(o, a.min_chars, a.min_words, a.min_lang_prob,
|
| 162 |
-
a.max_mt_prob, dom_counts, a.max_per_domain)
|
| 163 |
-
if text is None:
|
| 164 |
-
drops[reason] = drops.get(reason, 0) + 1
|
| 165 |
-
continue
|
| 166 |
-
host = domain(o.get("u")); dom_counts[host] = dom_counts.get(host, 0) + 1
|
| 167 |
-
if len(doms) < 500:
|
| 168 |
-
doms[host] = doms.get(host, 0) + 1
|
| 169 |
-
reg = o.get("web-register") or {}
|
| 170 |
-
rtop, _ = top_register(reg); regs[rtop] = regs.get(rtop, 0) + 1
|
| 171 |
-
mt_sum += float(reg.get("MT", 0.0)) if isinstance(reg, dict) else 0.0
|
| 172 |
-
tk = len(ENC.encode(text, disallowed_special=()))
|
| 173 |
-
ids.append(f"{out}_{kept}"); texts.append(text); tokens.append(tk)
|
| 174 |
-
kept += 1; chars += len(text); toks += tk
|
| 175 |
-
if len(ids) >= 1000:
|
| 176 |
-
flush()
|
| 177 |
-
if read % 20000 == 0:
|
| 178 |
-
print(f" read={read:,} kept={kept:,} tok={toks:,} ({time.time()-t0:.0f}s)", flush=True)
|
| 179 |
-
if a.max_records and kept >= a.max_records:
|
| 180 |
-
buf = b""; break
|
| 181 |
-
else:
|
| 182 |
-
continue
|
| 183 |
-
break
|
| 184 |
-
flush(); writer.close()
|
| 185 |
-
|
| 186 |
-
stats = {"read": read, "kept": kept, "drop_short": drops.get("short", 0),
|
| 187 |
-
"drop_lang": drops.get("language", 0) + drops.get("lang_prob", 0),
|
| 188 |
-
"drop_dup": 0, "drop_ocr": 0, "chars": chars, "tokens": toks,
|
| 189 |
-
"licenses": {LICENSE: kept}, "authors_with_value": 0, "license": LICENSE,
|
| 190 |
-
"stats_recomputed_from_parquet": True,
|
| 191 |
-
"drop_detail": drops, "registers": regs,
|
| 192 |
-
"mt_prob_mean_kept": round(mt_sum / max(1, kept), 3),
|
| 193 |
-
"domains_top_sample": dict(sorted(doms.items(), key=lambda x: -x[1])[:30]),
|
| 194 |
-
"secs": round(time.time()-t0, 1),
|
| 195 |
-
"source_repo": f"HPLT/HPLT3.0 pol_Latn {a.bin_label} via {a.inp}"}
|
| 196 |
-
(outd / f"{out}.stats.json").write_text(json.dumps(stats, ensure_ascii=False, indent=2)+"\n", encoding="utf-8")
|
| 197 |
-
print("=== STATS ===")
|
| 198 |
-
print(json.dumps({k: v for k, v in stats.items() if k not in ("domains_top_sample",)}, ensure_ascii=False, indent=2))
|
| 199 |
-
print(f"parquet={outd/(out+'.parquet')} ({os.path.getsize(outd/(out+'.parquet')):,}B)")
|
| 200 |
-
|
| 201 |
-
if __name__ == "__main__":
|
| 202 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/discover_govpl.py
DELETED
|
@@ -1,194 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Discover gov.pl subsites + their news-section paths and write a committed
|
| 3 |
-
manifest (govpl_subsites.json) that fetch_govpl.py consumes.
|
| 4 |
-
|
| 5 |
-
gov.pl offers no sitemap or API for enumeration, and news-section slugs are
|
| 6 |
-
non-uniform: ministries use `/aktualnosci`, but voivodeship/agency subsites use
|
| 7 |
-
`/wiadomosci2`, `/aktualnosci10`, `/wszystkie-aktualnosci`, etc. (gov.pl appends
|
| 8 |
-
numeric suffixes to disambiguate repeated slugs). So discovery is a separate,
|
| 9 |
-
auditable step — freeze the JS-rendered subsite list, then probe each landing
|
| 10 |
-
page for its deepest-paginating news section. fetch_govpl.py then reads the
|
| 11 |
-
manifest with plain stdlib (no browser), keeping the fetch reproducible.
|
| 12 |
-
|
| 13 |
-
SEED_SLUGS was captured from the rendered catalog at
|
| 14 |
-
https://www.gov.pl/web/gov/katalog-jednostek on 2026-07-18 (a client-side list,
|
| 15 |
-
NOT fetchable over plain HTTP). To refresh, open that page in a browser console
|
| 16 |
-
and run:
|
| 17 |
-
[...new Set([...document.querySelectorAll('a[href*="/web/"]')]
|
| 18 |
-
.map(a => (a.getAttribute('href').match(/\\/web\\/([a-z0-9-]+)/i)||[])[1])
|
| 19 |
-
.filter(Boolean))].filter(s => s !== 'gov')
|
| 20 |
-
then paste the array into SEED_SLUGS below.
|
| 21 |
-
|
| 22 |
-
All gov.pl text is CC-BY-SA 4.0 (site footer), government-authored/hosted.
|
| 23 |
-
|
| 24 |
-
Usage:
|
| 25 |
-
python3 src/discover_govpl.py --out src/govpl_subsites.json
|
| 26 |
-
"""
|
| 27 |
-
from __future__ import annotations
|
| 28 |
-
import argparse, http.client, json, re, time
|
| 29 |
-
from datetime import date
|
| 30 |
-
from html import unescape
|
| 31 |
-
from urllib.request import urlopen, Request
|
| 32 |
-
from urllib.error import URLError, HTTPError
|
| 33 |
-
|
| 34 |
-
BASE = "https://www.gov.pl"
|
| 35 |
-
UA = {"User-Agent": "polish-dynaword/0.1 (+research; openly-licensed corpus)",
|
| 36 |
-
"Accept": "text/html"}
|
| 37 |
-
|
| 38 |
-
# Frozen JS-rendered catalog (see module docstring for refresh recipe).
|
| 39 |
-
SEED_SLUGS = [
|
| 40 |
-
"premier", "aktywa-panstwowe", "cyfryzacja", "edukacja", "energia",
|
| 41 |
-
"finanse", "fundusze-regiony", "infrastruktura", "klimat", "kultura",
|
| 42 |
-
"nauka", "obrona-narodowa", "rodzina", "rolnictwo", "rozwoj-technologia",
|
| 43 |
-
"sport", "sprawiedliwosc", "mswia", "dyplomacja", "zdrowie", "zermswia",
|
| 44 |
-
"arimr", "chemikalia", "rpp", "gdos", "gif", "piorin", "gios", "gis",
|
| 45 |
-
"gitd", "gugik", "krus", "paa", "rcb", "udsc", "prokuratoria", "urpl",
|
| 46 |
-
"uzp", "uw-kujawsko-pomorski", "uw-lubelski", "uw-lubuski", "uw-lodzki",
|
| 47 |
-
"uw-mazowiecki", "uw-opolski", "uw-podkarpacki", "uw-podlaski",
|
| 48 |
-
"uw-warminsko-mazurski", "uw-zachodniopomorski", "gddkia-bialystok",
|
| 49 |
-
"gddkia-bydgoszcz", "gddkia-gdansk", "gddkia-katowice", "gddkia-kielce",
|
| 50 |
-
"gddkia-krakow", "gddkia-lublin", "gddkia-lodz", "gddkia-olsztyn",
|
| 51 |
-
"gddkia-opole", "gddkia-poznan", "gddkia-rzeszow", "gddkia-szczecin",
|
| 52 |
-
"gddkia-warszawa", "gddkia-wroclaw", "gddkia-zielona-gora", "wsse-bialystok",
|
| 53 |
-
"wsse-bydgoszcz", "wsse-gdansk", "wsse-gorzowwlkp", "wsse-katowice",
|
| 54 |
-
"wsse-kielce", "wsse-krakow", "wsse-lublin", "wsse-lodz", "wsse-olsztyn",
|
| 55 |
-
"wsse-opole", "wsse-poznan", "wsse-rzeszow", "wsse-szczecin",
|
| 56 |
-
"wsse-warszawa", "wsse-wroclaw", "prokuratura-krajowa", "po-bialystok",
|
| 57 |
-
"po-bielsko-biala", "po-bydgoszcz", "po-elblag", "po-gdansk", "po-gliwice",
|
| 58 |
-
"po-gorzow-wielkopolski", "po-katowice", "po-kielce", "po-krakow",
|
| 59 |
-
"po-legnica", "po-lublin", "po-lodz", "po-lomza", "po-nowy-sacz",
|
| 60 |
-
"po-olsztyn", "po-opole", "po-ostroleka", "po-ostrow-wielkopolski",
|
| 61 |
-
"po-piotrkow-trybunalski", "po-plock", "po-poznan", "po-rzeszow",
|
| 62 |
-
"po-siedlce", "po-sieradz", "po-slupsk", "po-sosnowiec", "po-swidnica",
|
| 63 |
-
"po-tarnobrzeg", "po-tarnow", "po-torun", "po-warszawa", "po-warszawa-praga",
|
| 64 |
-
"po-wloclawek", "po-wroclaw", "po-zielona-gora", "pr-gdansk", "pr-katowice",
|
| 65 |
-
"pr-krakow", "pr-lublin", "pr-lodz", "pr-poznan", "pr-rzeszow",
|
| 66 |
-
"pr-szczecin", "pr-warszawa", "pr-wroclaw", "kgpsp", "kwpsp-gdansk",
|
| 67 |
-
"kwpsp-opole", "kwpsp-poznan", "cskmswia", "spzoz-mswia-katowice",
|
| 68 |
-
"spzoz-mswia-lublin", "spzoz-mswia-opole", "spzoz-mswia-szczecin",
|
| 69 |
-
"spzoz-mswia-zielona-gora", "spzoz-mswia-glucholazy", "krrit", "kowr",
|
| 70 |
-
"kzn", "nck", "wody-polskie",
|
| 71 |
-
]
|
| 72 |
-
|
| 73 |
-
# A landing-page sub-page counts as a news section if its slug starts with one
|
| 74 |
-
# of these (gov.pl appends -suffix / digits, e.g. aktualnosci10, wiadomosci2).
|
| 75 |
-
_NEWS_PREFIX = re.compile(r"^(wszystkie-aktualnosci|aktualnosci|wiadomosci|"
|
| 76 |
-
r"serwis-prasowy|komunikaty)", re.I)
|
| 77 |
-
# On a listing page each article preview is an <span class="date"> ... </span>
|
| 78 |
-
# (inside a class="event" block) followed by <div class="title"><a href=...>.
|
| 79 |
-
# Binding the two in one match keeps date/title/url aligned per article.
|
| 80 |
-
_ARTICLE = re.compile(
|
| 81 |
-
r'<span class="date">\s*([\d.]+)\s*</span>.*?'
|
| 82 |
-
r'<div class="title">\s*<a href="([^"]+)"[^>]*>\s*(.*?)\s*</a>',
|
| 83 |
-
re.I | re.S)
|
| 84 |
-
_PAGE = re.compile(r'[?&]page=(\d+)')
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
def http_get_url(url: str, tries: int = 4) -> tuple[str | None, str]:
|
| 88 |
-
"""GET, returning (text, final_url_after_redirects). text is None on 404 or
|
| 89 |
-
exhausted retries. Needed because gov.pl news aliases (e.g. /aktualnosci)
|
| 90 |
-
302-redirect to a canonical feed (/wydarzenia) and DROP the ?page= param —
|
| 91 |
-
so pagination must run against the resolved canonical URL, not the alias."""
|
| 92 |
-
for i in range(tries):
|
| 93 |
-
try:
|
| 94 |
-
with urlopen(Request(url, headers=UA), timeout=60) as r:
|
| 95 |
-
return r.read().decode("utf-8", "replace"), r.geturl()
|
| 96 |
-
# OSError covers URLError/TimeoutError/socket/ssl/ConnectionReset;
|
| 97 |
-
# HTTPException covers IncompleteRead (truncated body) — all transient, retry.
|
| 98 |
-
except (HTTPError, OSError, http.client.HTTPException) as e:
|
| 99 |
-
if isinstance(e, HTTPError) and e.code == 404:
|
| 100 |
-
return None, url
|
| 101 |
-
time.sleep(1.5 * (i + 1))
|
| 102 |
-
return None, url
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
def http_get(url: str, tries: int = 4) -> str | None:
|
| 106 |
-
"""GET text, retrying transient errors; None on 404 or exhausted retries."""
|
| 107 |
-
return http_get_url(url, tries)[0]
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
def listing_articles(html: str, slug: str) -> list[dict]:
|
| 111 |
-
"""{url,title,date} for real articles on a listing page of subsite `slug`."""
|
| 112 |
-
out = []
|
| 113 |
-
prefix = f"/web/{slug}/"
|
| 114 |
-
for date_str, href, title in _ARTICLE.findall(html):
|
| 115 |
-
if href.startswith(prefix):
|
| 116 |
-
out.append({
|
| 117 |
-
"url": href,
|
| 118 |
-
"title": unescape(re.sub(r"\s+", " ", title)).strip(),
|
| 119 |
-
"date": date_str,
|
| 120 |
-
})
|
| 121 |
-
return out
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
def max_page(html: str) -> int:
|
| 125 |
-
nums = [int(n) for n in _PAGE.findall(html)]
|
| 126 |
-
return max(nums) if nums else 1
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
def news_candidates(landing_html: str, slug: str) -> list[str]:
|
| 130 |
-
"""Distinct same-subsite sub-slugs that look like a news section."""
|
| 131 |
-
seen = {}
|
| 132 |
-
for sub in re.findall(rf'href="/web/{re.escape(slug)}/([a-z0-9-]+)"', landing_html):
|
| 133 |
-
if _NEWS_PREFIX.match(sub):
|
| 134 |
-
seen[sub] = True
|
| 135 |
-
return list(seen)
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
def probe_subsite(slug: str) -> dict | None:
|
| 139 |
-
"""Resolve a subsite's best news section -> {slug, news_path, pages} or None."""
|
| 140 |
-
landing = http_get(f"{BASE}/web/{slug}")
|
| 141 |
-
if not landing:
|
| 142 |
-
return None
|
| 143 |
-
best = None
|
| 144 |
-
for sub in news_candidates(landing, slug):
|
| 145 |
-
html = http_get(f"{BASE}/web/{slug}/{sub}")
|
| 146 |
-
if not html:
|
| 147 |
-
continue
|
| 148 |
-
n_art = len(listing_articles(html, slug))
|
| 149 |
-
if n_art == 0:
|
| 150 |
-
continue
|
| 151 |
-
pages = max_page(html)
|
| 152 |
-
# Prefer the deepest-paginating feed; tie-break the shorter (more general) slug.
|
| 153 |
-
key = (pages, -len(sub))
|
| 154 |
-
if best is None or key > best[0]:
|
| 155 |
-
best = (key, sub, pages)
|
| 156 |
-
time.sleep(0.2)
|
| 157 |
-
if best is None:
|
| 158 |
-
return None
|
| 159 |
-
return {"slug": slug, "news_path": best[1], "pages": best[2]}
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
def main():
|
| 163 |
-
ap = argparse.ArgumentParser()
|
| 164 |
-
ap.add_argument("--out", default="src/govpl_subsites.json")
|
| 165 |
-
ap.add_argument("--slugs", nargs="*", help="override SEED_SLUGS (for testing)")
|
| 166 |
-
args = ap.parse_args()
|
| 167 |
-
|
| 168 |
-
slugs = args.slugs or SEED_SLUGS
|
| 169 |
-
manifest, skipped = [], []
|
| 170 |
-
for i, slug in enumerate(slugs, 1):
|
| 171 |
-
rec = probe_subsite(slug)
|
| 172 |
-
if rec:
|
| 173 |
-
manifest.append(rec)
|
| 174 |
-
print(f"[{i}/{len(slugs)}] {slug} -> {rec['news_path']} ({rec['pages']}p)", flush=True)
|
| 175 |
-
else:
|
| 176 |
-
skipped.append(slug)
|
| 177 |
-
print(f"[{i}/{len(slugs)}] {slug} -> NO NEWS SECTION (skipped)", flush=True)
|
| 178 |
-
|
| 179 |
-
total_pages = sum(r["pages"] for r in manifest)
|
| 180 |
-
out = {
|
| 181 |
-
"generated": date.today().isoformat(),
|
| 182 |
-
"source": f"{BASE}/web/gov/katalog-jednostek",
|
| 183 |
-
"subsites": manifest,
|
| 184 |
-
"skipped": skipped, # logged, not silently dropped
|
| 185 |
-
"total_pages": total_pages,
|
| 186 |
-
}
|
| 187 |
-
with open(args.out, "w", encoding="utf-8") as f:
|
| 188 |
-
json.dump(out, f, ensure_ascii=False, indent=2)
|
| 189 |
-
print(f"\nwrote {args.out}: {len(manifest)} subsites, {total_pages} listing pages, "
|
| 190 |
-
f"{len(skipped)} skipped")
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
if __name__ == "__main__":
|
| 194 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/fetch_govpl.py
DELETED
|
@@ -1,183 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Fetch gov.pl ministry/agency press releases into a SpeakLeash-style
|
| 3 |
-
.jsonl.zst, so build_dynaword.py consumes it unchanged (native source, not via
|
| 4 |
-
SpeakLeash). All textual content on gov.pl is published under CC-BY-SA 4.0 (site
|
| 5 |
-
footer: "Treści tekstowe publikowane w serwisie … CC BY-SA 4.0"), authored and
|
| 6 |
-
hosted by the Polish government — so the redistributor genuinely holds the right
|
| 7 |
-
to license it.
|
| 8 |
-
|
| 9 |
-
Enumeration is driven by the committed manifest src/govpl_subsites.json (built
|
| 10 |
-
by discover_govpl.py): {slug, news_path, pages} per subsite. This keeps the
|
| 11 |
-
fetch pure-stdlib and reproducible — no headless browser at fetch time.
|
| 12 |
-
|
| 13 |
-
Resumable: appends to <out>/govpl.jsonl, skips article URLs already present,
|
| 14 |
-
then compresses to govpl.jsonl.zst at the end of a run. Per-request failures are
|
| 15 |
-
retried then logged and skipped (never silently truncating the crawl).
|
| 16 |
-
|
| 17 |
-
Usage:
|
| 18 |
-
python3 src/discover_govpl.py --out src/govpl_subsites.json # once / to refresh
|
| 19 |
-
python3 src/fetch_govpl.py --out ~/speakleash --manifest src/govpl_subsites.json
|
| 20 |
-
"""
|
| 21 |
-
from __future__ import annotations
|
| 22 |
-
import argparse, json, re, subprocess, sys, threading, time
|
| 23 |
-
from concurrent.futures import ThreadPoolExecutor
|
| 24 |
-
from html import unescape
|
| 25 |
-
from pathlib import Path
|
| 26 |
-
|
| 27 |
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 28 |
-
from discover_govpl import BASE, http_get, http_get_url, listing_articles # shared, DRY
|
| 29 |
-
|
| 30 |
-
KEY = "govpl" # build_dynaword reads <KEY>.jsonl.zst
|
| 31 |
-
MIN_CHARS = 200 # same floor as build_dynaword; skip stubs early
|
| 32 |
-
|
| 33 |
-
_SCRIPT = re.compile(r"(?is)<(script|style)[^>]*>.*?</\1>")
|
| 34 |
-
_BLOCK_END = re.compile(r"(?i)</(p|div|h[1-6]|li|tr|table|ul|ol|blockquote)\s*>|<br\s*/?>")
|
| 35 |
-
_TAG = re.compile(r"<[^>]+>")
|
| 36 |
-
# Body ends where the editor-content region gives way to gallery/attachments/tags.
|
| 37 |
-
_END_MARKER = re.compile(
|
| 38 |
-
r'<[^>]+class="[^"]*(?:attachments|art-tags|tags|social|share|gallery|files)[^"]*"'
|
| 39 |
-
r'|data-group="gallery"|</article', re.I)
|
| 40 |
-
_EDITOR = re.compile(r'<div class="editor-content"[^>]*>', re.I)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def html_to_text(html: str) -> str:
|
| 44 |
-
html = _SCRIPT.sub("", html)
|
| 45 |
-
html = _BLOCK_END.sub("\n", html)
|
| 46 |
-
html = _TAG.sub("", html)
|
| 47 |
-
text = unescape(html)
|
| 48 |
-
text = re.sub(r"[ \t]+", " ", text)
|
| 49 |
-
text = re.sub(r" *\n *", "\n", text)
|
| 50 |
-
text = re.sub(r"\n{3,}", "\n\n", text)
|
| 51 |
-
return text.strip()
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
def article_body(html: str) -> str:
|
| 55 |
-
"""Text of the article body. gov.pl pages carry the class twice; pick the
|
| 56 |
-
richest editor-content region and cut at the trailing gallery/attachments.
|
| 57 |
-
ponytail: regex slice, not a DOM parse — end-markers drop gallery captions;
|
| 58 |
-
upgrade to an HTML parser only if boilerplate leakage shows up in stats."""
|
| 59 |
-
best = ""
|
| 60 |
-
for m in _EDITOR.finditer(html):
|
| 61 |
-
start = m.end()
|
| 62 |
-
end = _END_MARKER.search(html, start)
|
| 63 |
-
chunk = html[start:end.start()] if end else html[start:]
|
| 64 |
-
text = html_to_text(chunk)
|
| 65 |
-
if len(text) > len(best):
|
| 66 |
-
best = text
|
| 67 |
-
return best
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
def normalize(art: dict, html: str, slug: str) -> dict | None:
|
| 71 |
-
"""Listing entry {url,title,date} + article HTML -> record, or None if thin."""
|
| 72 |
-
body = article_body(html)
|
| 73 |
-
if len(body) < MIN_CHARS:
|
| 74 |
-
return None
|
| 75 |
-
title = art.get("title") or ""
|
| 76 |
-
text = f"{title}\n\n{body}" if title else body
|
| 77 |
-
return {
|
| 78 |
-
"text": text,
|
| 79 |
-
"meta": {
|
| 80 |
-
"url": BASE + art["url"],
|
| 81 |
-
"subsite": slug,
|
| 82 |
-
"title": title,
|
| 83 |
-
"date": art.get("date") or "",
|
| 84 |
-
},
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
def iter_listing(slug: str, news_path: str, pages: int):
|
| 89 |
-
"""Yield {url,title,date} article entries across a subsite's listing pages.
|
| 90 |
-
|
| 91 |
-
Resolves the news section's canonical URL first: gov.pl aliases (e.g.
|
| 92 |
-
/aktualnosci) redirect to a canonical feed (/wydarzenia) and drop ?page=,
|
| 93 |
-
so paginating the alias returns page 1 forever. We paginate the resolved
|
| 94 |
-
base with ?page=N&size=10 (the exact form gov.pl's own pager emits)."""
|
| 95 |
-
first_html, canonical = http_get_url(f"{BASE}/web/{slug}/{news_path}")
|
| 96 |
-
if first_html is None:
|
| 97 |
-
print(f" WARN news section failed, skipped: {slug}/{news_path}",
|
| 98 |
-
file=sys.stderr, flush=True)
|
| 99 |
-
return
|
| 100 |
-
base = canonical.split("?", 1)[0] # canonical path, no query
|
| 101 |
-
for page in range(1, pages + 1):
|
| 102 |
-
html = http_get(f"{base}?page={page}&size=10")
|
| 103 |
-
if html is None:
|
| 104 |
-
print(f" WARN listing failed, skipped: {base}?page={page}",
|
| 105 |
-
file=sys.stderr, flush=True)
|
| 106 |
-
continue
|
| 107 |
-
yield from listing_articles(html, slug)
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
def fetch_subsite(si: int, n_sub: int, sub: dict, done: set, lock: threading.Lock,
|
| 111 |
-
fo, st: dict) -> None:
|
| 112 |
-
"""Crawl one subsite. Runs in a worker thread: the slow article GET stays
|
| 113 |
-
outside the lock so workers actually overlap; only shared state (done set,
|
| 114 |
-
file, counters) is lock-guarded."""
|
| 115 |
-
slug, news_path, pages = sub["slug"], sub["news_path"], sub["pages"]
|
| 116 |
-
print(f"[{si}/{n_sub}] {slug}/{news_path} ({pages}p)", flush=True)
|
| 117 |
-
try:
|
| 118 |
-
for art in iter_listing(slug, news_path, pages):
|
| 119 |
-
url = BASE + art["url"]
|
| 120 |
-
with lock:
|
| 121 |
-
if url in done:
|
| 122 |
-
continue
|
| 123 |
-
done.add(url)
|
| 124 |
-
st["seen"] += 1
|
| 125 |
-
seen = st["seen"]
|
| 126 |
-
html = http_get(url) # network — deliberately outside the lock
|
| 127 |
-
if html is None:
|
| 128 |
-
with lock: st["skipped"] += 1
|
| 129 |
-
print(f" WARN article failed, skipped: {url}", file=sys.stderr, flush=True)
|
| 130 |
-
continue
|
| 131 |
-
rec = normalize(art, html, slug)
|
| 132 |
-
line = json.dumps(rec, ensure_ascii=False) + "\n" if rec else None
|
| 133 |
-
with lock:
|
| 134 |
-
if line:
|
| 135 |
-
fo.write(line); st["kept"] += 1
|
| 136 |
-
if seen % 500 == 0:
|
| 137 |
-
print(f" seen {st['seen']:,} | kept {st['kept']:,} | skipped {st['skipped']:,} "
|
| 138 |
-
f"| {st['seen']/(time.time()-st['t0']):.1f}/s", flush=True)
|
| 139 |
-
except Exception as e:
|
| 140 |
-
# A subsite that dies must not abort the whole crawl (ex.map would
|
| 141 |
-
# propagate and kill every worker). Log, skip the rest, keep going.
|
| 142 |
-
print(f" WARN subsite crashed, skipped rest: {slug}: {e!r}",
|
| 143 |
-
file=sys.stderr, flush=True)
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
def main():
|
| 147 |
-
ap = argparse.ArgumentParser()
|
| 148 |
-
ap.add_argument("--out", default="~/speakleash")
|
| 149 |
-
ap.add_argument("--manifest", default="src/govpl_subsites.json")
|
| 150 |
-
ap.add_argument("--workers", type=int, default=2,
|
| 151 |
-
help="concurrent subsite crawlers (be polite to gov.pl)")
|
| 152 |
-
args = ap.parse_args()
|
| 153 |
-
|
| 154 |
-
manifest = json.loads(Path(args.manifest).read_text(encoding="utf-8"))
|
| 155 |
-
subsites = manifest["subsites"]
|
| 156 |
-
|
| 157 |
-
out_dir = Path(args.out).expanduser(); out_dir.mkdir(parents=True, exist_ok=True)
|
| 158 |
-
jsonl = out_dir / f"{KEY}.jsonl"
|
| 159 |
-
done = set()
|
| 160 |
-
if jsonl.exists():
|
| 161 |
-
for ln in jsonl.open(encoding="utf-8"):
|
| 162 |
-
try: done.add(json.loads(ln)["meta"]["url"])
|
| 163 |
-
except Exception: pass
|
| 164 |
-
print(f"resume: {len(done):,} already fetched")
|
| 165 |
-
|
| 166 |
-
st = {"seen": 0, "kept": 0, "skipped": 0, "t0": time.time()}
|
| 167 |
-
lock = threading.Lock()
|
| 168 |
-
with jsonl.open("a", encoding="utf-8") as fo:
|
| 169 |
-
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
| 170 |
-
# list() drains the map so any worker exception surfaces here.
|
| 171 |
-
list(ex.map(
|
| 172 |
-
lambda item: fetch_subsite(item[0], len(subsites), item[1],
|
| 173 |
-
done, lock, fo, st),
|
| 174 |
-
enumerate(subsites, 1)))
|
| 175 |
-
|
| 176 |
-
print(f"fetched {st['kept']:,} articles ({st['skipped']:,} skipped); compressing...", flush=True)
|
| 177 |
-
subprocess.run(["zstd", "-19", "-f", "--rm", str(jsonl), "-o",
|
| 178 |
-
str(out_dir / f"{KEY}.jsonl.zst")], check=True)
|
| 179 |
-
print(f"wrote {out_dir / (KEY + '.jsonl.zst')} in {round(time.time()-st['t0'])}s")
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
if __name__ == "__main__":
|
| 183 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/fetch_njkp.py
DELETED
|
@@ -1,342 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Fetch the NKJP 1-million-word subcorpus (Podkorpus Milionowy NKJP 1.2) and
|
| 3 |
-
build a DynaWord-style parquet shard from the TEI source.
|
| 4 |
-
|
| 5 |
-
Downloads + extracts the IPI PAN tarball under /tmp, then walks every sample
|
| 6 |
-
folder and emits one parquet row per <div> in text.xml. Each <div> is a single
|
| 7 |
-
contiguous excerpt from one source document (its <ab> paragraphs joined by
|
| 8 |
-
newlines, ellipses stripped); across <div>s the excerpts are unrelated, so they
|
| 9 |
-
are kept as separate rows rather than merged.
|
| 10 |
-
|
| 11 |
-
The same minimal gates as src/build_dynaword.py are applied per passage (drop
|
| 12 |
-
< 200 chars, drop non-Polish by diacritic ratio, exact sha1 dedup; the OCR gate
|
| 13 |
-
is inapplicable - NKJP1M is not OCR), so the shard matches what the DynaWord
|
| 14 |
-
build would keep. Per-row `created` is the sample's TEI publication date
|
| 15 |
-
(<date type="published">) when the header records one. Token counts use
|
| 16 |
-
tiktoken cl100k (encode_ordinary), same as build_dynaword.py, and the emitted
|
| 17 |
-
stats are recomputed from the written parquet.
|
| 18 |
-
|
| 19 |
-
Text extraction + the stats report are adapted from tmp/count_tokens.py.
|
| 20 |
-
|
| 21 |
-
Usage:
|
| 22 |
-
python3 src/fetch_njkp.py --out . --workers 8
|
| 23 |
-
"""
|
| 24 |
-
from __future__ import annotations
|
| 25 |
-
|
| 26 |
-
import argparse
|
| 27 |
-
import hashlib
|
| 28 |
-
import json
|
| 29 |
-
import re
|
| 30 |
-
import ssl
|
| 31 |
-
import sys
|
| 32 |
-
import tarfile
|
| 33 |
-
import time
|
| 34 |
-
from concurrent.futures import ProcessPoolExecutor
|
| 35 |
-
from datetime import date
|
| 36 |
-
from pathlib import Path
|
| 37 |
-
from urllib.error import URLError
|
| 38 |
-
from urllib.request import urlopen, Request
|
| 39 |
-
from xml.etree import ElementTree as ET
|
| 40 |
-
|
| 41 |
-
import pyarrow as pa
|
| 42 |
-
import pyarrow.parquet as pq
|
| 43 |
-
import tiktoken
|
| 44 |
-
|
| 45 |
-
URL = ("https://clip.ipipan.waw.pl/NationalCorpusOfPolish"
|
| 46 |
-
"?action=AttachFile&do=get&target=NKJP-PodkorpusMilionowy-1.2.tar.gz")
|
| 47 |
-
ROOT_NAME = "NKJP-PodkorpusMilionowy-1.2"
|
| 48 |
-
UA = {"User-Agent": "polish-dynaword/0.1 (+research; openly-licensed corpus)"}
|
| 49 |
-
|
| 50 |
-
KEY = "nkjp1m" # source name / parquet stem, consumed by build_dynaword
|
| 51 |
-
LICENSE = "CC-BY" # stated on the NKJP download page (clip.ipipan.waw.pl)
|
| 52 |
-
AUTHOR = "NKJP" # compiled/distributed by the NKJP Consortium (IPI PAN)
|
| 53 |
-
|
| 54 |
-
# Gates - identical thresholds to src/build_dynaword.py so the shard matches
|
| 55 |
-
# what the DynaWord build itself would keep.
|
| 56 |
-
MIN_CHARS = 200
|
| 57 |
-
MIN_POLISH_RATIO = 0.005
|
| 58 |
-
POLISH_RE = re.compile(r"[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]")
|
| 59 |
-
ALPHA_RE = re.compile(r"[^\W\d_]", re.UNICODE)
|
| 60 |
-
|
| 61 |
-
NS = "{http://www.tei-c.org/ns/1.0}"
|
| 62 |
-
DIV_TAG, AB_TAG, DATE_TAG = f"{NS}div", f"{NS}ab", f"{NS}date"
|
| 63 |
-
_ELLIPSIS = re.compile(r"…|\.{3,}") # ellipsis markers stripped from text
|
| 64 |
-
|
| 65 |
-
# Same schema as src/build_dynaword.py so the shard drops straight into DynaWord.
|
| 66 |
-
SCHEMA = pa.schema([
|
| 67 |
-
("id", pa.string()), ("text", pa.string()), ("source", pa.string()),
|
| 68 |
-
("added", pa.string()), ("created", pa.string()), ("token_count", pa.int64()),
|
| 69 |
-
("license", pa.string()), ("author", pa.string()),
|
| 70 |
-
])
|
| 71 |
-
|
| 72 |
-
_ENC = None # per-worker tiktoken encoder
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
def download(url: str, dst: Path) -> Path:
|
| 76 |
-
if dst.exists() and dst.stat().st_size:
|
| 77 |
-
print(f" cached {dst}", flush=True)
|
| 78 |
-
return dst
|
| 79 |
-
print(f" downloading {url}", flush=True)
|
| 80 |
-
dst.parent.mkdir(parents=True, exist_ok=True)
|
| 81 |
-
|
| 82 |
-
def stream(ctx):
|
| 83 |
-
with urlopen(Request(url, headers=UA), timeout=120, context=ctx) as r, \
|
| 84 |
-
dst.open("wb") as f:
|
| 85 |
-
while chunk := r.read(1 << 20):
|
| 86 |
-
f.write(chunk)
|
| 87 |
-
|
| 88 |
-
try:
|
| 89 |
-
stream(None)
|
| 90 |
-
except URLError as e:
|
| 91 |
-
# clip.ipipan.waw.pl ships an incomplete cert chain Python rejects (curl
|
| 92 |
-
# accepts it); retry unverified for this known source only.
|
| 93 |
-
if not isinstance(e.reason, ssl.SSLError):
|
| 94 |
-
raise
|
| 95 |
-
print(" ! TLS verify failed; retrying unverified", file=sys.stderr, flush=True)
|
| 96 |
-
stream(ssl._create_unverified_context())
|
| 97 |
-
return dst
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
def extract_archive(archive: Path, dest: Path) -> Path:
|
| 101 |
-
# The tarball has no top folder, so extract into a dedicated dir to scope
|
| 102 |
-
# the text.xml scan.
|
| 103 |
-
root = dest / ROOT_NAME
|
| 104 |
-
if root.is_dir():
|
| 105 |
-
print(f" already extracted {root}", flush=True)
|
| 106 |
-
return root
|
| 107 |
-
print(f" extracting {archive} -> {root}", flush=True)
|
| 108 |
-
root.mkdir(parents=True)
|
| 109 |
-
with tarfile.open(archive, "r:gz") as tar:
|
| 110 |
-
tar.extractall(root, filter="data") # py3.12+ safe extraction
|
| 111 |
-
return root
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
def _clean(text: str) -> str:
|
| 115 |
-
"""Strip ellipsis markers (… and "...") and tidy the whitespace they leave."""
|
| 116 |
-
return re.sub(r"[ \t]{2,}", " ", _ELLIPSIS.sub(" ", text)).strip()
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
def _polish_ratio(text: str) -> float:
|
| 120 |
-
"""Fraction of letters that are Polish-specific diacritics (build_dynaword)."""
|
| 121 |
-
letters = ALPHA_RE.findall(text)
|
| 122 |
-
return len(POLISH_RE.findall(text)) / len(letters) if letters else 0.0
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
def _norm_date(raw: str) -> str:
|
| 126 |
-
"""Normalize a TEI @when value to an ISO date or bare year, else "".
|
| 127 |
-
|
| 128 |
-
Keeps full YYYY-MM-DD, keeps bare YYYY, and salvages a leading 4-digit year
|
| 129 |
-
from anything else (e.g. "YYYY-MM", a stray trailing space). Values whose
|
| 130 |
-
year is implausible as a publication year (NKJP1M has a few malformed ones,
|
| 131 |
-
such as "200") are treated as missing.
|
| 132 |
-
"""
|
| 133 |
-
raw = (raw or "").strip()
|
| 134 |
-
if re.fullmatch(r"\d{4}-\d{2}-\d{2}", raw):
|
| 135 |
-
return raw if 1500 <= int(raw[:4]) <= 2014 else ""
|
| 136 |
-
m = re.match(r"(\d{4})", raw)
|
| 137 |
-
return m.group(1) if m and 1500 <= int(m.group(1)) <= 2014 else ""
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
def _published_date(header_path: Path) -> str:
|
| 141 |
-
"""Publication date from a sample's TEI header (<date type='published'>)."""
|
| 142 |
-
try:
|
| 143 |
-
tree = ET.parse(header_path)
|
| 144 |
-
except Exception: # noqa: BLE001 - missing/unreadable header -> no date
|
| 145 |
-
return ""
|
| 146 |
-
for el in tree.iter(DATE_TAG):
|
| 147 |
-
if el.get("type") == "published":
|
| 148 |
-
d = _norm_date(el.get("when") or (el.text or ""))
|
| 149 |
-
if d:
|
| 150 |
-
return d
|
| 151 |
-
return ""
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
def extract_passages(xml_path: str) -> list[str]:
|
| 155 |
-
"""One passage per TEI <div> (its <ab> paragraphs joined by newlines).
|
| 156 |
-
|
| 157 |
-
<ab> blocks inside a <div> are adjacent source paragraphs (real coherence);
|
| 158 |
-
different <div>s are unrelated sampled excerpts, so each becomes its own row.
|
| 159 |
-
Adapted from tmp/count_tokens.py, which instead merged every <ab> per file.
|
| 160 |
-
"""
|
| 161 |
-
passages, current = [], []
|
| 162 |
-
for _, elem in ET.iterparse(xml_path, events=("end",)):
|
| 163 |
-
if elem.tag == AB_TAG:
|
| 164 |
-
# itertext() also captures any nested inline markup text.
|
| 165 |
-
text = _clean("".join(elem.itertext()))
|
| 166 |
-
if text:
|
| 167 |
-
current.append(text)
|
| 168 |
-
elem.clear()
|
| 169 |
-
elif elem.tag == DIV_TAG:
|
| 170 |
-
if current:
|
| 171 |
-
passages.append("\n".join(current))
|
| 172 |
-
current = []
|
| 173 |
-
elem.clear()
|
| 174 |
-
if current: # <ab> outside any <div> (not expected) - keep as one passage
|
| 175 |
-
passages.append("\n".join(current))
|
| 176 |
-
return passages
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
def process_file(xml_path: str) -> tuple[list[dict], list[int]]:
|
| 180 |
-
"""Sample file -> (kept row dicts per surviving <div>, [read, short, lang]).
|
| 181 |
-
|
| 182 |
-
Gates run per passage; dedup is deferred to main() so it can span files.
|
| 183 |
-
"""
|
| 184 |
-
global _ENC
|
| 185 |
-
if _ENC is None:
|
| 186 |
-
_ENC = tiktoken.get_encoding("cl100k_base")
|
| 187 |
-
folder_dir = Path(xml_path).parent
|
| 188 |
-
folder = folder_dir.name
|
| 189 |
-
created = _published_date(folder_dir / "header.xml")
|
| 190 |
-
try:
|
| 191 |
-
passages = extract_passages(xml_path)
|
| 192 |
-
except Exception: # noqa: BLE001 - skip unreadable samples, don't crash
|
| 193 |
-
return [], [0, 0, 0]
|
| 194 |
-
|
| 195 |
-
read = short = lang = 0
|
| 196 |
-
kept = []
|
| 197 |
-
for i, text in enumerate(passages):
|
| 198 |
-
read += 1
|
| 199 |
-
text = text.strip()
|
| 200 |
-
if len(text) < MIN_CHARS:
|
| 201 |
-
short += 1
|
| 202 |
-
continue
|
| 203 |
-
if _polish_ratio(text) < MIN_POLISH_RATIO:
|
| 204 |
-
lang += 1
|
| 205 |
-
continue
|
| 206 |
-
kept.append({
|
| 207 |
-
"id": f"{KEY}_{folder}_{i}", # passage index kept stable across gating
|
| 208 |
-
"text": text,
|
| 209 |
-
"created": created,
|
| 210 |
-
"tokens": len(_ENC.encode_ordinary(text)),
|
| 211 |
-
"chars": len(text),
|
| 212 |
-
"sha1": hashlib.sha1(text.encode("utf-8")).digest(),
|
| 213 |
-
})
|
| 214 |
-
return kept, [read, short, lang]
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
def build_stats(parquet_path: Path, gate: dict) -> dict:
|
| 218 |
-
"""Recompute the sidecar stats directly from the written parquet.
|
| 219 |
-
|
| 220 |
-
Counts (kept/chars/tokens/licenses/authors/dates) come from the bytes on
|
| 221 |
-
disk; the drop_* tallies are build-time artifacts carried over from `gate`.
|
| 222 |
-
A cross-check asserts read == kept + drops so the two can't silently drift.
|
| 223 |
-
"""
|
| 224 |
-
t = pq.read_table(parquet_path)
|
| 225 |
-
d = t.to_pydict()
|
| 226 |
-
n = t.num_rows
|
| 227 |
-
dated = [c for c in d["created"] if c]
|
| 228 |
-
years = sorted({int(c[:4]) for c in dated})
|
| 229 |
-
read = gate["read"]
|
| 230 |
-
drops = gate["drop_short"] + gate["drop_lang"] + gate["drop_dup"] + gate["drop_ocr"]
|
| 231 |
-
assert n == read - drops, f"gate arithmetic: kept {n} != read {read} - drops {drops}"
|
| 232 |
-
return {
|
| 233 |
-
"read": read,
|
| 234 |
-
"kept": n,
|
| 235 |
-
"drop_short": gate["drop_short"],
|
| 236 |
-
"drop_lang": gate["drop_lang"],
|
| 237 |
-
"drop_dup": gate["drop_dup"],
|
| 238 |
-
"drop_ocr": gate["drop_ocr"],
|
| 239 |
-
"chars": sum(len(x) for x in d["text"]),
|
| 240 |
-
"tokens": sum(d["token_count"]),
|
| 241 |
-
"licenses": {LICENSE: n},
|
| 242 |
-
"authors_with_value": sum(1 for a in d["author"] if a),
|
| 243 |
-
"documents_with_created": len(dated),
|
| 244 |
-
"created_range": f"{years[0]}-{years[-1]}" if years else "",
|
| 245 |
-
"license": LICENSE,
|
| 246 |
-
"stats_recomputed_from_parquet": True,
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
def report(rows: list[dict], stats: dict) -> None:
|
| 251 |
-
"""Aggregate cl100k token stats. (adapted from count_tokens.py)"""
|
| 252 |
-
toks = sorted(r["tokens"] for r in rows)
|
| 253 |
-
total_tok, total_chars = sum(toks), sum(r["chars"] for r in rows)
|
| 254 |
-
|
| 255 |
-
def pct(p: float) -> int:
|
| 256 |
-
return toks[max(0, min(len(toks) - 1, round(p / 100 * (len(toks) - 1))))]
|
| 257 |
-
|
| 258 |
-
print("\n" + "=" * 60)
|
| 259 |
-
print("NKJP cl100k token statistics")
|
| 260 |
-
print("=" * 60)
|
| 261 |
-
print(f"Passages kept: {len(rows):,}")
|
| 262 |
-
print(f"Total tokens: {total_tok:,}")
|
| 263 |
-
print(f"Total characters: {total_chars:,}")
|
| 264 |
-
if toks:
|
| 265 |
-
print(f"Mean tokens/pass.: {total_tok / len(toks):,.1f}")
|
| 266 |
-
print(f"Median / p90 / max: {pct(50):,} / {pct(90):,} / {max(toks):,}")
|
| 267 |
-
if total_tok:
|
| 268 |
-
print(f"Chars per token: {total_chars / total_tok:.2f}")
|
| 269 |
-
if stats.get("created_range"):
|
| 270 |
-
print(f"Created range: {stats['created_range']} "
|
| 271 |
-
f"({stats['documents_with_created']:,}/{len(rows):,} dated)")
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
def main() -> int:
|
| 275 |
-
ap = argparse.ArgumentParser(description=__doc__)
|
| 276 |
-
ap.add_argument("--out", default=".",
|
| 277 |
-
help="DynaWord root; shard -> <out>/data/nkjp1m/nkjp1m.parquet")
|
| 278 |
-
ap.add_argument("--tmp", default="/tmp", help="Download + extraction dir")
|
| 279 |
-
ap.add_argument("--workers", type=int, default=None, help="Process pool size")
|
| 280 |
-
ap.add_argument("--added", default=date.today().isoformat(),
|
| 281 |
-
help="Value for the 'added' column (default: today)")
|
| 282 |
-
args = ap.parse_args()
|
| 283 |
-
|
| 284 |
-
t0 = time.time()
|
| 285 |
-
tmp = Path(args.tmp).expanduser()
|
| 286 |
-
root = extract_archive(download(URL, tmp / f"{ROOT_NAME}.tar.gz"), tmp)
|
| 287 |
-
|
| 288 |
-
files = sorted(str(p) for p in root.rglob("text.xml"))
|
| 289 |
-
if not files:
|
| 290 |
-
print(f"error: no text.xml under {root}", file=sys.stderr)
|
| 291 |
-
return 1
|
| 292 |
-
print(f"Found {len(files)} text.xml files under {root}", flush=True)
|
| 293 |
-
|
| 294 |
-
read = short = lang = 0
|
| 295 |
-
collected = [] # kept row dicts, in sorted file + passage order (deterministic)
|
| 296 |
-
with ProcessPoolExecutor(max_workers=args.workers) as pool:
|
| 297 |
-
for i, (kept, st3) in enumerate(pool.map(process_file, files, chunksize=16), 1):
|
| 298 |
-
read += st3[0]; short += st3[1]; lang += st3[2]
|
| 299 |
-
collected.extend(kept)
|
| 300 |
-
if i % 1000 == 0 or i == len(files):
|
| 301 |
-
print(f" processed {i}/{len(files)} files, {len(collected):,} kept passages",
|
| 302 |
-
file=sys.stderr)
|
| 303 |
-
|
| 304 |
-
# Exact dedup (sha1), first-wins over the deterministic order above.
|
| 305 |
-
seen, rows, drop_dup = set(), [], 0
|
| 306 |
-
for r in collected:
|
| 307 |
-
if r["sha1"] in seen:
|
| 308 |
-
drop_dup += 1
|
| 309 |
-
continue
|
| 310 |
-
seen.add(r["sha1"])
|
| 311 |
-
rows.append(r)
|
| 312 |
-
|
| 313 |
-
n = len(rows)
|
| 314 |
-
out = Path(args.out).expanduser().resolve() / "data" / KEY / f"{KEY}.parquet"
|
| 315 |
-
out.parent.mkdir(parents=True, exist_ok=True)
|
| 316 |
-
pq.write_table(pa.table({
|
| 317 |
-
"id": [r["id"] for r in rows],
|
| 318 |
-
"text": [r["text"] for r in rows],
|
| 319 |
-
"source": [KEY] * n,
|
| 320 |
-
"added": [args.added] * n,
|
| 321 |
-
"created": [r["created"] for r in rows],
|
| 322 |
-
"token_count": [r["tokens"] for r in rows],
|
| 323 |
-
"license": [LICENSE] * n,
|
| 324 |
-
"author": [AUTHOR] * n,
|
| 325 |
-
}, schema=SCHEMA), out, compression="zstd")
|
| 326 |
-
|
| 327 |
-
# DynaWord-style sidecar stats, recomputed from the parquet just written.
|
| 328 |
-
gate = {"read": read, "drop_short": short, "drop_lang": lang,
|
| 329 |
-
"drop_dup": drop_dup, "drop_ocr": 0}
|
| 330 |
-
stats = build_stats(out, gate)
|
| 331 |
-
out.with_name(f"{KEY}.stats.json").write_text(
|
| 332 |
-
json.dumps(stats, ensure_ascii=False, indent=2) + "\n")
|
| 333 |
-
|
| 334 |
-
report(rows, stats)
|
| 335 |
-
print(f"\nWrote {n:,} passages from {len(files):,} files "
|
| 336 |
-
f"(read {read:,}, -short {short:,} -lang {lang:,} -dup {drop_dup:,}) "
|
| 337 |
-
f"-> {out} in {round(time.time() - t0)}s", flush=True)
|
| 338 |
-
return 0
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
if __name__ == "__main__":
|
| 342 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/govpl_subsites.json
DELETED
|
@@ -1,684 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"generated": "2026-07-18",
|
| 3 |
-
"source": "https://www.gov.pl/web/gov/katalog-jednostek",
|
| 4 |
-
"subsites": [
|
| 5 |
-
{
|
| 6 |
-
"slug": "premier",
|
| 7 |
-
"news_path": "aktualnosci",
|
| 8 |
-
"pages": 294
|
| 9 |
-
},
|
| 10 |
-
{
|
| 11 |
-
"slug": "aktywa-panstwowe",
|
| 12 |
-
"news_path": "wiadomosci",
|
| 13 |
-
"pages": 87
|
| 14 |
-
},
|
| 15 |
-
{
|
| 16 |
-
"slug": "cyfryzacja",
|
| 17 |
-
"news_path": "wiadomosci",
|
| 18 |
-
"pages": 353
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"slug": "edukacja",
|
| 22 |
-
"news_path": "wiadomosci",
|
| 23 |
-
"pages": 104
|
| 24 |
-
},
|
| 25 |
-
{
|
| 26 |
-
"slug": "energia",
|
| 27 |
-
"news_path": "wiadomosci",
|
| 28 |
-
"pages": 36
|
| 29 |
-
},
|
| 30 |
-
{
|
| 31 |
-
"slug": "finanse",
|
| 32 |
-
"news_path": "wiadomosci",
|
| 33 |
-
"pages": 266
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"slug": "fundusze-regiony",
|
| 37 |
-
"news_path": "aktualnosci1",
|
| 38 |
-
"pages": 378
|
| 39 |
-
},
|
| 40 |
-
{
|
| 41 |
-
"slug": "infrastruktura",
|
| 42 |
-
"news_path": "aktualnosci",
|
| 43 |
-
"pages": 325
|
| 44 |
-
},
|
| 45 |
-
{
|
| 46 |
-
"slug": "klimat",
|
| 47 |
-
"news_path": "wiadomosci",
|
| 48 |
-
"pages": 289
|
| 49 |
-
},
|
| 50 |
-
{
|
| 51 |
-
"slug": "kultura",
|
| 52 |
-
"news_path": "aktualnosci",
|
| 53 |
-
"pages": 481
|
| 54 |
-
},
|
| 55 |
-
{
|
| 56 |
-
"slug": "nauka",
|
| 57 |
-
"news_path": "wiadomosci",
|
| 58 |
-
"pages": 78
|
| 59 |
-
},
|
| 60 |
-
{
|
| 61 |
-
"slug": "obrona-narodowa",
|
| 62 |
-
"news_path": "aktualnosci5",
|
| 63 |
-
"pages": 186
|
| 64 |
-
},
|
| 65 |
-
{
|
| 66 |
-
"slug": "rodzina",
|
| 67 |
-
"news_path": "wiadomosci-polityka-rodzinna",
|
| 68 |
-
"pages": 111
|
| 69 |
-
},
|
| 70 |
-
{
|
| 71 |
-
"slug": "rolnictwo",
|
| 72 |
-
"news_path": "wiadomosci",
|
| 73 |
-
"pages": 5
|
| 74 |
-
},
|
| 75 |
-
{
|
| 76 |
-
"slug": "rozwoj-technologia",
|
| 77 |
-
"news_path": "wiadomosci",
|
| 78 |
-
"pages": 52
|
| 79 |
-
},
|
| 80 |
-
{
|
| 81 |
-
"slug": "sport",
|
| 82 |
-
"news_path": "wiadomosci",
|
| 83 |
-
"pages": 219
|
| 84 |
-
},
|
| 85 |
-
{
|
| 86 |
-
"slug": "sprawiedliwosc",
|
| 87 |
-
"news_path": "aktualnosci-ogloszenia-i-informacje",
|
| 88 |
-
"pages": 285
|
| 89 |
-
},
|
| 90 |
-
{
|
| 91 |
-
"slug": "mswia",
|
| 92 |
-
"news_path": "aktualnosci",
|
| 93 |
-
"pages": 216
|
| 94 |
-
},
|
| 95 |
-
{
|
| 96 |
-
"slug": "dyplomacja",
|
| 97 |
-
"news_path": "aktualnosci",
|
| 98 |
-
"pages": 302
|
| 99 |
-
},
|
| 100 |
-
{
|
| 101 |
-
"slug": "zdrowie",
|
| 102 |
-
"news_path": "wiadomosci",
|
| 103 |
-
"pages": 145
|
| 104 |
-
},
|
| 105 |
-
{
|
| 106 |
-
"slug": "zermswia",
|
| 107 |
-
"news_path": "aktualnosci",
|
| 108 |
-
"pages": 12
|
| 109 |
-
},
|
| 110 |
-
{
|
| 111 |
-
"slug": "arimr",
|
| 112 |
-
"news_path": "aktualnosci10",
|
| 113 |
-
"pages": 6
|
| 114 |
-
},
|
| 115 |
-
{
|
| 116 |
-
"slug": "rpp",
|
| 117 |
-
"news_path": "aktualnosci",
|
| 118 |
-
"pages": 93
|
| 119 |
-
},
|
| 120 |
-
{
|
| 121 |
-
"slug": "gdos",
|
| 122 |
-
"news_path": "aktualnosci",
|
| 123 |
-
"pages": 57
|
| 124 |
-
},
|
| 125 |
-
{
|
| 126 |
-
"slug": "gif",
|
| 127 |
-
"news_path": "wiadomosci",
|
| 128 |
-
"pages": 37
|
| 129 |
-
},
|
| 130 |
-
{
|
| 131 |
-
"slug": "gios",
|
| 132 |
-
"news_path": "wiadomosci",
|
| 133 |
-
"pages": 53
|
| 134 |
-
},
|
| 135 |
-
{
|
| 136 |
-
"slug": "gis",
|
| 137 |
-
"news_path": "wiadomosci",
|
| 138 |
-
"pages": 49
|
| 139 |
-
},
|
| 140 |
-
{
|
| 141 |
-
"slug": "gitd",
|
| 142 |
-
"news_path": "komunikaty-btm2",
|
| 143 |
-
"pages": 27
|
| 144 |
-
},
|
| 145 |
-
{
|
| 146 |
-
"slug": "gugik",
|
| 147 |
-
"news_path": "wiadomosci",
|
| 148 |
-
"pages": 183
|
| 149 |
-
},
|
| 150 |
-
{
|
| 151 |
-
"slug": "krus",
|
| 152 |
-
"news_path": "aktualnosci",
|
| 153 |
-
"pages": 18
|
| 154 |
-
},
|
| 155 |
-
{
|
| 156 |
-
"slug": "paa",
|
| 157 |
-
"news_path": "aktualnosci",
|
| 158 |
-
"pages": 49
|
| 159 |
-
},
|
| 160 |
-
{
|
| 161 |
-
"slug": "rcb",
|
| 162 |
-
"news_path": "komunikaty",
|
| 163 |
-
"pages": 90
|
| 164 |
-
},
|
| 165 |
-
{
|
| 166 |
-
"slug": "udsc",
|
| 167 |
-
"news_path": "aktualnosci",
|
| 168 |
-
"pages": 23
|
| 169 |
-
},
|
| 170 |
-
{
|
| 171 |
-
"slug": "prokuratoria",
|
| 172 |
-
"news_path": "aktualnosci",
|
| 173 |
-
"pages": 9
|
| 174 |
-
},
|
| 175 |
-
{
|
| 176 |
-
"slug": "urpl",
|
| 177 |
-
"news_path": "aktualnosci",
|
| 178 |
-
"pages": 14
|
| 179 |
-
},
|
| 180 |
-
{
|
| 181 |
-
"slug": "uzp",
|
| 182 |
-
"news_path": "aktualnosci",
|
| 183 |
-
"pages": 18
|
| 184 |
-
},
|
| 185 |
-
{
|
| 186 |
-
"slug": "uw-kujawsko-pomorski",
|
| 187 |
-
"news_path": "aktualnosci",
|
| 188 |
-
"pages": 216
|
| 189 |
-
},
|
| 190 |
-
{
|
| 191 |
-
"slug": "uw-lubelski",
|
| 192 |
-
"news_path": "wiadomosci",
|
| 193 |
-
"pages": 95
|
| 194 |
-
},
|
| 195 |
-
{
|
| 196 |
-
"slug": "uw-lubuski",
|
| 197 |
-
"news_path": "wiadomosci",
|
| 198 |
-
"pages": 138
|
| 199 |
-
},
|
| 200 |
-
{
|
| 201 |
-
"slug": "uw-lodzki",
|
| 202 |
-
"news_path": "wiadomosci",
|
| 203 |
-
"pages": 161
|
| 204 |
-
},
|
| 205 |
-
{
|
| 206 |
-
"slug": "uw-mazowiecki",
|
| 207 |
-
"news_path": "wiadomosci2",
|
| 208 |
-
"pages": 132
|
| 209 |
-
},
|
| 210 |
-
{
|
| 211 |
-
"slug": "uw-opolski",
|
| 212 |
-
"news_path": "aktualnosci",
|
| 213 |
-
"pages": 138
|
| 214 |
-
},
|
| 215 |
-
{
|
| 216 |
-
"slug": "uw-podkarpacki",
|
| 217 |
-
"news_path": "wiadomosci",
|
| 218 |
-
"pages": 149
|
| 219 |
-
},
|
| 220 |
-
{
|
| 221 |
-
"slug": "uw-podlaski",
|
| 222 |
-
"news_path": "wiadomosci",
|
| 223 |
-
"pages": 310
|
| 224 |
-
},
|
| 225 |
-
{
|
| 226 |
-
"slug": "uw-warminsko-mazurski",
|
| 227 |
-
"news_path": "aktualnosci",
|
| 228 |
-
"pages": 377
|
| 229 |
-
},
|
| 230 |
-
{
|
| 231 |
-
"slug": "uw-zachodniopomorski",
|
| 232 |
-
"news_path": "wiadomosci",
|
| 233 |
-
"pages": 4
|
| 234 |
-
},
|
| 235 |
-
{
|
| 236 |
-
"slug": "gddkia-bialystok",
|
| 237 |
-
"news_path": "aktualnosci",
|
| 238 |
-
"pages": 2
|
| 239 |
-
},
|
| 240 |
-
{
|
| 241 |
-
"slug": "gddkia-bydgoszcz",
|
| 242 |
-
"news_path": "aktualnosci",
|
| 243 |
-
"pages": 3
|
| 244 |
-
},
|
| 245 |
-
{
|
| 246 |
-
"slug": "gddkia-gdansk",
|
| 247 |
-
"news_path": "aktualnosci",
|
| 248 |
-
"pages": 5
|
| 249 |
-
},
|
| 250 |
-
{
|
| 251 |
-
"slug": "gddkia-katowice",
|
| 252 |
-
"news_path": "aktualnosci",
|
| 253 |
-
"pages": 5
|
| 254 |
-
},
|
| 255 |
-
{
|
| 256 |
-
"slug": "gddkia-kielce",
|
| 257 |
-
"news_path": "aktualnosci",
|
| 258 |
-
"pages": 6
|
| 259 |
-
},
|
| 260 |
-
{
|
| 261 |
-
"slug": "gddkia-krakow",
|
| 262 |
-
"news_path": "aktualnosci",
|
| 263 |
-
"pages": 7
|
| 264 |
-
},
|
| 265 |
-
{
|
| 266 |
-
"slug": "gddkia-lublin",
|
| 267 |
-
"news_path": "aktualnosci",
|
| 268 |
-
"pages": 5
|
| 269 |
-
},
|
| 270 |
-
{
|
| 271 |
-
"slug": "gddkia-lodz",
|
| 272 |
-
"news_path": "aktualnosci",
|
| 273 |
-
"pages": 4
|
| 274 |
-
},
|
| 275 |
-
{
|
| 276 |
-
"slug": "gddkia-olsztyn",
|
| 277 |
-
"news_path": "aktualnosci",
|
| 278 |
-
"pages": 1
|
| 279 |
-
},
|
| 280 |
-
{
|
| 281 |
-
"slug": "gddkia-opole",
|
| 282 |
-
"news_path": "aktualnosci",
|
| 283 |
-
"pages": 5
|
| 284 |
-
},
|
| 285 |
-
{
|
| 286 |
-
"slug": "gddkia-poznan",
|
| 287 |
-
"news_path": "aktualnosci",
|
| 288 |
-
"pages": 5
|
| 289 |
-
},
|
| 290 |
-
{
|
| 291 |
-
"slug": "gddkia-rzeszow",
|
| 292 |
-
"news_path": "aktualnosci",
|
| 293 |
-
"pages": 6
|
| 294 |
-
},
|
| 295 |
-
{
|
| 296 |
-
"slug": "gddkia-szczecin",
|
| 297 |
-
"news_path": "aktualnosci",
|
| 298 |
-
"pages": 3
|
| 299 |
-
},
|
| 300 |
-
{
|
| 301 |
-
"slug": "gddkia-warszawa",
|
| 302 |
-
"news_path": "aktualnosci",
|
| 303 |
-
"pages": 4
|
| 304 |
-
},
|
| 305 |
-
{
|
| 306 |
-
"slug": "gddkia-wroclaw",
|
| 307 |
-
"news_path": "aktualnosci",
|
| 308 |
-
"pages": 7
|
| 309 |
-
},
|
| 310 |
-
{
|
| 311 |
-
"slug": "gddkia-zielona-gora",
|
| 312 |
-
"news_path": "aktualnosci",
|
| 313 |
-
"pages": 2
|
| 314 |
-
},
|
| 315 |
-
{
|
| 316 |
-
"slug": "wsse-bialystok",
|
| 317 |
-
"news_path": "wiadomosci",
|
| 318 |
-
"pages": 20
|
| 319 |
-
},
|
| 320 |
-
{
|
| 321 |
-
"slug": "wsse-bydgoszcz",
|
| 322 |
-
"news_path": "aktualnosci",
|
| 323 |
-
"pages": 71
|
| 324 |
-
},
|
| 325 |
-
{
|
| 326 |
-
"slug": "wsse-gdansk",
|
| 327 |
-
"news_path": "wiadomosci",
|
| 328 |
-
"pages": 48
|
| 329 |
-
},
|
| 330 |
-
{
|
| 331 |
-
"slug": "wsse-katowice",
|
| 332 |
-
"news_path": "wiadomosci",
|
| 333 |
-
"pages": 35
|
| 334 |
-
},
|
| 335 |
-
{
|
| 336 |
-
"slug": "wsse-kielce",
|
| 337 |
-
"news_path": "wiadomosci",
|
| 338 |
-
"pages": 28
|
| 339 |
-
},
|
| 340 |
-
{
|
| 341 |
-
"slug": "wsse-lublin",
|
| 342 |
-
"news_path": "komunikaty-i-meldunki",
|
| 343 |
-
"pages": 53
|
| 344 |
-
},
|
| 345 |
-
{
|
| 346 |
-
"slug": "wsse-lodz",
|
| 347 |
-
"news_path": "komunikaty-o-wodzie-do-spozycia2",
|
| 348 |
-
"pages": 104
|
| 349 |
-
},
|
| 350 |
-
{
|
| 351 |
-
"slug": "wsse-olsztyn",
|
| 352 |
-
"news_path": "komunikaty-i-meldunki",
|
| 353 |
-
"pages": 52
|
| 354 |
-
},
|
| 355 |
-
{
|
| 356 |
-
"slug": "wsse-opole",
|
| 357 |
-
"news_path": "wiadomosci",
|
| 358 |
-
"pages": 17
|
| 359 |
-
},
|
| 360 |
-
{
|
| 361 |
-
"slug": "wsse-poznan",
|
| 362 |
-
"news_path": "wiadomosci",
|
| 363 |
-
"pages": 31
|
| 364 |
-
},
|
| 365 |
-
{
|
| 366 |
-
"slug": "wsse-rzeszow",
|
| 367 |
-
"news_path": "wiadomosci",
|
| 368 |
-
"pages": 24
|
| 369 |
-
},
|
| 370 |
-
{
|
| 371 |
-
"slug": "wsse-szczecin",
|
| 372 |
-
"news_path": "wiadomosci",
|
| 373 |
-
"pages": 44
|
| 374 |
-
},
|
| 375 |
-
{
|
| 376 |
-
"slug": "wsse-warszawa",
|
| 377 |
-
"news_path": "wiadomosci",
|
| 378 |
-
"pages": 36
|
| 379 |
-
},
|
| 380 |
-
{
|
| 381 |
-
"slug": "wsse-wroclaw",
|
| 382 |
-
"news_path": "komunikaty-i-meldunki",
|
| 383 |
-
"pages": 25
|
| 384 |
-
},
|
| 385 |
-
{
|
| 386 |
-
"slug": "prokuratura-krajowa",
|
| 387 |
-
"news_path": "aktualnosci",
|
| 388 |
-
"pages": 541
|
| 389 |
-
},
|
| 390 |
-
{
|
| 391 |
-
"slug": "po-bialystok",
|
| 392 |
-
"news_path": "aktualnosci",
|
| 393 |
-
"pages": 25
|
| 394 |
-
},
|
| 395 |
-
{
|
| 396 |
-
"slug": "po-bielsko-biala",
|
| 397 |
-
"news_path": "komunikaty",
|
| 398 |
-
"pages": 1
|
| 399 |
-
},
|
| 400 |
-
{
|
| 401 |
-
"slug": "po-bydgoszcz",
|
| 402 |
-
"news_path": "aktualnosci1",
|
| 403 |
-
"pages": 17
|
| 404 |
-
},
|
| 405 |
-
{
|
| 406 |
-
"slug": "po-elblag",
|
| 407 |
-
"news_path": "komunikaty",
|
| 408 |
-
"pages": 8
|
| 409 |
-
},
|
| 410 |
-
{
|
| 411 |
-
"slug": "po-gdansk",
|
| 412 |
-
"news_path": "aktualnosci",
|
| 413 |
-
"pages": 1
|
| 414 |
-
},
|
| 415 |
-
{
|
| 416 |
-
"slug": "po-gliwice",
|
| 417 |
-
"news_path": "komunikaty",
|
| 418 |
-
"pages": 32
|
| 419 |
-
},
|
| 420 |
-
{
|
| 421 |
-
"slug": "po-gorzow-wielkopolski",
|
| 422 |
-
"news_path": "aktualnosci1",
|
| 423 |
-
"pages": 17
|
| 424 |
-
},
|
| 425 |
-
{
|
| 426 |
-
"slug": "po-katowice",
|
| 427 |
-
"news_path": "komunikaty-rzecznika-prasowego",
|
| 428 |
-
"pages": 8
|
| 429 |
-
},
|
| 430 |
-
{
|
| 431 |
-
"slug": "po-kielce",
|
| 432 |
-
"news_path": "aktualnosci1",
|
| 433 |
-
"pages": 25
|
| 434 |
-
},
|
| 435 |
-
{
|
| 436 |
-
"slug": "po-krakow",
|
| 437 |
-
"news_path": "komunikaty-rzecznika2",
|
| 438 |
-
"pages": 11
|
| 439 |
-
},
|
| 440 |
-
{
|
| 441 |
-
"slug": "po-legnica",
|
| 442 |
-
"news_path": "aktualnosci1",
|
| 443 |
-
"pages": 36
|
| 444 |
-
},
|
| 445 |
-
{
|
| 446 |
-
"slug": "po-lublin",
|
| 447 |
-
"news_path": "aktualnosci",
|
| 448 |
-
"pages": 9
|
| 449 |
-
},
|
| 450 |
-
{
|
| 451 |
-
"slug": "po-lodz",
|
| 452 |
-
"news_path": "aktualnosci1",
|
| 453 |
-
"pages": 26
|
| 454 |
-
},
|
| 455 |
-
{
|
| 456 |
-
"slug": "po-lomza",
|
| 457 |
-
"news_path": "komunikaty-rzecznika-prasowego---archiwalne",
|
| 458 |
-
"pages": 13
|
| 459 |
-
},
|
| 460 |
-
{
|
| 461 |
-
"slug": "po-nowy-sacz",
|
| 462 |
-
"news_path": "aktualnosci",
|
| 463 |
-
"pages": 25
|
| 464 |
-
},
|
| 465 |
-
{
|
| 466 |
-
"slug": "po-olsztyn",
|
| 467 |
-
"news_path": "aktualnosci1",
|
| 468 |
-
"pages": 16
|
| 469 |
-
},
|
| 470 |
-
{
|
| 471 |
-
"slug": "po-opole",
|
| 472 |
-
"news_path": "aktualnosci",
|
| 473 |
-
"pages": 21
|
| 474 |
-
},
|
| 475 |
-
{
|
| 476 |
-
"slug": "po-ostroleka",
|
| 477 |
-
"news_path": "komunikaty-prasowe",
|
| 478 |
-
"pages": 6
|
| 479 |
-
},
|
| 480 |
-
{
|
| 481 |
-
"slug": "po-ostrow-wielkopolski",
|
| 482 |
-
"news_path": "aktualnosci1",
|
| 483 |
-
"pages": 18
|
| 484 |
-
},
|
| 485 |
-
{
|
| 486 |
-
"slug": "po-piotrkow-trybunalski",
|
| 487 |
-
"news_path": "aktualnosci",
|
| 488 |
-
"pages": 17
|
| 489 |
-
},
|
| 490 |
-
{
|
| 491 |
-
"slug": "po-plock",
|
| 492 |
-
"news_path": "aktualnosci",
|
| 493 |
-
"pages": 13
|
| 494 |
-
},
|
| 495 |
-
{
|
| 496 |
-
"slug": "po-poznan",
|
| 497 |
-
"news_path": "aktualnosci1",
|
| 498 |
-
"pages": 51
|
| 499 |
-
},
|
| 500 |
-
{
|
| 501 |
-
"slug": "po-rzeszow",
|
| 502 |
-
"news_path": "komunikaty-prasowe",
|
| 503 |
-
"pages": 38
|
| 504 |
-
},
|
| 505 |
-
{
|
| 506 |
-
"slug": "po-siedlce",
|
| 507 |
-
"news_path": "aktualnosci1",
|
| 508 |
-
"pages": 15
|
| 509 |
-
},
|
| 510 |
-
{
|
| 511 |
-
"slug": "po-sieradz",
|
| 512 |
-
"news_path": "aktualnosci",
|
| 513 |
-
"pages": 15
|
| 514 |
-
},
|
| 515 |
-
{
|
| 516 |
-
"slug": "po-sosnowiec",
|
| 517 |
-
"news_path": "aktualnosci",
|
| 518 |
-
"pages": 28
|
| 519 |
-
},
|
| 520 |
-
{
|
| 521 |
-
"slug": "po-swidnica",
|
| 522 |
-
"news_path": "aktualnosci",
|
| 523 |
-
"pages": 23
|
| 524 |
-
},
|
| 525 |
-
{
|
| 526 |
-
"slug": "po-tarnow",
|
| 527 |
-
"news_path": "aktualnosci1",
|
| 528 |
-
"pages": 14
|
| 529 |
-
},
|
| 530 |
-
{
|
| 531 |
-
"slug": "po-torun",
|
| 532 |
-
"news_path": "aktualnosci1",
|
| 533 |
-
"pages": 19
|
| 534 |
-
},
|
| 535 |
-
{
|
| 536 |
-
"slug": "po-warszawa",
|
| 537 |
-
"news_path": "komunikaty-rzecznika-prasowego",
|
| 538 |
-
"pages": 28
|
| 539 |
-
},
|
| 540 |
-
{
|
| 541 |
-
"slug": "po-warszawa-praga",
|
| 542 |
-
"news_path": "aktualnosci",
|
| 543 |
-
"pages": 31
|
| 544 |
-
},
|
| 545 |
-
{
|
| 546 |
-
"slug": "po-wloclawek",
|
| 547 |
-
"news_path": "aktualnosci1",
|
| 548 |
-
"pages": 18
|
| 549 |
-
},
|
| 550 |
-
{
|
| 551 |
-
"slug": "po-wroclaw",
|
| 552 |
-
"news_path": "aktualnosci",
|
| 553 |
-
"pages": 23
|
| 554 |
-
},
|
| 555 |
-
{
|
| 556 |
-
"slug": "po-zielona-gora",
|
| 557 |
-
"news_path": "aktualnosci1",
|
| 558 |
-
"pages": 35
|
| 559 |
-
},
|
| 560 |
-
{
|
| 561 |
-
"slug": "pr-gdansk",
|
| 562 |
-
"news_path": "aktualnosci",
|
| 563 |
-
"pages": 23
|
| 564 |
-
},
|
| 565 |
-
{
|
| 566 |
-
"slug": "pr-katowice",
|
| 567 |
-
"news_path": "aktualnosci-prokuratury-regionalnej",
|
| 568 |
-
"pages": 14
|
| 569 |
-
},
|
| 570 |
-
{
|
| 571 |
-
"slug": "pr-krakow",
|
| 572 |
-
"news_path": "komunikaty",
|
| 573 |
-
"pages": 6
|
| 574 |
-
},
|
| 575 |
-
{
|
| 576 |
-
"slug": "pr-lublin",
|
| 577 |
-
"news_path": "aktualnosci1",
|
| 578 |
-
"pages": 8
|
| 579 |
-
},
|
| 580 |
-
{
|
| 581 |
-
"slug": "pr-lodz",
|
| 582 |
-
"news_path": "aktualnosci",
|
| 583 |
-
"pages": 15
|
| 584 |
-
},
|
| 585 |
-
{
|
| 586 |
-
"slug": "pr-poznan",
|
| 587 |
-
"news_path": "wiadomosci",
|
| 588 |
-
"pages": 17
|
| 589 |
-
},
|
| 590 |
-
{
|
| 591 |
-
"slug": "pr-rzeszow",
|
| 592 |
-
"news_path": "aktualnosci",
|
| 593 |
-
"pages": 11
|
| 594 |
-
},
|
| 595 |
-
{
|
| 596 |
-
"slug": "pr-szczecin",
|
| 597 |
-
"news_path": "aktualnosci",
|
| 598 |
-
"pages": 13
|
| 599 |
-
},
|
| 600 |
-
{
|
| 601 |
-
"slug": "pr-warszawa",
|
| 602 |
-
"news_path": "aktualnosci1",
|
| 603 |
-
"pages": 19
|
| 604 |
-
},
|
| 605 |
-
{
|
| 606 |
-
"slug": "pr-wroclaw",
|
| 607 |
-
"news_path": "aktualnosci1",
|
| 608 |
-
"pages": 32
|
| 609 |
-
},
|
| 610 |
-
{
|
| 611 |
-
"slug": "kgpsp",
|
| 612 |
-
"news_path": "aktualnosci",
|
| 613 |
-
"pages": 130
|
| 614 |
-
},
|
| 615 |
-
{
|
| 616 |
-
"slug": "kwpsp-gdansk",
|
| 617 |
-
"news_path": "aktualnosci",
|
| 618 |
-
"pages": 103
|
| 619 |
-
},
|
| 620 |
-
{
|
| 621 |
-
"slug": "kwpsp-opole",
|
| 622 |
-
"news_path": "aktualnosci",
|
| 623 |
-
"pages": 6
|
| 624 |
-
},
|
| 625 |
-
{
|
| 626 |
-
"slug": "kwpsp-poznan",
|
| 627 |
-
"news_path": "wiadomosci2021",
|
| 628 |
-
"pages": 24
|
| 629 |
-
},
|
| 630 |
-
{
|
| 631 |
-
"slug": "spzoz-mswia-opole",
|
| 632 |
-
"news_path": "wiadomosci",
|
| 633 |
-
"pages": 3
|
| 634 |
-
},
|
| 635 |
-
{
|
| 636 |
-
"slug": "spzoz-mswia-szczecin",
|
| 637 |
-
"news_path": "aktualnosci",
|
| 638 |
-
"pages": 62
|
| 639 |
-
},
|
| 640 |
-
{
|
| 641 |
-
"slug": "spzoz-mswia-zielona-gora",
|
| 642 |
-
"news_path": "aktualnosci",
|
| 643 |
-
"pages": 2
|
| 644 |
-
},
|
| 645 |
-
{
|
| 646 |
-
"slug": "krrit",
|
| 647 |
-
"news_path": "aktualnosci",
|
| 648 |
-
"pages": 61
|
| 649 |
-
},
|
| 650 |
-
{
|
| 651 |
-
"slug": "kowr",
|
| 652 |
-
"news_path": "aktualnosci",
|
| 653 |
-
"pages": 5
|
| 654 |
-
},
|
| 655 |
-
{
|
| 656 |
-
"slug": "kzn",
|
| 657 |
-
"news_path": "aktualnosci",
|
| 658 |
-
"pages": 24
|
| 659 |
-
},
|
| 660 |
-
{
|
| 661 |
-
"slug": "nck",
|
| 662 |
-
"news_path": "aktualnosci",
|
| 663 |
-
"pages": 55
|
| 664 |
-
},
|
| 665 |
-
{
|
| 666 |
-
"slug": "wody-polskie",
|
| 667 |
-
"news_path": "aktualnosci",
|
| 668 |
-
"pages": 62
|
| 669 |
-
}
|
| 670 |
-
],
|
| 671 |
-
"skipped": [
|
| 672 |
-
"chemikalia",
|
| 673 |
-
"piorin",
|
| 674 |
-
"wsse-gorzowwlkp",
|
| 675 |
-
"wsse-krakow",
|
| 676 |
-
"po-slupsk",
|
| 677 |
-
"po-tarnobrzeg",
|
| 678 |
-
"cskmswia",
|
| 679 |
-
"spzoz-mswia-katowice",
|
| 680 |
-
"spzoz-mswia-lublin",
|
| 681 |
-
"spzoz-mswia-glucholazy"
|
| 682 |
-
],
|
| 683 |
-
"total_pages": 9247
|
| 684 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/make_docs.py
CHANGED
|
@@ -13,8 +13,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
| 13 |
from sources import SOURCES, EXCLUDED, ADDED
|
| 14 |
|
| 15 |
ROOT = Path(__file__).resolve().parent.parent
|
| 16 |
-
VERSION = "0.2.
|
| 17 |
-
RELEASE_DATE = "2026-07-26"
|
| 18 |
CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
|
| 19 |
|
| 20 |
# Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
|
|
@@ -120,10 +119,7 @@ def main():
|
|
| 120 |
st = load_stats(name)
|
| 121 |
if not st:
|
| 122 |
print(f" ! no stats for {name}"); continue
|
| 123 |
-
|
| 124 |
-
# date) opt out of template regeneration to avoid clobbering it.
|
| 125 |
-
if not cfg.get("custom_datasheet"):
|
| 126 |
-
(ROOT / "data" / name / f"{name}.md").write_text(datasheet(name, cfg, st))
|
| 127 |
rows.append((name, cfg, st))
|
| 128 |
tot_doc += st["kept"]; tot_tok += st["tokens"]; tot_chr += st["chars"]
|
| 129 |
rows.sort(key=lambda r: -r[2]["tokens"])
|
|
@@ -170,81 +166,21 @@ family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271))
|
|
| 170 |
|
| 171 |
> **v{VERSION} stable** · {tot_doc:,} documents · **{tot_tok/1e9:.2f}B tokens**
|
| 172 |
> (tiktoken proxy; canonical Llama-3 count at release) · {len(rows)} sources
|
| 173 |
-
> Updated: **{
|
| 174 |
|
| 175 |
-
> **v0.3-
|
| 176 |
-
>
|
| 177 |
-
>
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
|
| 180 |
-
> 810-document direct-ingestion sample stored under the legacy path
|
| 181 |
-
> `previews/v0.3.1/europeana.parquet`. It is not a full dataset release.
|
| 182 |
-
|
| 183 |
-
## Releases
|
| 184 |
-
|
| 185 |
-
### Stable releases
|
| 186 |
|
| 187 |
| version | status | documents | tokens | notes |
|
| 188 |
|---|---|---:|---:|---|
|
| 189 |
-
| `v0.2.
|
| 190 |
-
| `v0.2.2` | previous stable | 2,579,963 | 6.36B | Added community-contributed `govpl`: 88,190 docs / 80.7M tokens. |
|
| 191 |
-
| `v0.2.1` | previous stable | 2,491,773 | 6.28B | 12-source corpus with `license` and `author` metadata columns; added `1000_novels`. |
|
| 192 |
| `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
|
| 193 |
-
|
| 194 |
-

|
| 195 |
-
|
| 196 |
-
### Development and validation artifacts
|
| 197 |
-
|
| 198 |
-
| name | type | scope | notes |
|
| 199 |
-
|---|---|---|---|
|
| 200 |
-
| `v0.3-dev` | experimental development track | workflow and candidate audits | Quality remix, legal-source caps, source QA, deduplication and direct-upstream ingestion. Not a corpus release. |
|
| 201 |
-
| `Europeana validation artifact 2026-07-10` | reproducible sample | 810 documents / 140,042 tokens | Stored at the legacy path `previews/v0.3.1/europeana.parquet`; preserves per-record rights and creator metadata. Not a corpus release. |
|
| 202 |
-
|
| 203 |
-
### Version details
|
| 204 |
-
|
| 205 |
-
#### v0.2.3 — current stable
|
| 206 |
-
|
| 207 |
-
Community expansion release. Adds `european_hplt_v3_pl` from
|
| 208 |
-
[PR #5](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/5)
|
| 209 |
-
and `global_voices` from
|
| 210 |
-
[PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7),
|
| 211 |
-
plus `nkjp1m` from
|
| 212 |
-
[PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8).
|
| 213 |
-
The complete 16-source release contains **2,710,974 documents /
|
| 214 |
-
6,881,277,362 cl100k-proxy tokens**, summed from the released per-source parquet
|
| 215 |
-
statistics.
|
| 216 |
-
|
| 217 |
-
#### v0.2.2 — previous stable
|
| 218 |
-
|
| 219 |
-
Added `govpl` from
|
| 220 |
-
[PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9):
|
| 221 |
-
88,190 Polish government press releases collected directly from 133 gov.pl
|
| 222 |
-
ministry and agency subsites.
|
| 223 |
-
|
| 224 |
-
#### v0.2.1 — previous stable
|
| 225 |
-
|
| 226 |
-
Introduced the canonical eight-column release schema:
|
| 227 |
-
`id, text, source, added, created, token_count, license, author`. Added
|
| 228 |
-
`1000_novels` from
|
| 229 |
-
[PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1)
|
| 230 |
-
and recomputed all release statistics from parquet files.
|
| 231 |
-
|
| 232 |
-
#### v0.2.0 — initial stable corpus
|
| 233 |
-
|
| 234 |
-
The provenance-first baseline: 11 reviewed open or official sources,
|
| 235 |
-
2,490,773 documents and 6.22B proxy tokens.
|
| 236 |
-
|
| 237 |
-
#### v0.3-dev — experimental quality workflow
|
| 238 |
-
|
| 239 |
-
Candidate-only work on a better-balanced training mixture: legal-source caps,
|
| 240 |
-
temperature sampling, source QA, deduplication and direct-upstream ingestion.
|
| 241 |
-
It is not a replacement for the stable corpus.
|
| 242 |
-
|
| 243 |
-
#### Europeana validation artifact — 2026-07-10
|
| 244 |
-
|
| 245 |
-
A separate reproducible 810-document Europeana sample preserving per-record
|
| 246 |
-
rights and creator metadata. It does not change stable-release totals.
|
| 247 |
-
`v0.3.1-preview` remains only as the legacy storage-path label.
|
| 248 |
|
| 249 |
## What this dataset contributes
|
| 250 |
The raw texts come from existing open corpora (redistributed via SpeakLeash and,
|
|
@@ -269,18 +205,10 @@ as the redistributing aggregator; this release does not claim ownership of them
|
|
| 269 |
|
| 270 |
## Contributors
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
| [Paweł Puzio](https://huggingface.co/ppuzio) | Built `govpl`: subsite discovery, direct ingestion pipeline, dataset artifact, contract tests and documentation. | `v0.2.2`, [PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9) |
|
| 277 |
-
| [Arkadiusz Słota](https://huggingface.co/Maggio33) | Built `european_hplt_v3_pl`: HPLT v3 WDS 10+9 cleaning pipeline, 110,590-document artifact, validation and documentation. | `v0.2.3`, [PR #5](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/5) |
|
| 278 |
-
| [Dawid Majewski](https://huggingface.co/dawidmajewski) | Added the reviewed Global Voices Polish corpus with per-document author attribution and documentation. | `v0.2.3`, [PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7) |
|
| 279 |
-
| [1am](https://huggingface.co/1am) | Added `nkjp1m`: the manually annotated 1-million-word NKJP subcorpus, direct fetch/build pipeline, source documentation and release artifact. | `v0.2.3`, [PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8) |
|
| 280 |
-
|
| 281 |
-
Contributions are credited when they add a verifiable dataset artifact, pipeline,
|
| 282 |
-
validation, documentation or release work. A merged discussion with no resulting
|
| 283 |
-
files is not listed as a data contribution.
|
| 284 |
|
| 285 |
## Guiding principles
|
| 286 |
1. **Open & traceable licensing** — every source is *openly licensed* with a documented
|
|
@@ -333,10 +261,9 @@ Current v0.3 source-ingestion status:
|
|
| 333 |
- Europeana release policy: split conservatively at pre-1929 records for
|
| 334 |
US-sensitive downstream reuse, and keep later/unknown records separately
|
| 335 |
labeled or held until legal review.
|
| 336 |
-
- `
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
recommended before training.
|
| 340 |
|
| 341 |
Current review artifacts:
|
| 342 |
|
|
@@ -371,19 +298,23 @@ python3 src/make_docs.py
|
|
| 371 |
"""
|
| 372 |
(ROOT / "README.md").write_text(readme)
|
| 373 |
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
|
| 388 |
(ROOT / "LICENSE").write_text(
|
| 389 |
"Polish DynaWord is released under Creative Commons Attribution-ShareAlike 4.0\n"
|
|
|
|
| 13 |
from sources import SOURCES, EXCLUDED, ADDED
|
| 14 |
|
| 15 |
ROOT = Path(__file__).resolve().parent.parent
|
| 16 |
+
VERSION = "0.2.1"
|
|
|
|
| 17 |
CONTACT = "k.wikiel@gmail.com" # notice-and-takedown / data-removal requests
|
| 18 |
|
| 19 |
# Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
|
|
|
|
| 119 |
st = load_stats(name)
|
| 120 |
if not st:
|
| 121 |
print(f" ! no stats for {name}"); continue
|
| 122 |
+
(ROOT / "data" / name / f"{name}.md").write_text(datasheet(name, cfg, st))
|
|
|
|
|
|
|
|
|
|
| 123 |
rows.append((name, cfg, st))
|
| 124 |
tot_doc += st["kept"]; tot_tok += st["tokens"]; tot_chr += st["chars"]
|
| 125 |
rows.sort(key=lambda r: -r[2]["tokens"])
|
|
|
|
| 166 |
|
| 167 |
> **v{VERSION} stable** · {tot_doc:,} documents · **{tot_tok/1e9:.2f}B tokens**
|
| 168 |
> (tiktoken proxy; canonical Llama-3 count at release) · {len(rows)} sources
|
| 169 |
+
> Updated: **{ADDED}**
|
| 170 |
|
| 171 |
+
> **v0.3.0-preview in progress** · quality/diversity remix workflow, legal-style
|
| 172 |
+
> downweighting, and filtered contemporary Polish web candidates. Biblioteka
|
| 173 |
+
> Nauki and Europeana are prepared as source-ingestion PR targets with
|
| 174 |
+
> per-document `license` and `author` metadata, but they are not part of this
|
| 175 |
+
> stable parquet release yet.
|
| 176 |
|
| 177 |
+
## Versions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
| version | status | documents | tokens | notes |
|
| 180 |
|---|---|---:|---:|---|
|
| 181 |
+
| `v0.2.1` | stable release | {tot_doc:,} | {tot_tok/1e9:.2f}B | 12-source stable corpus with `license` and `author` metadata columns; adds `1000_novels`. |
|
|
|
|
|
|
|
| 182 |
| `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |
|
| 183 |
+
| `v0.3.0-preview` | workflow + candidate data in progress | candidate-only | TBD | Biblioteka Nauki, Europeana, and HPLT/Common Corpus style expansion pending per-source QA, dedup, and legal review. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
## What this dataset contributes
|
| 186 |
The raw texts come from existing open corpora (redistributed via SpeakLeash and,
|
|
|
|
| 205 |
|
| 206 |
## Contributors
|
| 207 |
|
| 208 |
+
- **Kacper Wikieł** — corpus curation, release engineering, documentation, and
|
| 209 |
+
reproducible build workflow.
|
| 210 |
+
- **Bart Kobyliński** — source expansion work for Biblioteka Nauki and Europeana,
|
| 211 |
+
including per-document license/author metadata collection and rebuild planning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
## Guiding principles
|
| 214 |
1. **Open & traceable licensing** — every source is *openly licensed* with a documented
|
|
|
|
| 261 |
- Europeana release policy: split conservatively at pre-1929 records for
|
| 262 |
US-sensitive downstream reuse, and keep later/unknown records separately
|
| 263 |
labeled or held until legal review.
|
| 264 |
+
- `ashtok897/european-hplt-v1`: candidate workflow exists, but web-crawl
|
| 265 |
+
provenance, dedup, QA, and final mix weighting are still pending before stable
|
| 266 |
+
inclusion.
|
|
|
|
| 267 |
|
| 268 |
Current review artifacts:
|
| 269 |
|
|
|
|
| 298 |
"""
|
| 299 |
(ROOT / "README.md").write_text(readme)
|
| 300 |
|
| 301 |
+
(ROOT / "CHANGELOG.md").write_text(
|
| 302 |
+
f"# Changelog\n\n## v{VERSION} ({ADDED})\n\n"
|
| 303 |
+
f"- Released a stable metadata-schema update: "
|
| 304 |
+
f"`id, text, source, added, created, token_count, license, author`.\n"
|
| 305 |
+
f"- Current release totals after parquet recount: {len(rows)} sources, "
|
| 306 |
+
f"{tot_doc:,} docs, {tot_tok/1e9:.2f}B tokens (tiktoken proxy).\n"
|
| 307 |
+
f"- Added `1000_novels` as a stable CC-BY-4.0 literature source.\n"
|
| 308 |
+
f"- Added source registry entries and PR contract for future "
|
| 309 |
+
f"`biblioteka_nauki` and `europeana` ingestion with per-document "
|
| 310 |
+
f"license/author metadata. These sources are not included in v{VERSION} "
|
| 311 |
+
f"parquets yet.\n"
|
| 312 |
+
f"- Credited Bart Kobyliński for source expansion work on Biblioteka "
|
| 313 |
+
f"Nauki and Europeana metadata/rebuild preparation.\n"
|
| 314 |
+
f"- Kept raw SpeakLeash Europeana excluded unless a direct rebuild "
|
| 315 |
+
f"preserves per-record rights metadata.\n"
|
| 316 |
+
f"- Sources: {', '.join(n for n, _, _ in rows)}.\n"
|
| 317 |
+
f"- Excluded (see README): {', '.join(EXCLUDED)}.\n")
|
| 318 |
|
| 319 |
(ROOT / "LICENSE").write_text(
|
| 320 |
"Polish DynaWord is released under Creative Commons Attribution-ShareAlike 4.0\n"
|
src/pattern_frequency_report.py
CHANGED
|
@@ -45,10 +45,7 @@ def count_patterns_for_source(parquet_path: Path) -> dict[str, int]:
|
|
| 45 |
|
| 46 |
for rg in range(pf.num_row_groups):
|
| 47 |
table = pf.read_row_group(rg, columns=["text"])
|
| 48 |
-
|
| 49 |
-
# offset limit after lower-casing. Use 64-bit string offsets before
|
| 50 |
-
# applying any text kernels so community-contributed web shards scale.
|
| 51 |
-
text = pc.cast(table["text"], "large_string")
|
| 52 |
text = pc.utf8_lower(text)
|
| 53 |
text = pc.replace_substring_regex(text, pattern="\\r?\\n", replacement=" ")
|
| 54 |
|
|
|
|
| 45 |
|
| 46 |
for rg in range(pf.num_row_groups):
|
| 47 |
table = pf.read_row_group(rg, columns=["text"])
|
| 48 |
+
text = table["text"]
|
|
|
|
|
|
|
|
|
|
| 49 |
text = pc.utf8_lower(text)
|
| 50 |
text = pc.replace_substring_regex(text, pattern="\\r?\\n", replacement=" ")
|
| 51 |
|
src/plot_version_growth.py
DELETED
|
@@ -1,66 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Plot stable Polish DynaWord corpus growth across released versions."""
|
| 3 |
-
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
|
| 6 |
-
import matplotlib.pyplot as plt
|
| 7 |
-
from matplotlib.ticker import FuncFormatter
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
ROOT = Path(__file__).resolve().parent.parent
|
| 11 |
-
OUTPUT = ROOT / "artifacts" / "dataset_size_by_version.png"
|
| 12 |
-
|
| 13 |
-
VERSIONS = ["v0.2.0", "v0.2.1", "v0.2.2", "v0.2.3"]
|
| 14 |
-
DOCUMENTS = [2_490_773, 2_491_773, 2_579_963, 2_710_974]
|
| 15 |
-
TOKENS = [6_221_393_871, 6_281_911_234, 6_362_577_363, 6_881_277_362]
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def millions(value, _position):
|
| 19 |
-
return f"{value / 1_000_000:.1f}M"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
def billions(value, _position):
|
| 23 |
-
return f"{value / 1_000_000_000:.1f}B"
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def main():
|
| 27 |
-
plt.style.use("seaborn-v0_8-whitegrid")
|
| 28 |
-
fig, axes = plt.subplots(1, 2, figsize=(12, 4.8))
|
| 29 |
-
|
| 30 |
-
panels = [
|
| 31 |
-
(axes[0], DOCUMENTS, "Documents", millions, lambda v: f"{v / 1_000_000:.3f}M", "#2563eb"),
|
| 32 |
-
(axes[1], TOKENS, "Tokens (cl100k proxy)", billions, lambda v: f"{v / 1_000_000_000:.3f}B", "#0f766e"),
|
| 33 |
-
]
|
| 34 |
-
|
| 35 |
-
for axis, values, ylabel, formatter, labeler, color in panels:
|
| 36 |
-
axis.plot(VERSIONS, values, marker="o", linewidth=2.5, color=color)
|
| 37 |
-
axis.fill_between(VERSIONS, values, alpha=0.12, color=color)
|
| 38 |
-
axis.set_ylabel(ylabel)
|
| 39 |
-
axis.yaxis.set_major_formatter(FuncFormatter(formatter))
|
| 40 |
-
axis.spines[["top", "right"]].set_visible(False)
|
| 41 |
-
axis.grid(axis="x", visible=False)
|
| 42 |
-
padding = (max(values) - min(values)) * 0.3 or max(values) * 0.02
|
| 43 |
-
axis.set_ylim(min(values) - padding, max(values) + padding)
|
| 44 |
-
|
| 45 |
-
for version, value in zip(VERSIONS, values):
|
| 46 |
-
axis.annotate(
|
| 47 |
-
labeler(value),
|
| 48 |
-
(version, value),
|
| 49 |
-
xytext=(0, 9),
|
| 50 |
-
textcoords="offset points",
|
| 51 |
-
ha="center",
|
| 52 |
-
fontsize=9,
|
| 53 |
-
fontweight="bold",
|
| 54 |
-
color=color,
|
| 55 |
-
)
|
| 56 |
-
|
| 57 |
-
fig.suptitle("Polish DynaWord — stable dataset growth by version", fontsize=15)
|
| 58 |
-
fig.tight_layout()
|
| 59 |
-
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
|
| 60 |
-
fig.savefig(OUTPUT, dpi=180, bbox_inches="tight")
|
| 61 |
-
plt.close(fig)
|
| 62 |
-
print(OUTPUT)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
if __name__ == "__main__":
|
| 66 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/sources.py
CHANGED
|
@@ -186,28 +186,6 @@ SOURCES = {
|
|
| 186 |
"created": "1918-01-01, 2025-12-31",
|
| 187 |
"is_ocr": False,
|
| 188 |
},
|
| 189 |
-
"govpl": {
|
| 190 |
-
"file_key": "govpl", # fetched directly from gov.pl, NOT via SpeakLeash
|
| 191 |
-
"pretty": "gov.pl — Polish government press releases",
|
| 192 |
-
"license": "CC-BY-SA-4.0",
|
| 193 |
-
"license_spdx": "CC-BY-SA-4.0",
|
| 194 |
-
"traceable": "All textual content on gov.pl is published under CC-BY-SA "
|
| 195 |
-
"4.0 (site footer: \"Treści tekstowe publikowane w serwisie "
|
| 196 |
-
"… są udostępniane na licencji CC BY-SA 4.0\"). Authored and "
|
| 197 |
-
"hosted by the Polish government, which holds the right to "
|
| 198 |
-
"license it — same open family as Polish Wikipedia.",
|
| 199 |
-
"upstream": "https://www.gov.pl/",
|
| 200 |
-
"provenance": "Ministry/agency press releases fetched directly from gov.pl "
|
| 201 |
-
"(editor-content per article, HTML stripped) by "
|
| 202 |
-
"src/fetch_govpl.py. Subsites + their non-uniform news-section "
|
| 203 |
-
"paths are enumerated by src/discover_govpl.py into the "
|
| 204 |
-
"committed manifest src/govpl_subsites.json (gov.pl has no "
|
| 205 |
-
"sitemap/API). Each record's meta.url resolves on gov.pl.",
|
| 206 |
-
"domain": "government",
|
| 207 |
-
# actual min/max of article dates in the fetched corpus (90,124 dated).
|
| 208 |
-
"created": "2005-09-26, 2026-07-19",
|
| 209 |
-
"is_ocr": False,
|
| 210 |
-
},
|
| 211 |
"biblioteka_nauki": {
|
| 212 |
"file_key": "biblioteka_nauki_pl_corpus",
|
| 213 |
"pretty": "Biblioteka Nauki",
|
|
@@ -251,81 +229,9 @@ SOURCES = {
|
|
| 251 |
"records should remain separately labeled or held until "
|
| 252 |
"legal review confirms their US status.",
|
| 253 |
},
|
| 254 |
-
"nkjp1m": {
|
| 255 |
-
"file_key": "nkjp1m",
|
| 256 |
-
"pretty": "The manually annotated 1-million word subcorpus of the National Corpus of Polish",
|
| 257 |
-
"license": "CC-BY",
|
| 258 |
-
"license_spdx": "CC-BY-4.0",
|
| 259 |
-
"traceable": "The NKJP download page (clip.ipipan.waw.pl) states the manually annotated 1-million-word subcorpus (Podkorpus Milionowy NKJP 1.2) is available under a CC-BY licence; attribution to the NKJP Consortium (IPI PAN) preserved. The page states 'CC-BY' with no version, normalized to CC-BY-4.0 for SPDX. The CC-BY licence covers the corpus text; NKJP's separate tools are GPL and are not included here.",
|
| 260 |
-
"upstream": "https://clip.ipipan.waw.pl/NationalCorpusOfPolish",
|
| 261 |
-
"provenance": "Downloaded the IPI PAN tarball (NKJP-PodkorpusMilionowy-1.2.tar.gz) directly by src/fetch_njkp.py, one row per TEI <div> passage (its <ab> paragraphs joined by newlines, ellipsis markers stripped). The same minimal gates as build_dynaword.py are applied per passage (drop < 200 chars, drop non-Polish by diacritic ratio, exact sha1 dedup; the OCR gate is inapplicable). Per-document 'created' is the sample's TEI publication date (<date type=\"published\">) where the header records one. Normalized into the DynaWord schema; cl100k token counts via tiktoken (encode_ordinary), and the stats are recomputed from the written parquet.",
|
| 262 |
-
"domain": "mixed (balanced reference corpus)",
|
| 263 |
-
"created": "1957-2008 (recorded for 6,581 of 18,381 documents; per-document in the created column)",
|
| 264 |
-
"is_ocr": False,
|
| 265 |
-
},
|
| 266 |
-
"european_hplt_v3_pl": {
|
| 267 |
-
"file_key": "european_hplt_v3_pl",
|
| 268 |
-
"pretty": "HPLT v3.0 Polish (web, top WDS bins 10-9)",
|
| 269 |
-
"license": "CC0-1.0",
|
| 270 |
-
"license_spdx": "CC0-1.0",
|
| 271 |
-
"traceable": "HPLT v3.0 Terms of Use license the data packaging under CC0-1.0 "
|
| 272 |
-
"(hplt-project.org/datasets/v3.0; HF card HPLT/HPLT3.0). HPLT does not "
|
| 273 |
-
"own the underlying web text; notice-and-takedown applies and downstream "
|
| 274 |
-
"legal/provenance review remains the user's responsibility.",
|
| 275 |
-
"upstream": "https://data.hplt-project.org/three/sorted/pol_Latn/",
|
| 276 |
-
"provenance": "Fetched directly from the HPLT v3 distribution (pol_Latn shards "
|
| 277 |
-
"10_1 [WDS=10] and 9_1 prefix [WDS=9]) by src/clean_hplt_v3.py, NOT via "
|
| 278 |
-
"SpeakLeash. Filtered: lang=pol_Latn + prob>=0.80, MT-prob<0.20, register "
|
| 279 |
-
"in ID/OP/HI/IN/NA, min 400 chars / 80 words, boilerplate/adult/legalish "
|
| 280 |
-
"drop, length cap 120k chars, CJK-mojibake drop, wikipedia/wikisource/"
|
| 281 |
-
"wikimedia + file-host domains excluded. Token counts via tiktoken cl100k.",
|
| 282 |
-
"domain": "web",
|
| 283 |
-
"created": "2012-01-01, 2024-12-31",
|
| 284 |
-
"is_ocr": False,
|
| 285 |
-
"legal_note": "Web-crawl derived: accept_after_web_review. HPLT is globally "
|
| 286 |
-
"deduplicated upstream and WDS quality-sorted; only top bins used. "
|
| 287 |
-
"Copyright recurs at all lengths in web crawl, so per-source near/"
|
| 288 |
-
"containment dedup vs existing sources is left to downstream per "
|
| 289 |
-
"Dynaword guidelines. Parity with the accepted european-hplt-v1 CC0 basis.",
|
| 290 |
-
},
|
| 291 |
-
"1000_novels": {
|
| 292 |
-
"speakleash_key": "1000_novels_corpus_CLARIN-PL",
|
| 293 |
-
"pretty": "1000 Novels Corpus (CLARIN-PL)",
|
| 294 |
-
"license": "CC-BY-4.0",
|
| 295 |
-
"license_spdx": "CC-BY-4.0",
|
| 296 |
-
"traceable": "The 1000 Novels Corpus is released under Creative Commons "
|
| 297 |
-
"Attribution 4.0 International by CLARIN-PL / Wrocław University "
|
| 298 |
-
"of Technology, with attribution to the corpus authors and "
|
| 299 |
-
"maintainers.",
|
| 300 |
-
"upstream": "https://clarin-pl.eu/dspace/handle/11321/312",
|
| 301 |
-
"domain": "literature",
|
| 302 |
-
"created": "unknown",
|
| 303 |
-
"is_ocr": False,
|
| 304 |
-
# Datasheet is contributor-committed (added 2026-07-02); skip regeneration
|
| 305 |
-
# so the global ADDED stamp does not overwrite the real add date.
|
| 306 |
-
"custom_datasheet": True,
|
| 307 |
-
},
|
| 308 |
-
"global_voices": {
|
| 309 |
-
# Data contributed directly (PR #7): no in-repo fetch/build script and a
|
| 310 |
-
# hand-authored datasheet. Registered for the source table + release totals;
|
| 311 |
-
# the datasheet stays contributor-owned via custom_datasheet.
|
| 312 |
-
"file_key": "global_voices",
|
| 313 |
-
"pretty": "Global Voices Polish",
|
| 314 |
-
"license": "CC-BY-3.0",
|
| 315 |
-
"license_spdx": "CC-BY-3.0",
|
| 316 |
-
"traceable": "CC BY 3.0 verified from the article-level license link published "
|
| 317 |
-
"with each retained Global Voices article; each record carries "
|
| 318 |
-
"CC-BY-3.0 metadata and per-document author/translator attribution "
|
| 319 |
-
"in global_voices.attribution.jsonl.",
|
| 320 |
-
"upstream": "https://pl.globalvoices.org/",
|
| 321 |
-
"domain": "civic media, news and public-interest journalism",
|
| 322 |
-
"created": "2008-11-04, 2023-05-24",
|
| 323 |
-
"is_ocr": False,
|
| 324 |
-
"custom_datasheet": True,
|
| 325 |
-
},
|
| 326 |
}
|
| 327 |
|
| 328 |
-
ADDED = "2026-
|
| 329 |
EXCLUDED = {
|
| 330 |
"open_subtitles_corpus": "Derivative of copyrighted film/TV dialogue; "
|
| 331 |
"OpenSubtitles uploads largely unlicensed. Same copyright lesson as "
|
|
|
|
| 186 |
"created": "1918-01-01, 2025-12-31",
|
| 187 |
"is_ocr": False,
|
| 188 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
"biblioteka_nauki": {
|
| 190 |
"file_key": "biblioteka_nauki_pl_corpus",
|
| 191 |
"pretty": "Biblioteka Nauki",
|
|
|
|
| 229 |
"records should remain separately labeled or held until "
|
| 230 |
"legal review confirms their US status.",
|
| 231 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
}
|
| 233 |
|
| 234 |
+
ADDED = "2026-06-15"
|
| 235 |
EXCLUDED = {
|
| 236 |
"open_subtitles_corpus": "Derivative of copyrighted film/TV dialogue; "
|
| 237 |
"OpenSubtitles uploads largely unlicensed. Same copyright lesson as "
|
src/test_govpl_contract.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
"""TDD contract for the direct gov.pl (press releases) ingestion path."""
|
| 2 |
-
import sys
|
| 3 |
-
import unittest
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
|
| 6 |
-
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 7 |
-
|
| 8 |
-
from discover_govpl import listing_articles, news_candidates, max_page
|
| 9 |
-
from fetch_govpl import article_body, normalize, BASE
|
| 10 |
-
|
| 11 |
-
LISTING = """
|
| 12 |
-
<div class="art-prev">
|
| 13 |
-
<div class="event"><span class="date">14.07.2026</span><span class="location">Paryż</span></div>
|
| 14 |
-
<div class="title"><a href="/web/premier/polska-gospodarzem-cwiczen">
|
| 15 |
-
Polska gospodarzem ćwiczeń</a></div>
|
| 16 |
-
<div class="intro">Lead...</div>
|
| 17 |
-
</div>
|
| 18 |
-
<div class="art-prev">
|
| 19 |
-
<div class="event"><span class="date">13.07.2026</span></div>
|
| 20 |
-
<div class="title"><a href="/web/premier/druga-wiadomosc">Druga wiadomość</a></div>
|
| 21 |
-
</div>
|
| 22 |
-
<!-- foreign link that must be ignored -->
|
| 23 |
-
<div class="title"><a href="/web/gov/menu-link">nav</a></div>
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
ARTICLE = """
|
| 27 |
-
<article>
|
| 28 |
-
<h1>Tytuł</h1>
|
| 29 |
-
<div class="editor-content"></div>
|
| 30 |
-
<div class="editor-content">
|
| 31 |
-
<p>Rada Ministrów przyjęła rozporządzenie. """ + ("Treść komunikatu. " * 20) + """</p>
|
| 32 |
-
<div class="attachments"><a href="/x">Załącznik do pobrania</a></div>
|
| 33 |
-
</div>
|
| 34 |
-
<div class="gallery"><a href="/photo/1"><span class="sr-only">Pokaż zdjęcie 1 z galerii</span></a></div>
|
| 35 |
-
</article>
|
| 36 |
-
"""
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
class GovplContractTest(unittest.TestCase):
|
| 40 |
-
def test_listing_binds_date_title_url_and_filters_foreign(self):
|
| 41 |
-
arts = listing_articles(LISTING, "premier")
|
| 42 |
-
self.assertEqual(len(arts), 2) # nav link (foreign slug) dropped
|
| 43 |
-
self.assertEqual(arts[0]["url"], "/web/premier/polska-gospodarzem-cwiczen")
|
| 44 |
-
self.assertEqual(arts[0]["date"], "14.07.2026")
|
| 45 |
-
self.assertIn("ćwiczeń", arts[0]["title"]) # entities decoded
|
| 46 |
-
self.assertEqual(arts[1]["date"], "13.07.2026")
|
| 47 |
-
|
| 48 |
-
def test_article_body_picks_richest_region_and_drops_gallery(self):
|
| 49 |
-
body = article_body(ARTICLE)
|
| 50 |
-
self.assertIn("Rada Ministrów", body)
|
| 51 |
-
self.assertNotIn("<", body) # tags stripped
|
| 52 |
-
self.assertNotIn("Pokaż zdjęcie", body) # gallery caption cut
|
| 53 |
-
self.assertNotIn("Załącznik do pobrania", body) # attachments cut
|
| 54 |
-
|
| 55 |
-
def test_normalize_schema_prepends_title_and_prefixes_url(self):
|
| 56 |
-
art = {"url": "/web/premier/x", "title": "Nagłówek", "date": "14.07.2026"}
|
| 57 |
-
row = normalize(art, ARTICLE, "premier")
|
| 58 |
-
self.assertEqual(set(row), {"text", "meta"})
|
| 59 |
-
self.assertEqual(set(row["meta"]), {"url", "subsite", "title", "date"})
|
| 60 |
-
self.assertTrue(row["text"].startswith("Nagłówek"))
|
| 61 |
-
self.assertEqual(row["meta"]["url"], BASE + "/web/premier/x")
|
| 62 |
-
self.assertEqual(row["meta"]["subsite"], "premier")
|
| 63 |
-
|
| 64 |
-
def test_thin_body_is_rejected(self):
|
| 65 |
-
thin = '<div class="editor-content"><p>Krótko.</p></div>'
|
| 66 |
-
self.assertIsNone(normalize({"url": "/web/premier/x", "title": "T"}, thin, "premier"))
|
| 67 |
-
self.assertIsNone(normalize({"url": "/web/premier/x", "title": "T"}, "", "premier"))
|
| 68 |
-
|
| 69 |
-
def test_news_candidate_detection(self):
|
| 70 |
-
landing = ('<a href="/web/arimr/aktualnosci10">n</a>'
|
| 71 |
-
'<a href="/web/arimr/wszystkie-aktualnosci">n</a>'
|
| 72 |
-
'<a href="/web/arimr/serwis-prasowy-arimr2">n</a>'
|
| 73 |
-
'<a href="/web/arimr/kontakt">x</a>'
|
| 74 |
-
'<a href="/web/arimr/informacje-o-arimr">x</a>')
|
| 75 |
-
cands = set(news_candidates(landing, "arimr"))
|
| 76 |
-
self.assertEqual(cands, {"aktualnosci10", "wszystkie-aktualnosci", "serwis-prasowy-arimr2"})
|
| 77 |
-
|
| 78 |
-
def test_max_page(self):
|
| 79 |
-
self.assertEqual(max_page('<a href="?page=2">2</a><a href="?page=294">294</a>'), 294)
|
| 80 |
-
self.assertEqual(max_page("<html>no pager</html>"), 1) # single-page listing
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
if __name__ == "__main__":
|
| 84 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/test_hplt_v3_contract.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Lokalny kontrakt-test artefaktu european_hplt_v3_pl (wzorzec: test_europeana_contract.py).
|
| 3 |
-
|
| 4 |
-
Ćwiczy inwarianty bramki merge DynaWord, które da się sprawdzić bez repo/CI:
|
| 5 |
-
canonical schema (typy+kolejność), licencja open+niepusta, brak pustego tekstu, token_count>0,
|
| 6 |
-
stats.json spójny z parquetem. NIE zastępuje `dsbench audit`/CI po stronie repo (licencja finalnie
|
| 7 |
-
podnoszona z src/sources.py — wpis MUSI być w PR).
|
| 8 |
-
"""
|
| 9 |
-
import json, sys
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
import pyarrow as pa, pyarrow.parquet as pq
|
| 12 |
-
import pyarrow.compute as pc
|
| 13 |
-
|
| 14 |
-
ROOT = Path(__file__).resolve().parent.parent
|
| 15 |
-
D = ROOT / "data" / "european_hplt_v3_pl"
|
| 16 |
-
PARQUET = D / "european_hplt_v3_pl.parquet"
|
| 17 |
-
STATS = D / "european_hplt_v3_pl.stats.json"
|
| 18 |
-
ACCEPTED = {"cc0-1.0", "cc-by-3.0", "cc-by-4.0", "cc-by-sa-3.0", "cc-by-sa-4.0",
|
| 19 |
-
"public-domain", "mit", "apache-2.0", "bsd-3-clause"}
|
| 20 |
-
CANON = ["id", "text", "source", "added", "created", "token_count", "license", "author"]
|
| 21 |
-
CANON_TYPES = {"id": "string", "text": "string", "source": "string", "added": "string",
|
| 22 |
-
"created": "string", "token_count": "int64", "license": "string", "author": "string"}
|
| 23 |
-
|
| 24 |
-
def main():
|
| 25 |
-
fails = []
|
| 26 |
-
pf = pq.ParquetFile(PARQUET)
|
| 27 |
-
sch = pf.schema_arrow
|
| 28 |
-
# 1. schema exact (order + types)
|
| 29 |
-
if sch.names != CANON:
|
| 30 |
-
fails.append(f"schema names != canonical: {sch.names}")
|
| 31 |
-
for name in CANON:
|
| 32 |
-
if name in sch.names and str(sch.field(name).type) != CANON_TYPES[name]:
|
| 33 |
-
fails.append(f"type {name}={sch.field(name).type} != {CANON_TYPES[name]}")
|
| 34 |
-
tbl = pf.read()
|
| 35 |
-
n = tbl.num_rows
|
| 36 |
-
# 2. licenses open + non-empty
|
| 37 |
-
lic = set(pc.unique(tbl["license"]).to_pylist())
|
| 38 |
-
bad = {l for l in lic if (l or "").lower() not in ACCEPTED}
|
| 39 |
-
if bad:
|
| 40 |
-
fails.append(f"non-accepted/empty licenses: {bad}")
|
| 41 |
-
# 3. no empty text
|
| 42 |
-
empty = pc.sum(pc.equal(pc.utf8_trim_whitespace(tbl["text"]), "")).as_py() or 0
|
| 43 |
-
if empty:
|
| 44 |
-
fails.append(f"empty text rows: {empty}")
|
| 45 |
-
# 4. token_count > 0
|
| 46 |
-
nonpos = pc.sum(pc.less_equal(tbl["token_count"], 0)).as_py() or 0
|
| 47 |
-
if nonpos:
|
| 48 |
-
fails.append(f"token_count<=0 rows: {nonpos}")
|
| 49 |
-
# 5. source uniform
|
| 50 |
-
srcs = set(pc.unique(tbl["source"]).to_pylist())
|
| 51 |
-
if srcs != {"european_hplt_v3_pl"}:
|
| 52 |
-
fails.append(f"source not uniform: {srcs}")
|
| 53 |
-
# 6. stats.json consistent
|
| 54 |
-
st = json.loads(STATS.read_text(encoding="utf-8"))
|
| 55 |
-
if st["kept"] != n:
|
| 56 |
-
fails.append(f"stats.kept={st['kept']} != parquet rows={n}")
|
| 57 |
-
tok_sum = pc.sum(tbl["token_count"]).as_py()
|
| 58 |
-
if st["tokens"] != tok_sum:
|
| 59 |
-
fails.append(f"stats.tokens={st['tokens']} != parquet sum={tok_sum}")
|
| 60 |
-
|
| 61 |
-
print(f"rows={n:,} tokens={tok_sum:,} licenses={lic} source={srcs}")
|
| 62 |
-
if fails:
|
| 63 |
-
print("CONTRACT FAIL:"); [print(" -", f) for f in fails]; sys.exit(1)
|
| 64 |
-
print("CONTRACT PASS (schema+license+text+token+stats invariants)")
|
| 65 |
-
|
| 66 |
-
if __name__ == "__main__":
|
| 67 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|