Update samorzad_gov_pl to de-identified upstream v0.2 (scoped from #15)
#46
by PiotrSty - opened
- data/samorzad_gov_pl/NOTICE.md +5 -4
- data/samorzad_gov_pl/samorzad_gov_pl.attribution.jsonl +2 -2
- data/samorzad_gov_pl/samorzad_gov_pl.md +48 -29
- data/samorzad_gov_pl/samorzad_gov_pl.parquet +2 -2
- data/samorzad_gov_pl/samorzad_gov_pl.stats.json +18 -14
- src/clean_samorzad_gov_pl.py +18 -8
- src/sources.py +4 -3
- src/test_samorzad_gov_pl_contract.py +13 -2
data/samorzad_gov_pl/NOTICE.md
CHANGED
|
@@ -7,8 +7,8 @@ platform.
|
|
| 7 |
The platform footer states that textual content published in the service,
|
| 8 |
excluding audiovisual content, is available under the [Creative Commons
|
| 9 |
Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)
|
| 10 |
-
license (`CC-BY-SA-4.0`). Every
|
| 11 |
-
|
| 12 |
|
| 13 |
For every released DynaWord document:
|
| 14 |
|
|
@@ -16,8 +16,9 @@ For every released DynaWord document:
|
|
| 16 |
- `samorzad_gov_pl.attribution.jsonl` preserves the discovered `source_url`,
|
| 17 |
fetched `final_url`, recommended `attribution_url`, article title,
|
| 18 |
institution, tenant identifier, license URL and modification notice;
|
| 19 |
-
- article text was extracted from source HTML
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
When redistributing or adapting these texts, retain the source attribution,
|
| 23 |
indicate changes and distribute adaptations under compatible
|
|
|
|
| 7 |
The platform footer states that textual content published in the service,
|
| 8 |
excluding audiovisual content, is available under the [Creative Commons
|
| 9 |
Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)
|
| 10 |
+
license (`CC-BY-SA-4.0`). Every page in the published v0.2 source dataset belongs
|
| 11 |
+
to the v0.1 source set for which the shared footer reference was verified.
|
| 12 |
|
| 13 |
For every released DynaWord document:
|
| 14 |
|
|
|
|
| 16 |
- `samorzad_gov_pl.attribution.jsonl` preserves the discovered `source_url`,
|
| 17 |
fetched `final_url`, recommended `attribution_url`, article title,
|
| 18 |
institution, tenant identifier, license URL and modification notice;
|
| 19 |
+
- article text was extracted from source HTML and de-identified upstream;
|
| 20 |
+
- this contribution normalizes metadata and excludes short, non-Polish or
|
| 21 |
+
duplicate records.
|
| 22 |
|
| 23 |
When redistributing or adapting these texts, retain the source attribution,
|
| 24 |
indicate changes and distribute adaptations under compatible
|
data/samorzad_gov_pl/samorzad_gov_pl.attribution.jsonl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2def7488c34e749204842bcf21d33149738b34de2515115e3f79401f7eb271c4
|
| 3 |
+
size 72438302
|
data/samorzad_gov_pl/samorzad_gov_pl.md
CHANGED
|
@@ -9,7 +9,7 @@ institutions and other public bodies.
|
|
| 9 |
## Dataset description
|
| 10 |
|
| 11 |
- **Published source dataset:** https://huggingface.co/datasets/dawidmajewski/samorzad-gov-pl-articles
|
| 12 |
-
- **Source revision:** `
|
| 13 |
- **Original platform:** https://samorzad.gov.pl/
|
| 14 |
- **Domain:** local government, education, social services and culture
|
| 15 |
- **Language:** Polish (`pl`)
|
|
@@ -21,7 +21,7 @@ institutions and other public bodies.
|
|
| 21 |
|
| 22 |
| read | kept | characters | tokens (`cl100k_base` proxy) | publishers |
|
| 23 |
|---:|---:|---:|---:|---:|
|
| 24 |
-
| 81,
|
| 25 |
|
| 26 |
The released Parquet uses the canonical DynaWord schema:
|
| 27 |
|
|
@@ -32,40 +32,56 @@ institution in `author`. The names were obtained from the `og:site_name`
|
|
| 32 |
metadata on each institution's platform homepage and frozen in
|
| 33 |
`src/samorzad_gov_pl_publishers.json`.
|
| 34 |
|
| 35 |
-
## Provenance
|
| 36 |
|
| 37 |
The source release was collected directly from public samorzad.gov.pl pages.
|
| 38 |
It contains every article URL found and successfully extracted during that
|
| 39 |
-
crawl, rather than a topical or length-selected sample.
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
DynaWord schema, applies the common minimum-length and Polish-language checks,
|
| 44 |
-
removes exact duplicate text and counts tokens with `cl100k_base`.
|
| 45 |
-
|
| 46 |
|
| 47 |
## Licensing — traceable basis and attribution
|
| 48 |
|
| 49 |
The platform's shared footer states that textual content published in the
|
| 50 |
service, excluding audiovisual content, is available under CC BY-SA 4.0. A
|
| 51 |
-
release-time audit verified the live shared footer script
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
`samorzad_gov_pl.license-evidence.json`.
|
| 55 |
|
| 56 |
The fixed DynaWord schema does not contain article titles or URLs. Therefore,
|
| 57 |
`samorzad_gov_pl.attribution.jsonl` maps every released `id` to its title,
|
| 58 |
discovered `source_url`, fetched `final_url`, recommended `attribution_url`,
|
| 59 |
publishing institution, platform tenant, license URL and modification notice.
|
| 60 |
-
For
|
| 61 |
platform redirected the request; `attribution_url` uses the fetched final URL.
|
| 62 |
|
| 63 |
Recommended attribution:
|
| 64 |
|
| 65 |
> Publishing institution listed in the `author` column; article title and
|
| 66 |
> canonical samorzad.gov.pl URL from the attribution sidecar; CC BY-SA 4.0.
|
| 67 |
-
> Article text was extracted from HTML
|
| 68 |
-
> DynaWord.
|
| 69 |
|
| 70 |
Photographs, recordings, videos and attachment bytes are not redistributed.
|
| 71 |
The source platform gives audiovisual materials separate terms, and linked
|
|
@@ -76,11 +92,11 @@ not redistribute those files.
|
|
| 76 |
|
| 77 |
| result | documents |
|
| 78 |
|---|---:|
|
| 79 |
-
| source records read | 81,
|
| 80 |
-
| shorter than 200 characters | 6,
|
| 81 |
-
| below the Polish-language heuristic |
|
| 82 |
-
| exact duplicate text | 1,
|
| 83 |
-
| retained | 72,
|
| 84 |
|
| 85 |
Exact duplicate removal is performed after short-text and language checks.
|
| 86 |
Existing DynaWord sources take priority when the same text is already present
|
|
@@ -88,11 +104,13 @@ elsewhere in the corpus.
|
|
| 88 |
|
| 89 |
## Limitations and recommended use
|
| 90 |
|
|
|
|
|
|
|
|
|
|
| 91 |
- The collection is not a complete historical archive of samorzad.gov.pl. It
|
| 92 |
contains the pages found and successfully extracted during one crawl.
|
| 93 |
-
-
|
| 94 |
-
|
| 95 |
-
inferred for them.
|
| 96 |
- The source text can contain spelling errors, extraction remnants or captions.
|
| 97 |
- Very short source records are excluded by DynaWord's 200-character minimum.
|
| 98 |
- Institution names describe the publishing body, not necessarily the person
|
|
@@ -112,18 +130,19 @@ elsewhere in the corpus.
|
|
| 112 |
## Reproduction
|
| 113 |
|
| 114 |
The converter refuses to build unless the downloaded `manifest.json` and all
|
| 115 |
-
10 Parquet shards match the pinned release. It verifies the manifest
|
| 116 |
-
artifact set, shard sizes and SHA-256 values, row counts, schema,
|
| 117 |
-
IDs and the release-wide record-text digest before conversion.
|
| 118 |
-
written to temporary files, cross-checked, synced and
|
| 119 |
-
a failed replacement restores the previous artifact
|
|
|
|
| 120 |
|
| 121 |
Download the published source Parquet shards and run:
|
| 122 |
|
| 123 |
```bash
|
| 124 |
hf download dawidmajewski/samorzad-gov-pl-articles \
|
| 125 |
--repo-type dataset \
|
| 126 |
-
--revision
|
| 127 |
--include 'data/*.parquet' --include manifest.json \
|
| 128 |
--local-dir /tmp/samorzad-gov-pl-articles
|
| 129 |
|
|
|
|
| 9 |
## Dataset description
|
| 10 |
|
| 11 |
- **Published source dataset:** https://huggingface.co/datasets/dawidmajewski/samorzad-gov-pl-articles
|
| 12 |
+
- **Source revision:** `a998efea84bb0a62d94effc0b54f88b422d9898f` (`v0.2`)
|
| 13 |
- **Original platform:** https://samorzad.gov.pl/
|
| 14 |
- **Domain:** local government, education, social services and culture
|
| 15 |
- **Language:** Polish (`pl`)
|
|
|
|
| 21 |
|
| 22 |
| read | kept | characters | tokens (`cl100k_base` proxy) | publishers |
|
| 23 |
|---:|---:|---:|---:|---:|
|
| 24 |
+
| 81,418 | 72,472 | 107,130,266 | 40,011,099 | 247 |
|
| 25 |
|
| 26 |
The released Parquet uses the canonical DynaWord schema:
|
| 27 |
|
|
|
|
| 32 |
metadata on each institution's platform homepage and frozen in
|
| 33 |
`src/samorzad_gov_pl_publishers.json`.
|
| 34 |
|
| 35 |
+
## Provenance and de-identification
|
| 36 |
|
| 37 |
The source release was collected directly from public samorzad.gov.pl pages.
|
| 38 |
It contains every article URL found and successfully extracted during that
|
| 39 |
+
crawl, rather than a topical or length-selected sample. Its v0.2 release
|
| 40 |
+
contains 81,418 articles from 247 institutions after four corrupted source
|
| 41 |
+
records were excluded.
|
| 42 |
+
|
| 43 |
+
Consumer-facing text was de-identified upstream before conversion to DynaWord.
|
| 44 |
+
Names were detected with the pinned Polish PII model
|
| 45 |
+
[`ArkadiuszPawlak/fastpdn-ner-polish-pii`](https://huggingface.co/ArkadiuszPawlak/fastpdn-ner-polish-pii)
|
| 46 |
+
at revision `636c57fe77b0afad8f065e7c76243dc051437035`. Deterministic
|
| 47 |
+
rules and checksum validation covered structured identifiers and contact data.
|
| 48 |
+
Removed values were replaced by typed placeholders such as `<PERSON>`,
|
| 49 |
+
`<PHONE>`, `<EMAIL>` and `<URL>`.
|
| 50 |
+
|
| 51 |
+
The upstream release audit scanned all 81,418 records for structured residuals,
|
| 52 |
+
reran the PERSON model on an evenly spaced 1,000-record sample, validated
|
| 53 |
+
placeholder structure, verified the 10 Parquet files by size and SHA-256, and
|
| 54 |
+
checked record provenance against the pinned source manifest. All required
|
| 55 |
+
release gates passed.
|
| 56 |
+
|
| 57 |
+
`src/clean_samorzad_gov_pl.py` verifies and converts the v0.2 Parquets into the
|
| 58 |
DynaWord schema, applies the common minimum-length and Polish-language checks,
|
| 59 |
+
removes exact duplicate text and counts tokens with `cl100k_base`. Retained text
|
| 60 |
+
is otherwise unchanged after upstream de-identification.
|
| 61 |
|
| 62 |
## Licensing — traceable basis and attribution
|
| 63 |
|
| 64 |
The platform's shared footer states that textual content published in the
|
| 65 |
service, excluding audiovisual content, is available under CC BY-SA 4.0. A
|
| 66 |
+
release-time audit verified the live shared footer script for all 81,422 pages
|
| 67 |
+
in the v0.1 source set. The four records omitted from v0.2 were a subset of that
|
| 68 |
+
audited set, so every v0.2 article remains covered by the same evidence. The
|
| 69 |
+
evidence URL, byte count and SHA-256 digest are recorded in
|
| 70 |
`samorzad_gov_pl.license-evidence.json`.
|
| 71 |
|
| 72 |
The fixed DynaWord schema does not contain article titles or URLs. Therefore,
|
| 73 |
`samorzad_gov_pl.attribution.jsonl` maps every released `id` to its title,
|
| 74 |
discovered `source_url`, fetched `final_url`, recommended `attribution_url`,
|
| 75 |
publishing institution, platform tenant, license URL and modification notice.
|
| 76 |
+
For 688 retained records the discovered and final URLs differ because the
|
| 77 |
platform redirected the request; `attribution_url` uses the fetched final URL.
|
| 78 |
|
| 79 |
Recommended attribution:
|
| 80 |
|
| 81 |
> Publishing institution listed in the `author` column; article title and
|
| 82 |
> canonical samorzad.gov.pl URL from the attribution sidecar; CC BY-SA 4.0.
|
| 83 |
+
> Article text was extracted from HTML, de-identified upstream and normalized
|
| 84 |
+
> for inclusion in Polish DynaWord.
|
| 85 |
|
| 86 |
Photographs, recordings, videos and attachment bytes are not redistributed.
|
| 87 |
The source platform gives audiovisual materials separate terms, and linked
|
|
|
|
| 92 |
|
| 93 |
| result | documents |
|
| 94 |
|---|---:|
|
| 95 |
+
| source records read | 81,418 |
|
| 96 |
+
| shorter than 200 characters | 6,932 |
|
| 97 |
+
| below the Polish-language heuristic | 34 |
|
| 98 |
+
| exact duplicate text | 1,980 |
|
| 99 |
+
| retained | 72,472 |
|
| 100 |
|
| 101 |
Exact duplicate removal is performed after short-text and language checks.
|
| 102 |
Existing DynaWord sources take priority when the same text is already present
|
|
|
|
| 104 |
|
| 105 |
## Limitations and recommended use
|
| 106 |
|
| 107 |
+
- Automated de-identification reduces but cannot guarantee removal of every
|
| 108 |
+
identifying value; downstream users should apply controls appropriate to
|
| 109 |
+
their use case.
|
| 110 |
- The collection is not a complete historical archive of samorzad.gov.pl. It
|
| 111 |
contains the pages found and successfully extracted during one crawl.
|
| 112 |
+
- After filtering, 51,964 retained records have an empty `created` value; no
|
| 113 |
+
date is inferred for them.
|
|
|
|
| 114 |
- The source text can contain spelling errors, extraction remnants or captions.
|
| 115 |
- Very short source records are excluded by DynaWord's 200-character minimum.
|
| 116 |
- Institution names describe the publishing body, not necessarily the person
|
|
|
|
| 130 |
## Reproduction
|
| 131 |
|
| 132 |
The converter refuses to build unless the downloaded `manifest.json` and all
|
| 133 |
+
10 Parquet shards match the pinned v0.2 release. It verifies the manifest
|
| 134 |
+
SHA-256, artifact set, shard sizes and SHA-256 values, row counts, schema,
|
| 135 |
+
unique record IDs and the release-wide record-text digest before conversion.
|
| 136 |
+
Outputs are written to temporary files, cross-checked, synced and
|
| 137 |
+
transactionally replaced; a failed replacement restores the previous artifact
|
| 138 |
+
set.
|
| 139 |
|
| 140 |
Download the published source Parquet shards and run:
|
| 141 |
|
| 142 |
```bash
|
| 143 |
hf download dawidmajewski/samorzad-gov-pl-articles \
|
| 144 |
--repo-type dataset \
|
| 145 |
+
--revision a998efea84bb0a62d94effc0b54f88b422d9898f \
|
| 146 |
--include 'data/*.parquet' --include manifest.json \
|
| 147 |
--local-dir /tmp/samorzad-gov-pl-articles
|
| 148 |
|
data/samorzad_gov_pl/samorzad_gov_pl.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a683b4220b9b70698d7c524637d9ea5c1d72630b8f92ea7a871642a719cf2c0
|
| 3 |
+
size 49612214
|
data/samorzad_gov_pl/samorzad_gov_pl.stats.json
CHANGED
|
@@ -1,25 +1,29 @@
|
|
| 1 |
{
|
| 2 |
-
"authors_with_value":
|
| 3 |
"central_tenant_count": 1,
|
| 4 |
-
"chars":
|
| 5 |
-
"cross_source_hashes_loaded":
|
| 6 |
-
"drop_dup":
|
| 7 |
-
"drop_lang":
|
| 8 |
"drop_ocr": 0,
|
| 9 |
-
"drop_short":
|
| 10 |
-
"kept":
|
| 11 |
"license": "CC-BY-SA-4.0",
|
| 12 |
"licenses": {
|
| 13 |
-
"CC-BY-SA-4.0":
|
| 14 |
},
|
| 15 |
"local_public_tenant_count": 246,
|
| 16 |
"publisher_count": 247,
|
| 17 |
-
"read":
|
| 18 |
-
"redirected_urls":
|
| 19 |
-
"tokens":
|
| 20 |
"upstream_artifact_count": 10,
|
| 21 |
"upstream_dataset": "dawidmajewski/samorzad-gov-pl-articles",
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"authors_with_value": 72472,
|
| 3 |
"central_tenant_count": 1,
|
| 4 |
+
"chars": 107130266,
|
| 5 |
+
"cross_source_hashes_loaded": 4255011,
|
| 6 |
+
"drop_dup": 1980,
|
| 7 |
+
"drop_lang": 34,
|
| 8 |
"drop_ocr": 0,
|
| 9 |
+
"drop_short": 6932,
|
| 10 |
+
"kept": 72472,
|
| 11 |
"license": "CC-BY-SA-4.0",
|
| 12 |
"licenses": {
|
| 13 |
+
"CC-BY-SA-4.0": 72472
|
| 14 |
},
|
| 15 |
"local_public_tenant_count": 246,
|
| 16 |
"publisher_count": 247,
|
| 17 |
+
"read": 81418,
|
| 18 |
+
"redirected_urls": 688,
|
| 19 |
+
"tokens": 40011099,
|
| 20 |
"upstream_artifact_count": 10,
|
| 21 |
"upstream_dataset": "dawidmajewski/samorzad-gov-pl-articles",
|
| 22 |
+
"upstream_deidentification_model": "ArkadiuszPawlak/fastpdn-ner-polish-pii",
|
| 23 |
+
"upstream_deidentification_model_revision": "636c57fe77b0afad8f065e7c76243dc051437035",
|
| 24 |
+
"upstream_deidentification_policy": "samorzad-pii-v3",
|
| 25 |
+
"upstream_manifest_sha256": "9d349bb271033fef62a051e311115460e030740f9593bb7f3158cb1437f87639",
|
| 26 |
+
"upstream_record_text_sha256": "9378f130ce26fc95015f661910e660f8bbe6442e75640089185f78052533377d",
|
| 27 |
+
"upstream_revision": "a998efea84bb0a62d94effc0b54f88b422d9898f",
|
| 28 |
+
"upstream_source_quality_excluded_records": 4
|
| 29 |
}
|
src/clean_samorzad_gov_pl.py
CHANGED
|
@@ -29,14 +29,14 @@ SOURCE = "samorzad_gov_pl"
|
|
| 29 |
LICENSE = "CC-BY-SA-4.0"
|
| 30 |
LICENSE_URL = "https://creativecommons.org/licenses/by-sa/4.0/"
|
| 31 |
UPSTREAM_DATASET = "dawidmajewski/samorzad-gov-pl-articles"
|
| 32 |
-
UPSTREAM_REVISION = "
|
| 33 |
-
UPSTREAM_TEXT_SHA256 = "
|
| 34 |
-
UPSTREAM_MANIFEST_SHA256 = "
|
| 35 |
UPSTREAM_EXPECTED = {
|
| 36 |
"manifest_sha256": UPSTREAM_MANIFEST_SHA256,
|
| 37 |
"dataset_id": UPSTREAM_DATASET,
|
| 38 |
"schema_version": "1.0.0",
|
| 39 |
-
"record_count":
|
| 40 |
"record_text_sha256": UPSTREAM_TEXT_SHA256,
|
| 41 |
}
|
| 42 |
MIN_CHARS = 200
|
|
@@ -251,9 +251,10 @@ def normalize_record(
|
|
| 251 |
"license_url": LICENSE_URL,
|
| 252 |
"modified": True,
|
| 253 |
"modification_notice": (
|
| 254 |
-
"Article text was extracted from the source HTML
|
| 255 |
-
"release normalizes metadata and may exclude
|
| 256 |
-
"duplicate records;
|
|
|
|
| 257 |
),
|
| 258 |
}
|
| 259 |
return row, attribution
|
|
@@ -281,7 +282,7 @@ def existing_text_hashes(repo_root: Path, output_path: Path) -> set[bytes]:
|
|
| 281 |
|
| 282 |
|
| 283 |
def _fsync_path(path: Path) -> None:
|
| 284 |
-
with path.open("rb") as handle:
|
| 285 |
os.fsync(handle.fileno())
|
| 286 |
|
| 287 |
|
|
@@ -394,6 +395,7 @@ def build(
|
|
| 394 |
seen = set(prior_hashes)
|
| 395 |
|
| 396 |
candidates: list[dict] = []
|
|
|
|
| 397 |
stats = {
|
| 398 |
"read": len(records),
|
| 399 |
"kept": 0,
|
|
@@ -420,6 +422,14 @@ def build(
|
|
| 420 |
"upstream_record_text_sha256": UPSTREAM_TEXT_SHA256,
|
| 421 |
"upstream_manifest_sha256": hashlib.sha256(manifest_path.read_bytes()).hexdigest(),
|
| 422 |
"upstream_artifact_count": len(manifest["artifacts"]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
}
|
| 424 |
for record in records:
|
| 425 |
text = str(record.get("text") or "").strip()
|
|
|
|
| 29 |
LICENSE = "CC-BY-SA-4.0"
|
| 30 |
LICENSE_URL = "https://creativecommons.org/licenses/by-sa/4.0/"
|
| 31 |
UPSTREAM_DATASET = "dawidmajewski/samorzad-gov-pl-articles"
|
| 32 |
+
UPSTREAM_REVISION = "a998efea84bb0a62d94effc0b54f88b422d9898f"
|
| 33 |
+
UPSTREAM_TEXT_SHA256 = "9378f130ce26fc95015f661910e660f8bbe6442e75640089185f78052533377d"
|
| 34 |
+
UPSTREAM_MANIFEST_SHA256 = "9d349bb271033fef62a051e311115460e030740f9593bb7f3158cb1437f87639"
|
| 35 |
UPSTREAM_EXPECTED = {
|
| 36 |
"manifest_sha256": UPSTREAM_MANIFEST_SHA256,
|
| 37 |
"dataset_id": UPSTREAM_DATASET,
|
| 38 |
"schema_version": "1.0.0",
|
| 39 |
+
"record_count": 81_418,
|
| 40 |
"record_text_sha256": UPSTREAM_TEXT_SHA256,
|
| 41 |
}
|
| 42 |
MIN_CHARS = 200
|
|
|
|
| 251 |
"license_url": LICENSE_URL,
|
| 252 |
"modified": True,
|
| 253 |
"modification_notice": (
|
| 254 |
+
"Article text was extracted from the source HTML and de-identified "
|
| 255 |
+
"upstream. This DynaWord release normalizes metadata and may exclude "
|
| 256 |
+
"short, non-Polish or duplicate records; retained text is otherwise "
|
| 257 |
+
"unchanged after upstream de-identification."
|
| 258 |
),
|
| 259 |
}
|
| 260 |
return row, attribution
|
|
|
|
| 282 |
|
| 283 |
|
| 284 |
def _fsync_path(path: Path) -> None:
|
| 285 |
+
with path.open("rb+") as handle:
|
| 286 |
os.fsync(handle.fileno())
|
| 287 |
|
| 288 |
|
|
|
|
| 395 |
seen = set(prior_hashes)
|
| 396 |
|
| 397 |
candidates: list[dict] = []
|
| 398 |
+
metadata = manifest["dataset_metadata"]
|
| 399 |
stats = {
|
| 400 |
"read": len(records),
|
| 401 |
"kept": 0,
|
|
|
|
| 422 |
"upstream_record_text_sha256": UPSTREAM_TEXT_SHA256,
|
| 423 |
"upstream_manifest_sha256": hashlib.sha256(manifest_path.read_bytes()).hexdigest(),
|
| 424 |
"upstream_artifact_count": len(manifest["artifacts"]),
|
| 425 |
+
"upstream_deidentification_model": metadata["deidentification_model"],
|
| 426 |
+
"upstream_deidentification_model_revision": metadata[
|
| 427 |
+
"deidentification_model_revision"
|
| 428 |
+
],
|
| 429 |
+
"upstream_deidentification_policy": metadata["deidentification_policy"],
|
| 430 |
+
"upstream_source_quality_excluded_records": metadata[
|
| 431 |
+
"source_quality_excluded_records"
|
| 432 |
+
],
|
| 433 |
}
|
| 434 |
for record in records:
|
| 435 |
text = str(record.get("text") or "").strip()
|
src/sources.py
CHANGED
|
@@ -331,12 +331,13 @@ SOURCES = {
|
|
| 331 |
"license": "CC-BY-SA-4.0",
|
| 332 |
"license_spdx": "CC-BY-SA-4.0",
|
| 333 |
"traceable": "The shared samorzad.gov.pl platform footer publishes textual "
|
| 334 |
-
"content under CC BY-SA 4.0.
|
|
|
|
| 335 |
"referenced the shared footer script; audiovisual media and "
|
| 336 |
"attachment bytes are not redistributed.",
|
| 337 |
"upstream": "https://huggingface.co/datasets/dawidmajewski/samorzad-gov-pl-articles",
|
| 338 |
-
"provenance": "Converted reproducibly from the published v0.
|
| 339 |
-
"by src/clean_samorzad_gov_pl.py. The source was collected "
|
| 340 |
"directly from public samorzad.gov.pl pages across 246 local "
|
| 341 |
"public institutions and one central platform tenant. "
|
| 342 |
"Institution display names are frozen "
|
|
|
|
| 331 |
"license": "CC-BY-SA-4.0",
|
| 332 |
"license_spdx": "CC-BY-SA-4.0",
|
| 333 |
"traceable": "The shared samorzad.gov.pl platform footer publishes textual "
|
| 334 |
+
"content under CC BY-SA 4.0. The v0.2 source release is a "
|
| 335 |
+
"de-identified subset of the audited v0.1 pages, all of which "
|
| 336 |
"referenced the shared footer script; audiovisual media and "
|
| 337 |
"attachment bytes are not redistributed.",
|
| 338 |
"upstream": "https://huggingface.co/datasets/dawidmajewski/samorzad-gov-pl-articles",
|
| 339 |
+
"provenance": "Converted reproducibly from the published, de-identified v0.2 "
|
| 340 |
+
"source dataset by src/clean_samorzad_gov_pl.py. The source was collected "
|
| 341 |
"directly from public samorzad.gov.pl pages across 246 local "
|
| 342 |
"public institutions and one central platform tenant. "
|
| 343 |
"Institution display names are frozen "
|
src/test_samorzad_gov_pl_contract.py
CHANGED
|
@@ -73,6 +73,7 @@ def test_normalize_record_maps_publisher_to_author_and_preserves_provenance():
|
|
| 73 |
assert attribution["title"] == source["title"]
|
| 74 |
assert attribution["license_url"] == "https://creativecommons.org/licenses/by-sa/4.0/"
|
| 75 |
assert attribution["modified"] is True
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
def test_verify_upstream_release_rejects_modified_shard(tmp_path):
|
|
@@ -183,14 +184,24 @@ def test_release_artifact_matches_stats_and_has_institution_authors():
|
|
| 183 |
|
| 184 |
assert table.schema == DYNAWORD_SCHEMA
|
| 185 |
assert table.num_rows == stats["kept"] == len(attributions)
|
|
|
|
|
|
|
| 186 |
assert stats["authors_with_value"] == stats["kept"]
|
| 187 |
assert stats["publisher_count"] == 247
|
| 188 |
assert stats["local_public_tenant_count"] == 246
|
| 189 |
assert stats["central_tenant_count"] == 1
|
| 190 |
-
assert stats["redirected_urls"] ==
|
| 191 |
assert stats["upstream_artifact_count"] == 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
assert stats["upstream_manifest_sha256"] == (
|
| 193 |
-
"
|
| 194 |
)
|
| 195 |
assert set(table["source"].to_pylist()) == {"samorzad_gov_pl"}
|
| 196 |
assert set(table["license"].to_pylist()) == {"CC-BY-SA-4.0"}
|
|
|
|
| 73 |
assert attribution["title"] == source["title"]
|
| 74 |
assert attribution["license_url"] == "https://creativecommons.org/licenses/by-sa/4.0/"
|
| 75 |
assert attribution["modified"] is True
|
| 76 |
+
assert "de-identified upstream" in attribution["modification_notice"]
|
| 77 |
|
| 78 |
|
| 79 |
def test_verify_upstream_release_rejects_modified_shard(tmp_path):
|
|
|
|
| 184 |
|
| 185 |
assert table.schema == DYNAWORD_SCHEMA
|
| 186 |
assert table.num_rows == stats["kept"] == len(attributions)
|
| 187 |
+
assert stats["read"] == 81_418
|
| 188 |
+
assert stats["kept"] == 72_472
|
| 189 |
assert stats["authors_with_value"] == stats["kept"]
|
| 190 |
assert stats["publisher_count"] == 247
|
| 191 |
assert stats["local_public_tenant_count"] == 246
|
| 192 |
assert stats["central_tenant_count"] == 1
|
| 193 |
+
assert stats["redirected_urls"] == 688
|
| 194 |
assert stats["upstream_artifact_count"] == 10
|
| 195 |
+
assert stats["upstream_deidentification_model"] == (
|
| 196 |
+
"ArkadiuszPawlak/fastpdn-ner-polish-pii"
|
| 197 |
+
)
|
| 198 |
+
assert stats["upstream_deidentification_model_revision"] == (
|
| 199 |
+
"636c57fe77b0afad8f065e7c76243dc051437035"
|
| 200 |
+
)
|
| 201 |
+
assert stats["upstream_deidentification_policy"] == "samorzad-pii-v3"
|
| 202 |
+
assert stats["upstream_source_quality_excluded_records"] == 4
|
| 203 |
assert stats["upstream_manifest_sha256"] == (
|
| 204 |
+
"9d349bb271033fef62a051e311115460e030740f9593bb7f3158cb1437f87639"
|
| 205 |
)
|
| 206 |
assert set(table["source"].to_pylist()) == {"samorzad_gov_pl"}
|
| 207 |
assert set(table["license"].to_pylist()) == {"CC-BY-SA-4.0"}
|