ppuzio commited on
Commit
262df1b
·
1 Parent(s): 312a6c4

eurlex: relabel to LicenseRef-EU-Reuse-Policy, report third-party (IASB) material (#71)

Browse files

- eurlex: relabel to LicenseRef-EU-Reuse-Policy, report third-party (IASB) material (d006339fd5f8a157e4da378978423a7b36f329cc)

artifacts/source_findings.md CHANGED
@@ -1927,3 +1927,57 @@ clause does not change a label here. Evidence in `data/wikinews/wikinews.license
1927
  **Blockers** — none to merge. Open: lawyer on the 2.5 → 4.0 label and on E1; the 2 boundary
1928
  documents; copyright pastes in news text (the audit's 100-document press-copying sample was
1929
  not run); the markup residue above.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1927
  **Blockers** — none to merge. Open: lawyer on the 2.5 → 4.0 label and on E1; the 2 boundary
1928
  documents; copyright pastes in news text (the audit's 100-document press-copying sample was
1929
  not run); the markup residue above.
1930
+
1931
+ ## eurlex — relabelled to the EU reuse policy, third-party material reported (2026-10-06)
1932
+
1933
+ **Investigated** — 2026-10-06 (October 2026 rights audit, polish-dynaword-v2 #57; lawyer
1934
+ question #56 B5; `rights_audit_2026-10/reports/citations.md`).
1935
+
1936
+ **Verdict** — kept and relabelled, nothing dropped: 243,060 documents, 5,976,949,249
1937
+ characters, 2,378,055,718 tokens before and after. `CC-BY-4.0` becomes
1938
+ `LicenseRef-EU-Reuse-Policy` in the per-row `license` column, the registry and the card,
1939
+ by `src/clean_eurlex.py` (tested in `src/test_eurlex_contract.py`; all other columns are
1940
+ identical). The Polish Copyright Act Art. 4 basis is removed from the card.
1941
+
1942
+ **License evidence** — verified, read 2026-10-06: the EUR-Lex legal notice
1943
+ (<https://eur-lex.europa.eu/content/legal-notice/legal-notice.html>, sha256 `7994b96f…`)
1944
+ bases the Commission's reuse policy on Decision 2011/833/EU and allows re-use of the legal
1945
+ documents published in EUR-Lex "unless otherwise specified". Its CC BY 4.0 grant covers
1946
+ only the website's editorial content, summaries of EU legislation and consolidated texts,
1947
+ so a corpus-wide CC-BY-4.0 label overstated the grant. Decision 2011/833/EU
1948
+ (<https://eur-lex.europa.eu/eli/dec/2011/833/oj/eng>, "In force", sha256 `1e867b79…`):
1949
+ Art. 4 reuse for commercial and non-commercial purposes, Art. 6(2) source
1950
+ acknowledgement and no distortion, Art. 2(2)(a)-(b) and recital 14 exclusions. Inferred:
1951
+ the Decision covers Commission documents, so acts of other institutions (Council,
1952
+ Parliament, ECB, EESC, CJEU) rest on the notice's general sentence. Evidence in
1953
+ `data/eurlex/eurlex.license-evidence.json`.
1954
+
1955
+ **Third-party check** — report only (`python3 src/clean_eurlex.py --scan`):
1956
+ - 92 documents (74.1M characters, 1.24%) contain the IASB notice: reproduction allowed in
1957
+ the EEA, all rights reserved outside it. They are 64 OJ acts adopting or amending
1958
+ IAS/IFRS and 28 consolidated versions (20 of Regulation 1126/2008). The notice is the
1959
+ "special conditions of use" the legal notice names for the International Accounting
1960
+ Standards. All 92 matched lines and all 64 titles hand-checked. Two more documents have
1961
+ a standard title line without the notice (67,283 characters) and were not counted.
1962
+ - 97 documents contain a (c) sign; 33 are third-party credits or short data citations
1963
+ (photographs, maps, OECD, IHS Markit, McKinsey, Springer), 25 EU credits, 7 binary
1964
+ garbage, 32 glyph noise or list markers. Labelled by reading the first occurrence in
1965
+ each; the credited images are not in the text.
1966
+ - Header patterns: ECB acts 1,414 documents (1.00% of characters), EESC 5,154 (2.16%),
1967
+ state aid `SA.nnnnn` 2,941 (1.26%), UN ECE regulations 253 (0.39%). These are EU-body or
1968
+ Commission texts, not third-party under the notice; they matter only if those bodies'
1969
+ reuse terms differ. The audit's rough shares (ECB ~4%, state aid ~2.5%) do not
1970
+ reproduce with these patterns.
1971
+ - No large-scale reproduction of non-EU copyrighted works was found. Recall for third-party
1972
+ text the patterns do not target is unknown.
1973
+
1974
+ **Blockers** — none to merge. Open decision for the maintainer: keep the 92 IASB-notice
1975
+ documents (the notice reserves rights outside the EEA, and the Hub is not EEA-limited) or
1976
+ drop them. Ids are in `data/eurlex/eurlex.third-party-scan.json`.
1977
+
1978
+ **Not established** — SpeakLeash's terms for `eurlex_corpus`; whether the ECB, EESC,
1979
+ Council, Parliament and the Court of Justice publish reuse terms of their own; the
1980
+ Publications Office's position on non-Commission documents (lawyer question, #56 B5).
1981
+
1982
+ **Lesson** — a reuse policy is not a Creative Commons licence: copy the clause, not the
1983
+ label, and read what the grant covers before using its name.
data/eurlex/eurlex.license-evidence.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source": "eurlex",
3
+ "status": "reviewed-reuse-policy-with-third-party-exclusions",
4
+ "reviewed_at": "2026-10-06",
5
+ "label": "LicenseRef-EU-Reuse-Policy",
6
+ "previous_label": "CC-BY-4.0",
7
+ "issue": "slayerlabs/polish-dynaword-v2#57 (lawyer question: #56 B5)",
8
+ "reuse_basis": {
9
+ "documents": [
10
+ {
11
+ "role": "EUR-Lex legal notice",
12
+ "url": "https://eur-lex.europa.eu/content/legal-notice/legal-notice.html",
13
+ "retrieved_at": "2026-10-06T01:37+02:00",
14
+ "bytes": 135286,
15
+ "sha256": "7994b96f400239cda9061a64f781c75cf927637cf29320402a4ffce6d71f3857",
16
+ "note": "sha256 of the HTML as fetched; the page footer carries the current year, so a later fetch hashes differently",
17
+ "clauses": {
18
+ "reuse_policy": "Copyright notice: 'The Commission's document reuse policy is based on Decision 2011/833/EU.' Unless otherwise specified, the legal documents published in EUR-Lex may be re-used for commercial or non-commercial purposes.",
19
+ "special_conditions": "Copyright notice: 'Some documents, like the International Accounting Standards, may be subject to special conditions of use'; they are mentioned in the respective Official Journal/document.",
20
+ "cc_by_4_scope": "Copyright notice: CC BY 4.0 covers the editorial content of the website, the summaries of EU legislation and the consolidated texts, with source acknowledgement and indication of changes.",
21
+ "third_party": "Copyright notice: additional rights may need clearing where content includes third-party works; content not owned by the EU may need permission from the rights holders.",
22
+ "industrial_property": "Copyright notice: software or documents covered by industrial property rights (patents, trademarks, registered designs, logos, names) are excluded from the reuse policy.",
23
+ "metadata": "Copyright notice: EUR-Lex metadata is CC0 1.0 (not used here)."
24
+ }
25
+ },
26
+ {
27
+ "role": "Commission Decision 2011/833/EU of 12 December 2011 on the reuse of Commission documents",
28
+ "url": "https://eur-lex.europa.eu/eli/dec/2011/833/oj/eng",
29
+ "retrieved_at": "2026-10-06T01:37+02:00",
30
+ "bytes": 314528,
31
+ "sha256": "1e867b79d32ed7078175705668e48f64c2850fa15a26ff761f4dc080514e69e8",
32
+ "status_on_page": "In force",
33
+ "clauses": {
34
+ "art_1_2_1_scope": "Documents held by the Commission, or on its behalf by the Publications Office, produced by the Commission or entities acting on its behalf.",
35
+ "recital_14": "The Decision does not apply to documents the Commission cannot allow to be reused, e.g. third-party intellectual property rights or documents received from the other Institutions.",
36
+ "art_2_2_a": "Not applicable to software or documents covered by industrial property rights.",
37
+ "art_2_2_b": "Not applicable to documents the Commission cannot license in view of third-party intellectual property rights.",
38
+ "art_4": "General principle: documents available for reuse for commercial or non-commercial purposes under Art. 6, without charge, without individual application.",
39
+ "art_6_2": "Permitted conditions: (a) acknowledge the source, (b) do not distort the original meaning or message, (c) non-liability of the Commission."
40
+ }
41
+ }
42
+ ],
43
+ "not_relied_on": "Polish Copyright Act Art. 4: it concerns Polish official documents, not EU acts. The v0.2.5 card cited it; removed.",
44
+ "limit": "Decision 2011/833/EU applies to Commission documents. Acts of other institutions (Council, Parliament, ECB, EESC, CJEU) in the corpus rest on the notice's general sentence about legal documents published in EUR-Lex alone. This is an inference from the notice wording (Inferred), not a statement by the Publications Office."
45
+ },
46
+ "chain_of_title": [
47
+ "EU institutions (authors) -> Publications Office EUR-Lex (publisher; reuse policy above)",
48
+ "-> SpeakLeash speakleash-ds-pub key eurlex_corpus (aggregator; its terms for this corpus were not checked)",
49
+ "-> SlayerLab/polish-dynaword eurlex (this dataset)"
50
+ ],
51
+ "parquet": {
52
+ "v0_2_5_sha256": "5f151d57c20103f5488fd7f1b6c108311b648e4c7ed1ff02ef7a376be5c92f04",
53
+ "v0_2_5_bytes": 1691883292,
54
+ "after_relabel_sha256": "44cc0dfb0c73c1462635cebc23ed7c1f46e6c509e57e118477a8cfc7cc74c84c",
55
+ "rows": 243060,
56
+ "chars": 5976949249,
57
+ "tokens": 2378055718,
58
+ "change": "per-row license column CC-BY-4.0 -> LicenseRef-EU-Reuse-Policy (src/clean_eurlex.py); all other columns identical, no row dropped"
59
+ },
60
+ "document_kinds_heuristic": {
61
+ "method": "first 200 characters of each document",
62
+ "counts": {
63
+ "oj_c": 102032,
64
+ "oj_l": 52413,
65
+ "eurlex_page": 24146,
66
+ "court_of_justice_celex_start": 21846,
67
+ "consolidated": 17229,
68
+ "other": 13712,
69
+ "court_of_justice_text": 6155,
70
+ "immc": 3521,
71
+ "commission_head": 2006
72
+ },
73
+ "note": "17,229 consolidated texts (29.0% of characters) are within the notice's CC BY 4.0 grant as well; the single corpus label does not claim CC BY 4.0 for the rest"
74
+ },
75
+ "third_party_check": {
76
+ "report_only": true,
77
+ "dropped": 0,
78
+ "scan": "data/eurlex/eurlex.third-party-scan.json (src/clean_eurlex.py --scan)",
79
+ "iasb_notice": {
80
+ "documents": 92,
81
+ "characters": 74060114,
82
+ "share_of_characters": 0.01239,
83
+ "what": "Documents carrying the IASB notice (reproduction allowed within the EEA, all rights reserved outside it): 64 OJ acts adopting or amending IAS/IFRS and 28 consolidated versions (20 of Regulation 1126/2008, 6 of 1725/2003, 1 of 475/2012, 1 of 1361/2014). The notice sits in the reproduced standards; the rest of each document is EU text.",
84
+ "hand_check": "All 92 matched lines read: each is the IASB notice (11 distinct line forms, including whitespace and quote-mark variants). All 64 non-consolidated titles concern IAS/IFRS or accounting.",
85
+ "cross_check": "2 further documents have a standard-title line without the notice (eurlex_1848316, eurlex_2024404; 67,283 characters): not counted.",
86
+ "mentions_without_notice": "6 documents name the IFRS Foundation or IASC Foundation in running text only (funding decisions, reports); not counted."
87
+ },
88
+ "copyright_sign": {
89
+ "documents": 97,
90
+ "hand_labelled_third_party_credit_or_citation": [
91
+ "eurlex_1804281",
92
+ "eurlex_1808068",
93
+ "eurlex_1809226",
94
+ "eurlex_1810394",
95
+ "eurlex_1813244",
96
+ "eurlex_1815292",
97
+ "eurlex_1821803",
98
+ "eurlex_1823205",
99
+ "eurlex_1823678",
100
+ "eurlex_1823728",
101
+ "eurlex_1852144",
102
+ "eurlex_1852490",
103
+ "eurlex_1865032",
104
+ "eurlex_1869305",
105
+ "eurlex_1888527",
106
+ "eurlex_1900544",
107
+ "eurlex_1917072",
108
+ "eurlex_1937895",
109
+ "eurlex_1944848",
110
+ "eurlex_1953473",
111
+ "eurlex_1973899",
112
+ "eurlex_1976278",
113
+ "eurlex_2002307",
114
+ "eurlex_2006693",
115
+ "eurlex_2014867",
116
+ "eurlex_2018301",
117
+ "eurlex_2018302",
118
+ "eurlex_2028817",
119
+ "eurlex_2028818",
120
+ "eurlex_2032137",
121
+ "eurlex_2033606",
122
+ "eurlex_2042094",
123
+ "eurlex_2045379"
124
+ ],
125
+ "hand_labelled_third_party_count": 33,
126
+ "other": "by first occurrence: 25 EU-owned credits (Commission, European Court of Auditors, ECB symbol, EUPL), 7 binary-garbage documents, and 32 glyph noise, list markers or trademark symbols",
127
+ "binary_garbage_documents": [
128
+ "eurlex_1995131",
129
+ "eurlex_2016612",
130
+ "eurlex_2025049",
131
+ "eurlex_2025668",
132
+ "eurlex_2025821",
133
+ "eurlex_2026102",
134
+ "eurlex_2026315"
135
+ ],
136
+ "note": "The credit lines name photographs, maps and data sources; the credited images are not in the text. The excerpts are short data citations (OECD, IEA, IHS Markit, CRU, McKinsey, Springer, IOTF)."
137
+ },
138
+ "author_header_categories": {
139
+ "method": "regex on the first 3000 characters; counts in the scan file",
140
+ "ecb_act": 1414,
141
+ "eesc": 5154,
142
+ "state_aid_sa": 2941,
143
+ "un_ece_regulation": 253,
144
+ "note": "Not third-party under the notice by themselves: they are texts of EU bodies or Commission notices. They matter only if those bodies' reuse terms differ (not checked). The audit's rough shares (ECB ~4%, state aid ~2.5%) do not reproduce with these patterns."
145
+ },
146
+ "not_found": "No large-scale reproduction of non-EU copyrighted works was found by these patterns. Recall for third-party text they do not target is unknown (Inferred)."
147
+ },
148
+ "not_checked": [
149
+ "SpeakLeash's terms for eurlex_corpus",
150
+ "whether the ECB, EESC, Council, Parliament and the Court of Justice publish reuse terms of their own, and whether they differ from the notice",
151
+ "the 'Unless otherwise specified' clause per document: only the IASB notice and the (c) sign were searched for",
152
+ "Official Journal documents quoting national or private texts in annexes (e.g. UN ECE regulations, 253 documents by header; standards bodies' texts)",
153
+ "the Publications Office's position on non-Commission documents (a lawyer question, #56 B5)"
154
+ ]
155
+ }
data/eurlex/eurlex.md CHANGED
@@ -6,15 +6,15 @@ EUR-Lex (EU legal acts, Polish)
6
  - **Source (upstream):** https://eur-lex.europa.eu
7
  - **Domain:** legal
8
  - **Language:** Polish (pl)
9
- - **License:** `CC-BY-4.0`
10
  - **Created (range):** 1952-01-01, 2024-12-31
11
  - **Added:** 2026-07-02
12
 
13
  ## Licensing — traceable basis
14
- EU documents reusable under Commission Decision 2011/833/EU; normative acts fall outside copyright (PL art. 4 pr. aut.). Reuse authorised with source acknowledgement.
15
 
16
  ## Provenance
17
- Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key `eurlex_corpus`) of the upstream source above. SpeakLeash credited as intermediate aggregator; upstream license/attribution preserved.
18
 
19
  ## Statistics
20
  | documents | characters | tokens (tiktoken proxy) |
@@ -25,10 +25,13 @@ Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key `eurlex
25
  ## Per-document license metadata
26
  | license | documents |
27
  |---|---:|
28
- | `CC-BY-4.0` | 243,060 |
29
 
30
  Author metadata present for **0** 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)
 
6
  - **Source (upstream):** https://eur-lex.europa.eu
7
  - **Domain:** legal
8
  - **Language:** Polish (pl)
9
+ - **License:** `LicenseRef-EU-Reuse-Policy`
10
  - **Created (range):** 1952-01-01, 2024-12-31
11
  - **Added:** 2026-07-02
12
 
13
  ## Licensing — traceable basis
14
+ The EUR-Lex legal notice (https://eur-lex.europa.eu/content/legal-notice/legal-notice.html, read 2026-10-06) says the Commission's document reuse policy is based on Decision 2011/833/EU and that, unless otherwise specified, the legal documents published in EUR-Lex may be re-used for commercial or non-commercial purposes. Decision 2011/833/EU (https://eur-lex.europa.eu/eli/dec/2011/833/oj/eng) Art. 4 makes documents available for reuse without charge or application; Art. 6(2) allows the conditions of source acknowledgement and no distortion of the original meaning. The notice's Creative Commons BY 4.0 grant covers only EUR-Lex editorial content, summaries of EU legislation and consolidated texts, not the acts as such, so the corpus is not labelled CC BY 4.0. This is a reuse permission, not an exclusion from copyright: Art. 4 of the Polish Copyright Act does not apply to EU acts and is not relied on.
15
 
16
  ## Provenance
17
+ Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key `eurlex_corpus`) of EUR-Lex. SpeakLeash is an intermediate aggregator: its own terms for the corpus were not checked, and the upstream EUR-Lex terms above are the basis. Documents are Polish-language EUR-Lex texts: Official Journal L and C items, consolidated texts, Court of Justice documents and Commission documents.
18
 
19
  ## Statistics
20
  | documents | characters | tokens (tiktoken proxy) |
 
25
  ## Per-document license metadata
26
  | license | documents |
27
  |---|---:|
28
+ | `LicenseRef-EU-Reuse-Policy` | 243,060 |
29
 
30
  Author metadata present for **0** documents. Empty values mean the upstream record did not expose a machine-readable author field.
31
 
32
+ ## Legal scope note
33
+ Third-party material is not covered. The notice and Decision 2011/833/EU Art. 2(2)(a)-(b) exclude documents covered by industrial property rights or third-party intellectual property rights, and the notice says the International Accounting Standards may carry special conditions of use. 92 documents (74.1M characters, 1.24%) contain the IASB notice allowing reproduction within the EEA and reserving all rights outside it: 64 Official Journal acts adopting or amending IAS/IFRS and 28 consolidated versions (Regulations 1126/2008, 1725/2003, 475/2012, 1361/2014). 97 documents contain a (c) sign; 33 of them are third-party credits or short data citations (photographs, maps, OECD, IHS Markit, McKinsey, Springer), the rest EU credits or extraction noise. Nothing was removed. Ids and counts are in `eurlex.third-party-scan.json` and `eurlex.license-evidence.json`; recall for third-party text the patterns do not target is unknown. Decision 2011/833/EU itself covers documents held by the Commission or the Publications Office; acts of other institutions (Council, Parliament, ECB, EESC, CJEU) rest on the notice's general sentence alone, and whether those bodies publish their own reuse terms was not checked.
34
+
35
  Statistics were recomputed directly from the released parquet file.
36
 
37
  ## Filters applied (build_dynaword.py)
data/eurlex/eurlex.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5f151d57c20103f5488fd7f1b6c108311b648e4c7ed1ff02ef7a376be5c92f04
3
- size 1691883292
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44cc0dfb0c73c1462635cebc23ed7c1f46e6c509e57e118477a8cfc7cc74c84c
3
+ size 1691885842
data/eurlex/eurlex.stats.json CHANGED
@@ -8,9 +8,9 @@
8
  "chars": 5976949249,
9
  "tokens": 2378055718,
10
  "licenses": {
11
- "CC-BY-4.0": 243060
12
  },
13
  "authors_with_value": 0,
14
- "license": "CC-BY-4.0",
15
  "stats_recomputed_from_parquet": true
16
  }
 
8
  "chars": 5976949249,
9
  "tokens": 2378055718,
10
  "licenses": {
11
+ "LicenseRef-EU-Reuse-Policy": 243060
12
  },
13
  "authors_with_value": 0,
14
+ "license": "LicenseRef-EU-Reuse-Policy",
15
  "stats_recomputed_from_parquet": true
16
  }
data/eurlex/eurlex.third-party-scan.json ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "rows": 243060,
3
+ "chars": 5976949249,
4
+ "rules": {
5
+ "iasb_notice": {
6
+ "docs": 92,
7
+ "chars": 74060114,
8
+ "pattern": "zastrze[żz]one\\s+poza\\s+EOG",
9
+ "window": "whole text",
10
+ "share_of_chars": 0.01239
11
+ },
12
+ "copyright_sign": {
13
+ "docs": 97,
14
+ "chars": 31335172,
15
+ "pattern": "©",
16
+ "window": "whole text",
17
+ "share_of_chars": 0.00524
18
+ },
19
+ "ecb_act": {
20
+ "docs": 1414,
21
+ "chars": 59885106,
22
+ "pattern": "\\((EBC|CON)/\\d{4}/\\d+\\)",
23
+ "window": "first 3000 characters",
24
+ "share_of_chars": 0.01002
25
+ },
26
+ "eesc": {
27
+ "docs": 5154,
28
+ "chars": 129142031,
29
+ "pattern": "EESC[-_ ]\\d{4}|Opinia Europejskiego Komitetu Ekonomiczno-Społecznego|Europejski Komitet Ekonomiczno-Społeczny",
30
+ "window": "first 3000 characters",
31
+ "share_of_chars": 0.02161
32
+ },
33
+ "state_aid_sa": {
34
+ "docs": 2941,
35
+ "chars": 75399658,
36
+ "pattern": "\\bSA\\.\\d{4,6}\\b",
37
+ "window": "first 3000 characters",
38
+ "share_of_chars": 0.01262
39
+ },
40
+ "un_ece_regulation": {
41
+ "docs": 253,
42
+ "chars": 23115516,
43
+ "pattern": "Regulamin\\w* nr \\d+[^\\n]{0,80}(Europejskiej Komisji Gospodarczej|EKG ONZ)",
44
+ "window": "first 3000 characters",
45
+ "share_of_chars": 0.00387
46
+ }
47
+ },
48
+ "iasb_notice_ids": [
49
+ "eurlex_1838756",
50
+ "eurlex_1849634",
51
+ "eurlex_1858966",
52
+ "eurlex_1858967",
53
+ "eurlex_1858968",
54
+ "eurlex_1861433",
55
+ "eurlex_1861571",
56
+ "eurlex_1861798",
57
+ "eurlex_1864768",
58
+ "eurlex_1865459",
59
+ "eurlex_1867520",
60
+ "eurlex_1873710",
61
+ "eurlex_1875966",
62
+ "eurlex_1877208",
63
+ "eurlex_1877852",
64
+ "eurlex_1883669",
65
+ "eurlex_1883677",
66
+ "eurlex_1885399",
67
+ "eurlex_1888360",
68
+ "eurlex_1888463",
69
+ "eurlex_1892388",
70
+ "eurlex_1893873",
71
+ "eurlex_1894940",
72
+ "eurlex_1898488",
73
+ "eurlex_1899031",
74
+ "eurlex_1901186",
75
+ "eurlex_1901192",
76
+ "eurlex_1901197",
77
+ "eurlex_1901204",
78
+ "eurlex_1901211",
79
+ "eurlex_1901726",
80
+ "eurlex_1906344",
81
+ "eurlex_1907279",
82
+ "eurlex_1908275",
83
+ "eurlex_1908290",
84
+ "eurlex_1908308",
85
+ "eurlex_1908315",
86
+ "eurlex_1908324",
87
+ "eurlex_1908528",
88
+ "eurlex_1910176",
89
+ "eurlex_1910340",
90
+ "eurlex_1911589",
91
+ "eurlex_1913515",
92
+ "eurlex_1914195",
93
+ "eurlex_1919078",
94
+ "eurlex_1919129",
95
+ "eurlex_1919130",
96
+ "eurlex_1919550",
97
+ "eurlex_1919710",
98
+ "eurlex_1921635",
99
+ "eurlex_1921640",
100
+ "eurlex_1929891",
101
+ "eurlex_1930795",
102
+ "eurlex_1930859",
103
+ "eurlex_1931269",
104
+ "eurlex_1931985",
105
+ "eurlex_1932248",
106
+ "eurlex_1939819",
107
+ "eurlex_1939820",
108
+ "eurlex_1939858",
109
+ "eurlex_1940236",
110
+ "eurlex_1940265",
111
+ "eurlex_1942295",
112
+ "eurlex_1943238",
113
+ "eurlex_1944058",
114
+ "eurlex_1947662",
115
+ "eurlex_1947821",
116
+ "eurlex_1947822",
117
+ "eurlex_1953178",
118
+ "eurlex_1955954",
119
+ "eurlex_1960818",
120
+ "eurlex_1960827",
121
+ "eurlex_1962574",
122
+ "eurlex_1962666",
123
+ "eurlex_1963180",
124
+ "eurlex_1965597",
125
+ "eurlex_1965598",
126
+ "eurlex_1965758",
127
+ "eurlex_1967466",
128
+ "eurlex_1968555",
129
+ "eurlex_1972398",
130
+ "eurlex_1979642",
131
+ "eurlex_1988175",
132
+ "eurlex_1988286",
133
+ "eurlex_1995439",
134
+ "eurlex_1995808",
135
+ "eurlex_2010160",
136
+ "eurlex_2012411",
137
+ "eurlex_2026447",
138
+ "eurlex_2027900",
139
+ "eurlex_2031043",
140
+ "eurlex_2039084"
141
+ ]
142
+ }
src/clean_eurlex.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """eurlex rights-audit actions (slayerlabs/polish-dynaword-v2#57).
3
+
4
+ relabel (default): the v0.2.5 release labelled every row `CC-BY-4.0`. The EUR-Lex legal
5
+ notice licenses under CC BY 4.0 only "the editorial content of this website, the summaries
6
+ of EU legislation and the consolidated texts"; the legal documents themselves are reusable
7
+ under the Commission's reuse policy (Decision 2011/833/EU). Rewrites the per-row `license`
8
+ column to `LicenseRef-EU-Reuse-Policy` and recomputes `eurlex.stats.json` with
9
+ `normalize_schema.normalize_one`. No row is dropped or edited. Raises, and leaves the
10
+ parquet as it was, if any row carries a licence other than the old or the new label.
11
+
12
+ --scan: report-only count of documents the notice's third-party / special-conditions
13
+ exclusions may reach. Writes `data/eurlex/eurlex.third-party-scan.json`. Nothing is dropped.
14
+ The regexes are heuristics: counts are lower bounds on what they target, and recall for
15
+ third-party text they do not target is unknown.
16
+
17
+ Restore the v0.2.5 input before a rerun (sha256 5f151d57c20103f5488fd7f1b6c108311b648e4c7ed1ff02ef7a376be5c92f04):
18
+ git checkout 3bab9f9 -- data/eurlex/eurlex.parquet
19
+ python3 src/clean_eurlex.py
20
+ """
21
+ from __future__ import annotations
22
+
23
+ import argparse
24
+ import json
25
+ import re
26
+ import sys
27
+ from pathlib import Path
28
+
29
+ import pyarrow as pa
30
+ import pyarrow.compute as pc
31
+ import pyarrow.parquet as pq
32
+
33
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
34
+ from normalize_schema import normalize_one # noqa: E402
35
+
36
+ SOURCE = "eurlex"
37
+ ROOT = Path(__file__).resolve().parents[1]
38
+ PARQUET = ROOT / "data" / SOURCE / f"{SOURCE}.parquet"
39
+ SCAN_JSON = ROOT / "data" / SOURCE / f"{SOURCE}.third-party-scan.json"
40
+ OLD_LICENSE, NEW_LICENSE = "CC-BY-4.0", "LicenseRef-EU-Reuse-Policy"
41
+ BATCH = 8192 # same as normalize_schema, so the row groups match
42
+
43
+ # Whole-text rule. The IASB's notice in the IAS/IFRS adopting acts and their consolidated
44
+ # versions: reproduction allowed in the EEA, "all rights reserved outside the EEA" (worded
45
+ # "Wszystkie istniejące prawa [są] zastrzeżone poza EOG" or "Wszelkie prawa zastrzeżone poza EOG").
46
+ WHOLE_TEXT_RULES = {
47
+ "iasb_notice": re.compile(r"zastrze[żz]one\s+poza\s+EOG"),
48
+ "copyright_sign": re.compile("©"),
49
+ }
50
+ # Header-window rules: documents whose first HEADER characters mark an author other than the Commission.
51
+ HEADER = 3000
52
+ HEADER_RULES = {
53
+ "ecb_act": re.compile(r"\((EBC|CON)/\d{4}/\d+\)"),
54
+ "eesc": re.compile(r"EESC[-_ ]\d{4}|Opinia Europejskiego Komitetu Ekonomiczno-Społecznego"
55
+ r"|Europejski Komitet Ekonomiczno-Społeczny"),
56
+ "state_aid_sa": re.compile(r"\bSA\.\d{4,6}\b"),
57
+ "un_ece_regulation": re.compile(r"Regulamin\w* nr \d+[^\n]{0,80}(Europejskiej Komisji Gospodarczej|EKG ONZ)", re.I),
58
+ }
59
+
60
+
61
+ def relabel(path: Path = PARQUET, old: str = OLD_LICENSE, new: str = NEW_LICENSE) -> dict:
62
+ """Rewrite `license` of every row to `new`, then recompute stats. Returns the stats."""
63
+ tmp = path.with_suffix(".parquet.tmp")
64
+ pf = pq.ParquetFile(path)
65
+ schema = pf.schema_arrow
66
+ index = schema.get_field_index("license")
67
+ writer = pq.ParquetWriter(tmp, schema, compression="zstd")
68
+ try:
69
+ for batch in pf.iter_batches(batch_size=BATCH):
70
+ tbl = pa.Table.from_batches([batch])
71
+ found = set(pc.unique(tbl["license"]).to_pylist())
72
+ if not found <= {old, new}:
73
+ raise ValueError(f"{path.name}: unexpected licence(s) {sorted(map(str, found - {old, new}))}")
74
+ tbl = tbl.set_column(index, schema.field(index), pa.array([new] * tbl.num_rows, type=pa.string()))
75
+ writer.write_table(tbl)
76
+ writer.close()
77
+ tmp.replace(path)
78
+ except BaseException:
79
+ writer.close()
80
+ tmp.unlink(missing_ok=True)
81
+ raise
82
+ return normalize_one(path)
83
+
84
+
85
+ def scan(path: Path = PARQUET) -> dict:
86
+ """Count documents matching each rule. Report-only."""
87
+ pf = pq.ParquetFile(path)
88
+ rules = {**{k: (v, False) for k, v in WHOLE_TEXT_RULES.items()}, **{k: (v, True) for k, v in HEADER_RULES.items()}}
89
+ out = {k: {"docs": 0, "chars": 0} for k in rules}
90
+ iasb_ids: list[str] = []
91
+ rows = chars = 0
92
+ for batch in pf.iter_batches(batch_size=BATCH, columns=["id", "text"]):
93
+ for doc_id, text in zip(batch["id"].to_pylist(), batch["text"].to_pylist()):
94
+ rows += 1
95
+ chars += len(text)
96
+ for name, (pattern, header_only) in rules.items():
97
+ if pattern.search(text[:HEADER] if header_only else text):
98
+ out[name]["docs"] += 1
99
+ out[name]["chars"] += len(text)
100
+ if name == "iasb_notice":
101
+ iasb_ids.append(doc_id)
102
+ for name, (pattern, header_only) in rules.items():
103
+ out[name]["pattern"] = pattern.pattern
104
+ out[name]["window"] = f"first {HEADER} characters" if header_only else "whole text"
105
+ out[name]["share_of_chars"] = round(out[name]["chars"] / chars, 5)
106
+ return {"rows": rows, "chars": chars, "rules": out, "iasb_notice_ids": sorted(iasb_ids)}
107
+
108
+
109
+ def main() -> None:
110
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
111
+ ap.add_argument("--scan", action="store_true", help="write the report-only third-party scan instead of relabelling")
112
+ ap.add_argument("--parquet", type=Path, default=PARQUET)
113
+ args = ap.parse_args()
114
+ if args.scan:
115
+ result = scan(args.parquet)
116
+ SCAN_JSON.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n")
117
+ print(json.dumps({k: v for k, v in result.items() if k != "iasb_notice_ids"}, ensure_ascii=False, indent=2))
118
+ else:
119
+ stats = relabel(args.parquet)
120
+ print(f"{SOURCE}: {stats['kept']:,} docs | {stats['tokens']:,} tokens | licences {stats['licenses']}")
121
+
122
+
123
+ if __name__ == "__main__":
124
+ main()
src/sources.py CHANGED
@@ -207,11 +207,45 @@ SOURCES = {
207
  "release": "0.2.0",
208
  "speakleash_key": "eurlex_corpus",
209
  "pretty": "EUR-Lex (EU legal acts, Polish)",
210
- "license": "CC-BY-4.0",
211
- "license_spdx": "CC-BY-4.0",
212
- "traceable": "EU documents reusable under Commission Decision 2011/833/EU; "
213
- "normative acts fall outside copyright (PL art. 4 pr. aut.). "
214
- "Reuse authorised with source acknowledgement.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  "upstream": "https://eur-lex.europa.eu",
216
  "domain": "legal",
217
  "created": "1952-01-01, 2024-12-31",
 
207
  "release": "0.2.0",
208
  "speakleash_key": "eurlex_corpus",
209
  "pretty": "EUR-Lex (EU legal acts, Polish)",
210
+ "license": "LicenseRef-EU-Reuse-Policy",
211
+ "license_spdx": "LicenseRef-EU-Reuse-Policy",
212
+ "traceable": "The EUR-Lex legal notice (https://eur-lex.europa.eu/content/legal-notice/"
213
+ "legal-notice.html, read 2026-10-06) says the Commission's document reuse "
214
+ "policy is based on Decision 2011/833/EU and that, unless otherwise "
215
+ "specified, the legal documents published in EUR-Lex may be re-used for "
216
+ "commercial or non-commercial purposes. Decision 2011/833/EU "
217
+ "(https://eur-lex.europa.eu/eli/dec/2011/833/oj/eng) Art. 4 makes documents "
218
+ "available for reuse without charge or application; Art. 6(2) allows the "
219
+ "conditions of source acknowledgement and no distortion of the original "
220
+ "meaning. The notice's Creative Commons BY 4.0 grant covers only EUR-Lex "
221
+ "editorial content, summaries of EU legislation and consolidated texts, not "
222
+ "the acts as such, so the corpus is not labelled CC BY 4.0. This is a reuse "
223
+ "permission, not an exclusion from copyright: Art. 4 of the Polish Copyright "
224
+ "Act does not apply to EU acts and is not relied on.",
225
+ "provenance": "Pulled from SpeakLeash's public redistribution (`speakleash-ds-pub`, key "
226
+ "`eurlex_corpus`) of EUR-Lex. SpeakLeash is an intermediate aggregator: its "
227
+ "own terms for the corpus were not checked, and the upstream EUR-Lex terms "
228
+ "above are the basis. Documents are Polish-language EUR-Lex texts: Official "
229
+ "Journal L and C items, consolidated texts, Court of Justice documents and "
230
+ "Commission documents.",
231
+ "legal_note": "Third-party material is not covered. The notice and Decision 2011/833/EU "
232
+ "Art. 2(2)(a)-(b) exclude documents covered by industrial property rights "
233
+ "or third-party intellectual property rights, and the notice says the "
234
+ "International Accounting Standards may carry special conditions of use. "
235
+ "92 documents (74.1M characters, 1.24%) contain the IASB notice allowing "
236
+ "reproduction within the EEA and reserving all rights outside it: 64 "
237
+ "Official Journal acts adopting or amending IAS/IFRS and 28 consolidated "
238
+ "versions (Regulations 1126/2008, 1725/2003, 475/2012, 1361/2014). 97 "
239
+ "documents contain a (c) sign; 33 of them are third-party credits or short "
240
+ "data citations (photographs, maps, OECD, IHS Markit, McKinsey, Springer), "
241
+ "the rest EU credits or extraction noise. Nothing was removed. Ids and "
242
+ "counts are in `eurlex.third-party-scan.json` and "
243
+ "`eurlex.license-evidence.json`; recall for third-party text the patterns "
244
+ "do not target is unknown. Decision 2011/833/EU itself covers documents "
245
+ "held by the Commission or the Publications Office; acts of other "
246
+ "institutions (Council, Parliament, ECB, EESC, CJEU) rest on the notice's "
247
+ "general sentence alone, and whether those bodies publish their own reuse "
248
+ "terms was not checked.",
249
  "upstream": "https://eur-lex.europa.eu",
250
  "domain": "legal",
251
  "created": "1952-01-01, 2024-12-31",
src/test_eurlex_contract.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract tests for the eurlex licence relabel (slayerlabs/polish-dynaword-v2#57)."""
2
+ from __future__ import annotations
3
+
4
+ import hashlib
5
+ import json
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ import pyarrow as pa
10
+ import pyarrow.parquet as pq
11
+ import pytest
12
+
13
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
14
+
15
+ import make_docs
16
+ from clean_eurlex import (
17
+ HEADER,
18
+ HEADER_RULES,
19
+ NEW_LICENSE,
20
+ OLD_LICENSE,
21
+ WHOLE_TEXT_RULES,
22
+ relabel,
23
+ scan,
24
+ )
25
+ from normalize_schema import SCHEMA, string_len_sum
26
+ from sources import SOURCES
27
+
28
+ ROOT = Path(__file__).resolve().parents[1]
29
+ DATA = ROOT / "data" / "eurlex"
30
+ CFG = SOURCES["eurlex"]
31
+
32
+
33
+ def write_parquet(path: Path, rows: list[dict]) -> Path:
34
+ path.parent.mkdir(parents=True, exist_ok=True)
35
+ pq.write_table(pa.Table.from_pylist(rows, schema=SCHEMA), path, compression="zstd")
36
+ return path
37
+
38
+
39
+ def row(i: int, text: str = "Rozporządzenie. " * 20, license: str = OLD_LICENSE) -> dict:
40
+ return {"id": f"eurlex_{i}", "text": text, "source": "eurlex", "added": "2026-06-15",
41
+ "created": "1952-01-01, 2024-12-31", "token_count": 7 + i, "license": license, "author": ""}
42
+
43
+
44
+ # normalize_one reads the registry entry by directory name, so the fixture lives in <tmp>/eurlex/.
45
+ @pytest.fixture
46
+ def parquet(tmp_path):
47
+ return write_parquet(tmp_path / "eurlex" / "eurlex.parquet", [row(0), row(1), row(2, license=NEW_LICENSE)])
48
+
49
+
50
+ def test_relabel_changes_only_the_license_column(parquet):
51
+ before = pq.read_table(parquet)
52
+ stats = relabel(parquet)
53
+ after = pq.read_table(parquet)
54
+
55
+ assert after.schema == before.schema
56
+ assert after["license"].to_pylist() == [NEW_LICENSE] * 3
57
+ for name in before.schema.names:
58
+ if name != "license":
59
+ assert after[name].equals(before[name]), name
60
+ assert stats["kept"] == 3
61
+ assert stats["licenses"] == {NEW_LICENSE: 3}
62
+ assert stats["license"] == NEW_LICENSE == CFG["license"]
63
+ assert stats["chars"] == string_len_sum(before["text"])
64
+ assert stats["tokens"] == sum(before["token_count"].to_pylist())
65
+ assert json.loads(parquet.with_name("eurlex.stats.json").read_text()) == stats
66
+ assert not parquet.with_suffix(".parquet.tmp").exists()
67
+
68
+
69
+ def test_relabel_is_idempotent(parquet):
70
+ first = relabel(parquet)
71
+ assert relabel(parquet) == first
72
+
73
+
74
+ def test_relabel_refuses_an_unexpected_license_and_leaves_the_file_alone(tmp_path):
75
+ path = write_parquet(tmp_path / "eurlex" / "eurlex.parquet", [row(0), row(1, license="CC-BY-SA-4.0")])
76
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
77
+ with pytest.raises(ValueError, match="CC-BY-SA-4.0"):
78
+ relabel(path)
79
+ assert hashlib.sha256(path.read_bytes()).hexdigest() == digest
80
+ assert not path.with_suffix(".parquet.tmp").exists()
81
+
82
+
83
+ # The three wordings of the IASB notice in the corpus (Polish text of the OJ), and text that must not match.
84
+ IASB_NOTICES = [
85
+ "Powielanie dozwolone w obrębie Europejskiego Obszaru Gospodarczego. Wszystkie istniejące prawa są "
86
+ "zastrzeżone poza EOG, z wyjątkiem prawa do powielania na użytek własny lub w innych uczciwych celach.",
87
+ "Powielanie dozwolone w Europejskim Obszarze Gospodarczym. Wszystkie istniejące prawa zastrzeżone poza EOG, "
88
+ "za wyjątkiem prawa do powielania w celach osobistych lub innych uczciwych celach.",
89
+ "Reprodukowanie dozwolone na terenie Europejskiego Obszaru Gospodarczego. Wszelkie prawa zastrzeżone poza EOG, "
90
+ "z wyjątkiem prawa do powielania dla własnego użytku osobistego.",
91
+ "Wszystkie istniejące prawa są zastrzeżone poza EOG, z wyjątkiem prawa do powielania",
92
+ ]
93
+
94
+
95
+ @pytest.mark.parametrize("text", IASB_NOTICES)
96
+ def test_iasb_rule_matches_the_notice_wordings(text):
97
+ assert WHOLE_TEXT_RULES["iasb_notice"].search(f"Standard rachunkowości 1\n{text}\nStandard 2")
98
+
99
+
100
+ @pytest.mark.parametrize("text", [
101
+ "Wszelkie prawa zastrzeżone.",
102
+ "Państwa trzecie zastrzegają poza EOG swoje prawa.",
103
+ "Fundacja IFRS finansuje Komitet.",
104
+ ])
105
+ def test_iasb_rule_ignores_other_text(text):
106
+ assert not WHOLE_TEXT_RULES["iasb_notice"].search(text)
107
+
108
+
109
+ def test_header_rules_look_only_at_the_header():
110
+ ecb = "Opinia Europejskiego Banku Centralnego (CON/2012/45) w sprawie"
111
+ assert HEADER_RULES["ecb_act"].search(ecb)
112
+ assert HEADER_RULES["state_aid_sa"].search("Pomoc państwa SA.34567 (2012/N)")
113
+ assert HEADER_RULES["un_ece_regulation"].search("Regulamin nr 117 Europejskiej Komisji Gospodarczej Organizacji")
114
+ assert not HEADER_RULES["ecb_act"].search("Rozporządzenie Rady")
115
+
116
+
117
+ def test_scan_counts_documents_per_rule(tmp_path):
118
+ late = "x" * (HEADER + 10) + " (CON/2012/45)"
119
+ path = write_parquet(tmp_path / "eurlex" / "eurlex.parquet", [
120
+ row(0, text=IASB_NOTICES[0] + " " * 150),
121
+ row(1, text="Zdjęcie © Adobe Stock. " + "a" * 200),
122
+ row(2, text="Opinia (CON/2012/45) " + "b" * 200),
123
+ row(3, text=late), # header rules stop at HEADER characters
124
+ row(4),
125
+ ])
126
+ result = scan(path)
127
+ rules = result["rules"]
128
+ assert result["rows"] == 5
129
+ assert result["chars"] == sum(len(t) for t in pq.read_table(path)["text"].to_pylist())
130
+ assert result["iasb_notice_ids"] == ["eurlex_0"]
131
+ assert (rules["iasb_notice"]["docs"], rules["copyright_sign"]["docs"], rules["ecb_act"]["docs"]) == (1, 1, 1)
132
+ assert rules["state_aid_sa"]["docs"] == 0
133
+ assert rules["iasb_notice"]["chars"] == len(pq.read_table(path)["text"][0].as_py())
134
+
135
+
136
+ def test_registry_label_and_basis():
137
+ assert CFG["license"] == CFG["license_spdx"] == NEW_LICENSE
138
+ assert CFG["release"] == "0.2.0"
139
+ basis = CFG["traceable"]
140
+ assert "2011/833" in basis and "legal-notice" in basis
141
+ assert "not labelled CC BY 4.0" in basis
142
+ # Art. 4 of the Polish Copyright Act is named only to say it is not relied on
143
+ assert "does not apply to EU acts and is not relied on" in basis
144
+ assert "third-party" in CFG["legal_note"].lower()
145
+
146
+
147
+ def test_release_artifact_matches_label_stats_and_evidence():
148
+ path = DATA / "eurlex.parquet"
149
+ pf = pq.ParquetFile(path)
150
+ stats = json.loads((DATA / "eurlex.stats.json").read_text())
151
+ evidence = json.loads((DATA / "eurlex.license-evidence.json").read_text())
152
+
153
+ assert pf.schema_arrow.names == SCHEMA.names
154
+ rows = chars = tokens = 0
155
+ licenses, sources = set(), set()
156
+ for group in range(pf.num_row_groups):
157
+ tbl = pf.read_row_group(group)
158
+ rows += tbl.num_rows
159
+ chars += string_len_sum(tbl["text"])
160
+ tokens += sum(tbl["token_count"].to_pylist())
161
+ licenses |= set(tbl["license"].to_pylist())
162
+ sources |= set(tbl["source"].to_pylist())
163
+ assert licenses == {CFG["license"]}
164
+ assert sources == {"eurlex"}
165
+ assert (rows, chars, tokens) == (stats["kept"], stats["chars"], stats["tokens"])
166
+ assert stats["licenses"] == {CFG["license"]: rows} and stats["license"] == CFG["license"]
167
+ # the relabel drops nothing: same totals as v0.2.5
168
+ assert (rows, chars, tokens) == (243060, 5976949249, 2378055718)
169
+
170
+ digest = hashlib.sha256()
171
+ with open(path, "rb") as handle:
172
+ for block in iter(lambda: handle.read(1 << 24), b""):
173
+ digest.update(block)
174
+ assert digest.hexdigest() == evidence["parquet"]["after_relabel_sha256"]
175
+
176
+
177
+ def test_evidence_and_scan_agree():
178
+ evidence = json.loads((DATA / "eurlex.license-evidence.json").read_text())
179
+ result = json.loads((DATA / "eurlex.third-party-scan.json").read_text())
180
+ check = evidence["third_party_check"]
181
+
182
+ assert evidence["label"] == CFG["license"] and evidence["previous_label"] == OLD_LICENSE
183
+ assert check["dropped"] == 0
184
+ assert check["iasb_notice"]["documents"] == result["rules"]["iasb_notice"]["docs"] == len(result["iasb_notice_ids"])
185
+ assert check["iasb_notice"]["characters"] == result["rules"]["iasb_notice"]["chars"]
186
+ assert check["copyright_sign"]["documents"] == result["rules"]["copyright_sign"]["docs"]
187
+ third_party = check["copyright_sign"]["hand_labelled_third_party_credit_or_citation"]
188
+ assert len(third_party) == len(set(third_party)) == check["copyright_sign"]["hand_labelled_third_party_count"]
189
+ for name in ("ecb_act", "eesc", "state_aid_sa", "un_ece_regulation"):
190
+ assert check["author_header_categories"][name] == result["rules"][name]["docs"]
191
+ assert (result["rows"], result["chars"]) == (evidence["parquet"]["rows"], evidence["parquet"]["chars"])
192
+
193
+ urls = [doc["url"] for doc in evidence["reuse_basis"]["documents"]]
194
+ assert urls == ["https://eur-lex.europa.eu/content/legal-notice/legal-notice.html",
195
+ "https://eur-lex.europa.eu/eli/dec/2011/833/oj/eng"]
196
+ for doc in evidence["reuse_basis"]["documents"]:
197
+ assert len(doc["sha256"]) == 64 and int(doc["sha256"], 16) >= 0
198
+ assert doc["retrieved_at"].startswith("2026-10-06")
199
+
200
+
201
+ def test_datasheet_is_generated_from_registry_and_stats():
202
+ stats = json.loads((DATA / "eurlex.stats.json").read_text())
203
+ card = (DATA / "eurlex.md").read_text().replace("\r\n", "\n")
204
+ assert card == make_docs.datasheet("eurlex", CFG, stats)
205
+ assert f"- **License:** `{NEW_LICENSE}`" in card
206
+ assert OLD_LICENSE not in card
207
+ assert "art. 4 pr. aut." not in card