Datasets:
biblioteka_nauki: drop 4,142 reviewed rows, add per-record licence basis (v2#111) (#186)
Browse files- biblioteka_nauki: drop 4,142 reviewed rows, add per-record licence basis (v2#111) (f6263129635fe29a01984fe15539c7c0d26c06ea)
- artifacts/source_findings.md +82 -0
- data/biblioteka_nauki/biblioteka_nauki.attribution.jsonl +2 -2
- data/biblioteka_nauki/biblioteka_nauki.licence-basis.json +702 -0
- data/biblioteka_nauki/biblioteka_nauki.license-evidence.json +1 -0
- data/biblioteka_nauki/biblioteka_nauki.md +74 -18
- data/biblioteka_nauki/biblioteka_nauki.parquet +2 -2
- data/biblioteka_nauki/biblioteka_nauki.review.csv +0 -0
- data/biblioteka_nauki/biblioteka_nauki.stats.json +22 -10
- src/biblioteka_nauki_overlap.py +2 -1
- src/clean_biblioteka_nauki.py +148 -41
- src/licence_basis.py +18 -0
- src/licence_basis_biblioteka_nauki.py +411 -0
- src/sources.py +19 -5
- src/test_biblioteka_nauki_contract.py +113 -41
- src/test_biblioteka_nauki_overlap.py +7 -12
- src/test_licence_basis.py +34 -0
- src/test_licence_basis_biblioteka_nauki.py +271 -0
artifacts/source_findings.md
CHANGED
|
@@ -3670,3 +3670,85 @@ The texts themselves give no sign either way: none holds a footnote marker of WL
|
|
| 3670 |
**Not established** — the editors of the print editions and their death years; the first-edition form of any author
|
| 3671 |
name; what SpeakLeash changed and who removed the footer; whether WL's export drops author's footnotes in any book;
|
| 3672 |
whether `source_edition` is the edition the modernised text actually follows.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3670 |
**Not established** — the editors of the print editions and their death years; the first-edition form of any author
|
| 3671 |
name; what SpeakLeash changed and who removed the footer; whether WL's export drops author's footnotes in any book;
|
| 3672 |
whether `source_edition` is the edition the modernised text actually follows.
|
| 3673 |
+
|
| 3674 |
+
## biblioteka_nauki — row review: 4,142 rows dropped, per-record licence basis added (update to the sections above)
|
| 3675 |
+
|
| 3676 |
+
**Investigated** — 2026-10-20 (slayerlabs/polish-dynaword-v2#111).
|
| 3677 |
+
|
| 3678 |
+
**Verdict** — kept; 4,142 of 41,985 documents dropped by a pinned row review (maintainer decisions 1A, 2A and 3 on
|
| 3679 |
+
v2#111, 2026-10-20): 41,985 → 37,843 documents (-9.9%), 1,739,004,913 → 1,534,529,869 characters, 669,909,430 →
|
| 3680 |
+
590,924,796 tokens (-78,984,634, -11.8%). Every kept row is identical to the shard before the review; the licence basis
|
| 3681 |
+
fields are new in the sidecar.
|
| 3682 |
+
|
| 3683 |
+
**Method** — `src/clean_biblioteka_nauki.py` runs the existing filters, then `src/licence_basis_biblioteka_nauki.py`
|
| 3684 |
+
scans the text of every remaining row (front matter 4,000 characters, back matter 3,000, author check on the first
|
| 3685 |
+
8,000 and last 5,000) with the rules below. A row
|
| 3686 |
+
a rule nominates has one line in `data/biblioteka_nauki/biblioteka_nauki.review.csv` (`id,decision,reason`, pinned by
|
| 3687 |
+
SHA-256). The build fails when the rules and the table disagree, applies the drops, recomputes stats, evidence and
|
| 3688 |
+
sidecar in one run from the v0.2.5 shard and writes `licence_basis`, `licence_basis_url` and `licence_basis_date`. A
|
| 3689 |
+
row gets the first reason in the order printed licence, prior publication, file mismatch, restriction notice, year.
|
| 3690 |
+
The rules' measurements and the hand reads are in `data/biblioteka_nauki/biblioteka_nauki.licence-basis.json`.
|
| 3691 |
+
|
| 3692 |
+
| decision: reason | documents | characters | tokens |
|
| 3693 |
+
|---|---:|---:|---:|
|
| 3694 |
+
| drop: created_before_licence_version | 3,957 | 181,784,176 | 70,103,154 |
|
| 3695 |
+
| drop: restriction_notice_no_cc_note | 97 | 14,700,907 | 5,882,338 |
|
| 3696 |
+
| drop: reprint_or_prior_publication | 30 | 1,475,398 | 531,012 |
|
| 3697 |
+
| drop: translation_of_earlier_publication | 17 | 902,932 | 346,552 |
|
| 3698 |
+
| drop: file_is_another_work | 16 | 1,237,708 | 455,178 |
|
| 3699 |
+
| drop: republished_by_permission | 11 | 1,359,754 | 504,063 |
|
| 3700 |
+
| drop: api_flagged_reprint_translation | 5 | 2,189,037 | 844,892 |
|
| 3701 |
+
| drop: translation_title_marker | 5 | 119,365 | 47,745 |
|
| 3702 |
+
| drop: printed_licence_nc_or_nd | 4 | 705,767 | 269,700 |
|
| 3703 |
+
| keep: text_garbled | 25 | 775,097 | 466,995 |
|
| 3704 |
+
| keep: same_author_prior_version | 5 | 295,509 | 117,106 |
|
| 3705 |
+
| keep: title_in_other_language | 5 | 193,470 | 74,078 |
|
| 3706 |
+
| keep: arr_only_no_cc_note | 5 | 2,104,519 | 804,452 |
|
| 3707 |
+
| keep: restriction_notice_beside_cc_note | 5 | 2,442,662 | 915,329 |
|
| 3708 |
+
| keep: not_a_notice_on_the_work | 5 | 158,813 | 61,768 |
|
| 3709 |
+
| keep: discusses_licence | 3 | 101,066 | 36,837 |
|
| 3710 |
+
| keep: item_found_later_in_file | 3 | 178,625 | 72,855 |
|
| 3711 |
+
| keep: printed_by_label_sa | 2 | 169,732 | 64,912 |
|
| 3712 |
+
| keep: translation_of_cc_original | 2 | 70,772 | 25,009 |
|
| 3713 |
+
| keep: front_matter_item | 2 | 6,914 | 2,880 |
|
| 3714 |
+
| keep: printed_sa_label_by | 1 | 482,353 | 185,072 |
|
| 3715 |
+
|
| 3716 |
+
- **Year rule (decision 3)** — 3,989 rows have a `created` start year earlier than the first year of their label's
|
| 3717 |
+
licence version (CC BY 2.0: 2004; 3.0 and 3.0 PL: 2007; 4.0: 2013): 3,989 documents, 184,805,600 characters,
|
| 3718 |
+
71,278,767 tokens. 32 of them also meet an earlier drop reason and keep that reason (restriction notice 26,
|
| 3719 |
+
another work 3, printed NC or ND 1, prior publication 1, translation 1); 7 that an earlier rule had read and kept
|
| 3720 |
+
are dropped under the year rule (restriction notice beside a CC note 5, not a notice on the work 1, printed SA on a
|
| 3721 |
+
CC BY label 1). So 3,957 documents carry the year reason; 3,950 of them are in no other rule's list. By label: CC
|
| 3722 |
+
BY 4.0 2,279, CC BY-SA 4.0 1,470, CC BY 3.0 106, CC BY 3.0 PL 85, CC BY-SA 3.0 PL 49. In a seeded sample of 100 of
|
| 3723 |
+
the 3,989, 90 print the `created` year in the first 8,000 or last 5,000 characters; the other 10 cite no later year.
|
| 3724 |
+
- **Journal adoption years could not be obtained** — the API returns a journal's current licence only, the shipped rows
|
| 3725 |
+
carry no journal key, and asking for every item would take about 26 hours at the polite rate. Issues from before a
|
| 3726 |
+
journal adopted Creative Commons may therefore remain where the publication year is not earlier than the licence
|
| 3727 |
+
version. The year rule is a lower bound: the years are those of the generic licence texts (the Polish port may be
|
| 3728 |
+
later, which would add rows), and the platform shows the licence an item has today.
|
| 3729 |
+
- **Printed NC/ND (4), another work (16), prior publication, permission and translation (63 rows), API flags (5)** —
|
| 3730 |
+
decision 1A. 16 files are a different work from the one described: neither the title nor any author appears where the text
|
| 3731 |
+
starts, ends or is attributed (all 51 candidates read; 30 each of two looser sets were sampled and none was another
|
| 3732 |
+
work). Prior publication and translation rows were read in context for the tight families (reprint words in the front
|
| 3733 |
+
matter, permission, earlier publication, title markers, translator credit, translation statement); the broad
|
| 3734 |
+
translator-word family (1,326 rows, mostly footnotes) was not.
|
| 3735 |
+
- **Restriction notice, no CC note (97)** — decision 2A: the front or back matter prints a restriction on copying or
|
| 3736 |
+
reproduction and no CC licence of its own. All 120 hits were read; 6 of the 110 hits outside `file_note` rows are not
|
| 3737 |
+
a notice on the work. This is the weakest evidence of the drops: it is a reader's judgement that the printed
|
| 3738 |
+
restriction contradicts the platform's CC label; no journal page was read to see which of the two the journal means.
|
| 3739 |
+
- **Licence basis** — `file_note` for 2,657 records (the text prints a CC licence with the label's elements; URL is
|
| 3740 |
+
the item's page, date is the row's `added` date), `depositor` for 35,186 (only the platform's licence field states
|
| 3741 |
+
it; URL is the API record, date 2026-10-05/2026-10-06). No record has `publisher` or `none`: no journal or publisher
|
| 3742 |
+
page was read, and the 12 rows the API did not serve are withheld. A seeded sample of 60 `file_note` rows, read in
|
| 3743 |
+
context, held 60 genuine notes of the work's own licence.
|
| 3744 |
+
|
| 3745 |
+
**Kept as decided** — the 63 other nominated rows (a printed licence that belongs to an original or to a discussion of
|
| 3746 |
+
licences, "all rights reserved" beside a CC note or without a clause, unreadable text, another language, a revised
|
| 3747 |
+
version by the same authors), 8 translations of ancient, archival or literary texts by the item's author (the original
|
| 3748 |
+
is not a rights-held work; a 9th, `articles_534737`, is dropped as `reprint_or_prior_publication`), and the 16 rows
|
| 3749 |
+
that print "Wszelkie prawa zastrzeżone" or "All rights reserved" as written beside a CC API licence.
|
| 3750 |
+
|
| 3751 |
+
**Not established** — journal adoption years; whether the platform's licence at publication equals the one it shows
|
| 3752 |
+
now for the rows the year rule does not catch; the false-negative rate of the `file_note` rule (licences printed in
|
| 3753 |
+
words or a form the parser does not read were not counted); whether the 97 restriction-notice drops would stand if the
|
| 3754 |
+
journals' own licence pages were read; recall of the reprint and translation rules beyond the tight families.
|
data/biblioteka_nauki/biblioteka_nauki.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:aaf761cfb5e6f1e6a66721933e5cf09a7e9340e4fc2b10bd3944e70d61bd2b44
|
| 3 |
+
size 13313905
|
data/biblioteka_nauki/biblioteka_nauki.licence-basis.json
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_dates": [
|
| 3 |
+
"2026-06-27"
|
| 4 |
+
],
|
| 5 |
+
"api_flags": {
|
| 6 |
+
"biblioteka_nauki_articles_1194786": [
|
| 7 |
+
"reprintPublication"
|
| 8 |
+
],
|
| 9 |
+
"biblioteka_nauki_articles_2154637": [
|
| 10 |
+
"translationPublication"
|
| 11 |
+
],
|
| 12 |
+
"biblioteka_nauki_articles_508678": [
|
| 13 |
+
"reprintPublication"
|
| 14 |
+
],
|
| 15 |
+
"biblioteka_nauki_books_1954543": [
|
| 16 |
+
"translationPublication"
|
| 17 |
+
],
|
| 18 |
+
"biblioteka_nauki_books_2139603": [
|
| 19 |
+
"translationPublication"
|
| 20 |
+
]
|
| 21 |
+
},
|
| 22 |
+
"by_code": {
|
| 23 |
+
"depositor": {
|
| 24 |
+
"characters": 1344777075,
|
| 25 |
+
"rows": 35186,
|
| 26 |
+
"tokens": 518747238
|
| 27 |
+
},
|
| 28 |
+
"file_note": {
|
| 29 |
+
"characters": 189752794,
|
| 30 |
+
"rows": 2657,
|
| 31 |
+
"tokens": 72177558
|
| 32 |
+
}
|
| 33 |
+
},
|
| 34 |
+
"by_label": {
|
| 35 |
+
"CC-BY-2.0": {
|
| 36 |
+
"depositor": 0,
|
| 37 |
+
"file_note": 1,
|
| 38 |
+
"none": 0,
|
| 39 |
+
"publisher": 0
|
| 40 |
+
},
|
| 41 |
+
"CC-BY-3.0": {
|
| 42 |
+
"depositor": 2306,
|
| 43 |
+
"file_note": 0,
|
| 44 |
+
"none": 0,
|
| 45 |
+
"publisher": 0
|
| 46 |
+
},
|
| 47 |
+
"CC-BY-3.0-PL": {
|
| 48 |
+
"depositor": 6825,
|
| 49 |
+
"file_note": 1124,
|
| 50 |
+
"none": 0,
|
| 51 |
+
"publisher": 0
|
| 52 |
+
},
|
| 53 |
+
"CC-BY-4.0": {
|
| 54 |
+
"depositor": 14460,
|
| 55 |
+
"file_note": 989,
|
| 56 |
+
"none": 0,
|
| 57 |
+
"publisher": 0
|
| 58 |
+
},
|
| 59 |
+
"CC-BY-SA-3.0": {
|
| 60 |
+
"depositor": 7,
|
| 61 |
+
"file_note": 0,
|
| 62 |
+
"none": 0,
|
| 63 |
+
"publisher": 0
|
| 64 |
+
},
|
| 65 |
+
"CC-BY-SA-3.0-PL": {
|
| 66 |
+
"depositor": 2651,
|
| 67 |
+
"file_note": 40,
|
| 68 |
+
"none": 0,
|
| 69 |
+
"publisher": 0
|
| 70 |
+
},
|
| 71 |
+
"CC-BY-SA-4.0": {
|
| 72 |
+
"depositor": 8937,
|
| 73 |
+
"file_note": 503,
|
| 74 |
+
"none": 0,
|
| 75 |
+
"publisher": 0
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"codes": [
|
| 79 |
+
"file_note",
|
| 80 |
+
"publisher",
|
| 81 |
+
"depositor",
|
| 82 |
+
"none"
|
| 83 |
+
],
|
| 84 |
+
"counts": {
|
| 85 |
+
"depositor": 35186,
|
| 86 |
+
"file_note": 2657,
|
| 87 |
+
"none": 0,
|
| 88 |
+
"publisher": 0
|
| 89 |
+
},
|
| 90 |
+
"created_before_licence_version": {
|
| 91 |
+
"by_label": {
|
| 92 |
+
"CC-BY-3.0": 106,
|
| 93 |
+
"CC-BY-3.0-PL": 85,
|
| 94 |
+
"CC-BY-4.0": 2279,
|
| 95 |
+
"CC-BY-SA-3.0-PL": 49,
|
| 96 |
+
"CC-BY-SA-4.0": 1470
|
| 97 |
+
},
|
| 98 |
+
"characters": 184805600,
|
| 99 |
+
"hand_check": "seeded sample of 100 of these rows: in 90 the `created` year is printed in the first 8000 or last 5000 characters; in the other 10 the text cites no later year than `created`",
|
| 100 |
+
"note": "a lower bound: the years are those of the generic licence texts (the Polish port may be later, which would add rows), and the platform shows the licence it has today, which may be later than the issue",
|
| 101 |
+
"overlap": {
|
| 102 |
+
"already_dropped_by_another_rule": {
|
| 103 |
+
"file_is_another_work": 3,
|
| 104 |
+
"printed_licence_nc_or_nd": 1,
|
| 105 |
+
"reprint_or_prior_publication": 1,
|
| 106 |
+
"restriction_notice_no_cc_note": 26,
|
| 107 |
+
"translation_of_earlier_publication": 1
|
| 108 |
+
},
|
| 109 |
+
"dropped_with_this_reason": 3957,
|
| 110 |
+
"flipped_from_keep": {
|
| 111 |
+
"not_a_notice_on_the_work": 1,
|
| 112 |
+
"printed_sa_label_by": 1,
|
| 113 |
+
"restriction_notice_beside_cc_note": 5
|
| 114 |
+
},
|
| 115 |
+
"not_otherwise_in_review": 3950
|
| 116 |
+
},
|
| 117 |
+
"precedence": "a row some other rule dropped keeps that rule's reason; a row only kept by another rule is dropped here",
|
| 118 |
+
"release_year": {
|
| 119 |
+
"CC-BY-2.0": 2004,
|
| 120 |
+
"CC-BY-3.0": 2007,
|
| 121 |
+
"CC-BY-3.0-PL": 2007,
|
| 122 |
+
"CC-BY-4.0": 2013,
|
| 123 |
+
"CC-BY-SA-3.0": 2007,
|
| 124 |
+
"CC-BY-SA-3.0-PL": 2007,
|
| 125 |
+
"CC-BY-SA-4.0": 2013
|
| 126 |
+
},
|
| 127 |
+
"rows": 3989,
|
| 128 |
+
"rule": "the `created` start year is earlier than the first year of the label's licence version; the row is dropped",
|
| 129 |
+
"tokens": 71278767
|
| 130 |
+
},
|
| 131 |
+
"dates": {
|
| 132 |
+
"depositor": "2026-10-05/2026-10-06",
|
| 133 |
+
"file_note": "the row's `added` date"
|
| 134 |
+
},
|
| 135 |
+
"hand_check": {
|
| 136 |
+
"file_note": "seeded sample of 60 of the file_note rows read in context: 60 genuine notes of the work's own licence (one carries a general 'unless stated otherwise' note of the publishing university)",
|
| 137 |
+
"not_measured": "rows with a licence printed in words or a form the parser does not read (false negatives of file_note) were not counted"
|
| 138 |
+
},
|
| 139 |
+
"hand_read": {
|
| 140 |
+
"file_mismatch": "all 51 rows read; the looser sets (title only absent: 476 rows, author only absent: 458, the 51 excluded) were sampled, 30 of each: 0 of the 60 were a different work (other language, encoding or front matter)",
|
| 141 |
+
"printed_note": "all 13 rows read",
|
| 142 |
+
"prior_publication": "every row with a hit of the tight families (reprint words in the front matter, permission, earlier publication, title markers, translator credit and translation statement) was read in context; the broad translator-word family (1,326 rows, mostly footnotes) was not. Rows read and not confirmed (prior_publication_any minus prior_publication_in_review) are not in the review",
|
| 143 |
+
"restriction_notice": "all 120 hits read in context; 6 of the 110 outside file_note rows are not a notice on the work"
|
| 144 |
+
},
|
| 145 |
+
"input": {
|
| 146 |
+
"license_api_sha256": "51e0bf7900e016f4b0102eecfd5032f3969a566899bf8ba094abad9f4f4578b5",
|
| 147 |
+
"rows_before_review": 41985,
|
| 148 |
+
"rows_before_review_content_sha256": "cc4ad9ce16aaef3c7bc5197743ad58182e3d5011f78cbf53896083e7a8541954",
|
| 149 |
+
"v0.2.5_parquet_sha256": "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26"
|
| 150 |
+
},
|
| 151 |
+
"issue": "slayerlabs/polish-dynaword-v2#111",
|
| 152 |
+
"journal_adoption": {
|
| 153 |
+
"consequence": "an issue from before its journal adopted CC may remain wherever the publication year is not earlier than the licence version",
|
| 154 |
+
"obtainable": false,
|
| 155 |
+
"proxy": "created_before_licence_version",
|
| 156 |
+
"reason": "GET /api/journals/{id} returns the journal's current licence only, the shipped rows carry no journal key, and fetching every item takes about 26 hours at the polite rate"
|
| 157 |
+
},
|
| 158 |
+
"nominated_rows": {
|
| 159 |
+
"file_mismatch": 51,
|
| 160 |
+
"printed_note": 13,
|
| 161 |
+
"prior_publication": {
|
| 162 |
+
"earlier": 77,
|
| 163 |
+
"permission": 10,
|
| 164 |
+
"reprint_word": 180,
|
| 165 |
+
"title_reprint": 1,
|
| 166 |
+
"title_translation": 9,
|
| 167 |
+
"translation_statement": 220,
|
| 168 |
+
"translator_credit": 63
|
| 169 |
+
},
|
| 170 |
+
"prior_publication_any": 540,
|
| 171 |
+
"prior_publication_in_review": 73,
|
| 172 |
+
"restriction_notice": {
|
| 173 |
+
"arr_only/file_note": 6,
|
| 174 |
+
"arr_only/none": 8,
|
| 175 |
+
"clause/file_note": 4,
|
| 176 |
+
"clause/none": 102
|
| 177 |
+
}
|
| 178 |
+
},
|
| 179 |
+
"not_screened": {
|
| 180 |
+
"translations_of_source_texts": {
|
| 181 |
+
"characters": 270651,
|
| 182 |
+
"dropped_by_review": {
|
| 183 |
+
"biblioteka_nauki_articles_534737": "reprint_or_prior_publication"
|
| 184 |
+
},
|
| 185 |
+
"ids": [
|
| 186 |
+
"biblioteka_nauki_articles_1806845",
|
| 187 |
+
"biblioteka_nauki_articles_1806823",
|
| 188 |
+
"biblioteka_nauki_articles_1806867",
|
| 189 |
+
"biblioteka_nauki_articles_2057384",
|
| 190 |
+
"biblioteka_nauki_articles_1194054",
|
| 191 |
+
"biblioteka_nauki_articles_1917278",
|
| 192 |
+
"biblioteka_nauki_articles_699650",
|
| 193 |
+
"biblioteka_nauki_articles_555820"
|
| 194 |
+
],
|
| 195 |
+
"note": "translations of ancient, archival or literary texts by the item's author; the original is not a rights-held work in the sense of the rule. One of the 9 is in the review under a prior-publication reason and is dropped (`dropped_by_review`)",
|
| 196 |
+
"rows": 8,
|
| 197 |
+
"tokens": 109996
|
| 198 |
+
}
|
| 199 |
+
},
|
| 200 |
+
"overlaps": {
|
| 201 |
+
"biblioteka_nauki_articles_1396194": [
|
| 202 |
+
"created_before_licence_version",
|
| 203 |
+
"file_is_another_work"
|
| 204 |
+
],
|
| 205 |
+
"biblioteka_nauki_articles_2137969": [
|
| 206 |
+
"created_before_licence_version",
|
| 207 |
+
"translation_of_earlier_publication"
|
| 208 |
+
],
|
| 209 |
+
"biblioteka_nauki_articles_336963": [
|
| 210 |
+
"created_before_licence_version",
|
| 211 |
+
"not_a_notice_on_the_work"
|
| 212 |
+
],
|
| 213 |
+
"biblioteka_nauki_articles_371128": [
|
| 214 |
+
"created_before_licence_version",
|
| 215 |
+
"reprint_or_prior_publication"
|
| 216 |
+
],
|
| 217 |
+
"biblioteka_nauki_articles_629493": [
|
| 218 |
+
"created_before_licence_version",
|
| 219 |
+
"file_is_another_work"
|
| 220 |
+
],
|
| 221 |
+
"biblioteka_nauki_articles_697912": [
|
| 222 |
+
"created_before_licence_version",
|
| 223 |
+
"restriction_notice_no_cc_note"
|
| 224 |
+
],
|
| 225 |
+
"biblioteka_nauki_articles_697939": [
|
| 226 |
+
"created_before_licence_version",
|
| 227 |
+
"restriction_notice_no_cc_note"
|
| 228 |
+
],
|
| 229 |
+
"biblioteka_nauki_articles_697973": [
|
| 230 |
+
"created_before_licence_version",
|
| 231 |
+
"restriction_notice_no_cc_note"
|
| 232 |
+
],
|
| 233 |
+
"biblioteka_nauki_articles_697985": [
|
| 234 |
+
"created_before_licence_version",
|
| 235 |
+
"restriction_notice_no_cc_note"
|
| 236 |
+
],
|
| 237 |
+
"biblioteka_nauki_articles_697987": [
|
| 238 |
+
"created_before_licence_version",
|
| 239 |
+
"restriction_notice_no_cc_note"
|
| 240 |
+
],
|
| 241 |
+
"biblioteka_nauki_articles_697989": [
|
| 242 |
+
"created_before_licence_version",
|
| 243 |
+
"restriction_notice_no_cc_note"
|
| 244 |
+
],
|
| 245 |
+
"biblioteka_nauki_articles_697991": [
|
| 246 |
+
"created_before_licence_version",
|
| 247 |
+
"restriction_notice_no_cc_note"
|
| 248 |
+
],
|
| 249 |
+
"biblioteka_nauki_articles_697993": [
|
| 250 |
+
"created_before_licence_version",
|
| 251 |
+
"restriction_notice_no_cc_note"
|
| 252 |
+
],
|
| 253 |
+
"biblioteka_nauki_articles_697997": [
|
| 254 |
+
"created_before_licence_version",
|
| 255 |
+
"restriction_notice_no_cc_note"
|
| 256 |
+
],
|
| 257 |
+
"biblioteka_nauki_articles_698011": [
|
| 258 |
+
"created_before_licence_version",
|
| 259 |
+
"restriction_notice_no_cc_note"
|
| 260 |
+
],
|
| 261 |
+
"biblioteka_nauki_articles_698057": [
|
| 262 |
+
"created_before_licence_version",
|
| 263 |
+
"restriction_notice_no_cc_note"
|
| 264 |
+
],
|
| 265 |
+
"biblioteka_nauki_articles_698309": [
|
| 266 |
+
"created_before_licence_version",
|
| 267 |
+
"restriction_notice_no_cc_note"
|
| 268 |
+
],
|
| 269 |
+
"biblioteka_nauki_articles_916222": [
|
| 270 |
+
"created_before_licence_version",
|
| 271 |
+
"restriction_notice_no_cc_note"
|
| 272 |
+
],
|
| 273 |
+
"biblioteka_nauki_articles_916223": [
|
| 274 |
+
"created_before_licence_version",
|
| 275 |
+
"restriction_notice_no_cc_note"
|
| 276 |
+
],
|
| 277 |
+
"biblioteka_nauki_articles_916224": [
|
| 278 |
+
"created_before_licence_version",
|
| 279 |
+
"restriction_notice_no_cc_note"
|
| 280 |
+
],
|
| 281 |
+
"biblioteka_nauki_articles_916225": [
|
| 282 |
+
"created_before_licence_version",
|
| 283 |
+
"restriction_notice_no_cc_note"
|
| 284 |
+
],
|
| 285 |
+
"biblioteka_nauki_articles_916226": [
|
| 286 |
+
"created_before_licence_version",
|
| 287 |
+
"restriction_notice_no_cc_note"
|
| 288 |
+
],
|
| 289 |
+
"biblioteka_nauki_articles_916227": [
|
| 290 |
+
"created_before_licence_version",
|
| 291 |
+
"restriction_notice_no_cc_note"
|
| 292 |
+
],
|
| 293 |
+
"biblioteka_nauki_articles_916228": [
|
| 294 |
+
"created_before_licence_version",
|
| 295 |
+
"restriction_notice_no_cc_note"
|
| 296 |
+
],
|
| 297 |
+
"biblioteka_nauki_articles_916229": [
|
| 298 |
+
"created_before_licence_version",
|
| 299 |
+
"restriction_notice_no_cc_note"
|
| 300 |
+
],
|
| 301 |
+
"biblioteka_nauki_articles_916230": [
|
| 302 |
+
"created_before_licence_version",
|
| 303 |
+
"restriction_notice_no_cc_note"
|
| 304 |
+
],
|
| 305 |
+
"biblioteka_nauki_articles_916235": [
|
| 306 |
+
"created_before_licence_version",
|
| 307 |
+
"restriction_notice_no_cc_note"
|
| 308 |
+
],
|
| 309 |
+
"biblioteka_nauki_articles_916239": [
|
| 310 |
+
"created_before_licence_version",
|
| 311 |
+
"restriction_notice_no_cc_note"
|
| 312 |
+
],
|
| 313 |
+
"biblioteka_nauki_articles_916240": [
|
| 314 |
+
"created_before_licence_version",
|
| 315 |
+
"restriction_notice_no_cc_note"
|
| 316 |
+
],
|
| 317 |
+
"biblioteka_nauki_books_1076491": [
|
| 318 |
+
"created_before_licence_version",
|
| 319 |
+
"restriction_notice_beside_cc_note"
|
| 320 |
+
],
|
| 321 |
+
"biblioteka_nauki_books_1076500": [
|
| 322 |
+
"created_before_licence_version",
|
| 323 |
+
"printed_licence_nc_or_nd"
|
| 324 |
+
],
|
| 325 |
+
"biblioteka_nauki_books_1076514": [
|
| 326 |
+
"created_before_licence_version",
|
| 327 |
+
"restriction_notice_beside_cc_note"
|
| 328 |
+
],
|
| 329 |
+
"biblioteka_nauki_books_1182283": [
|
| 330 |
+
"created_before_licence_version",
|
| 331 |
+
"printed_sa_label_by"
|
| 332 |
+
],
|
| 333 |
+
"biblioteka_nauki_books_1389278": [
|
| 334 |
+
"created_before_licence_version",
|
| 335 |
+
"restriction_notice_beside_cc_note"
|
| 336 |
+
],
|
| 337 |
+
"biblioteka_nauki_books_1409888": [
|
| 338 |
+
"created_before_licence_version",
|
| 339 |
+
"restriction_notice_beside_cc_note"
|
| 340 |
+
],
|
| 341 |
+
"biblioteka_nauki_books_1623111": [
|
| 342 |
+
"created_before_licence_version",
|
| 343 |
+
"file_is_another_work",
|
| 344 |
+
"restriction_notice_no_cc_note"
|
| 345 |
+
],
|
| 346 |
+
"biblioteka_nauki_books_1790306": [
|
| 347 |
+
"created_before_licence_version",
|
| 348 |
+
"restriction_notice_beside_cc_note"
|
| 349 |
+
],
|
| 350 |
+
"biblioteka_nauki_books_1930491": [
|
| 351 |
+
"created_before_licence_version",
|
| 352 |
+
"restriction_notice_no_cc_note"
|
| 353 |
+
],
|
| 354 |
+
"biblioteka_nauki_books_1954543": [
|
| 355 |
+
"api_flagged_reprint_translation",
|
| 356 |
+
"restriction_notice_no_cc_note"
|
| 357 |
+
],
|
| 358 |
+
"biblioteka_nauki_books_949210": [
|
| 359 |
+
"created_before_licence_version",
|
| 360 |
+
"restriction_notice_no_cc_note"
|
| 361 |
+
]
|
| 362 |
+
},
|
| 363 |
+
"platform_check": {
|
| 364 |
+
"answered_200": 42056,
|
| 365 |
+
"http404": 12,
|
| 366 |
+
"note": "the 12 http404 rows are withheld, so no shipped row has `none`; see biblioteka_nauki.license-evidence.json",
|
| 367 |
+
"retrieved": "2026-10-05..2026-10-06",
|
| 368 |
+
"rows_asked": 42068
|
| 369 |
+
},
|
| 370 |
+
"publisher_check": {
|
| 371 |
+
"done": false,
|
| 372 |
+
"note": "no journal or publisher page was read; the issue allows `publisher` as a second basis"
|
| 373 |
+
},
|
| 374 |
+
"regexes": {
|
| 375 |
+
"ARR": "(?i)wszelkie\\s+prawa\\s+(?:zastrzeżone|autorskie\\s+zastrzeżone)|wszystkie\\s+prawa\\s+zastrzeżone|all\\s+rights\\s+reserved|tous\\s+droits\\s+réservés|alle\\s+rechte\\s+vorbehalten",
|
| 376 |
+
"CLAUSE_AFTER_ARR": "(?i)nie\\s+(?:może|mogą)\\b|bez\\s+(?:pisemnej\\s+)?zgody|without\\s+(?:the\\s+)?(?:prior\\s+)?(?:written\\s+)?permission|zabronion|ograniczona",
|
| 377 |
+
"CONSENT": "(?i)(?:przedrukowywanie|przedruk\\w*|kopiowanie|powielanie|rozpowszechnianie|reprodukowanie|rozpowszechniania)[^.]{0,100}(?:bez\\s+(?:pisemnej\\s+|uprzedniej\\s+|uprzedniego\\s+)?(?:zgody|zezwolenia)|zabronion\\w+|wymaga\\w*\\s+zgody)|(?:reprint\\w*|reproduc\\w*|copying|redistribut\\w*|duplicat\\w*)[^.]{0,80}(?:without\\s+(?:the\\s+)?(?:prior\\s+)?(?:written\\s+)?(?:permission|consent)|prohibited|forbidden|not\\s+permitted)|bez\\s+(?:pisemnej\\s+)?zgody\\s+(?:wydawcy|autora|redakcji)|zabrania\\s+się\\s+(?:kopiowania|powielania|przedruk)|swoboda\\s+użytkownika\\s+ograniczona",
|
| 378 |
+
"R2_CREDIT": "(?:\\bPrzekład|\\bTłumaczenie|\\bTranslated by|\\bTranslation by|\\bPrzełożył[a]?|\\bTłumaczył[a]?|\\bTłum\\.|\\bPrzeł\\.|\\bPrzekład z [^.]{3,40}:)\\s*:?\\s*([A-ZŁŚŻŹĆ][a-ząęółśżźćńü\\-]{2,}(?:\\s+[A-ZŁŚŻŹĆ][a-ząęółśżźćńü\\-]{2,}){1,2})\\s*(?:[.\\n]|$|\\s(?=[A-Z0-9]))",
|
| 379 |
+
"R2_FRONT": {
|
| 380 |
+
"earlier": "(?i)\\b(?:first|originally|previously|earlier)\\s+(?:published|appeared)\\b|\\boriginally\\s+appeared\\b|\\bpublished\\s+(?:earlier|previously|originally|first)\\b|\\bpierwotnie\\s+(?:opublik|ukaza|wydan)\\w+|\\bukaza\\w+\\s+się\\s+(?:po\\s+raz\\s+pierwszy|wcześniej|pierwotnie|uprzednio)|\\b(?:publikowan|opublikowan|drukowan)\\w+\\s+(?:wcześniej|uprzednio|pierwotnie)",
|
| 381 |
+
"permission": "(?i)\\b(?:reprinted|reproduced|translated|published|republished|printed)\\s+(?:here\\s+)?(?:with|by)\\s+(?:the\\s+)?(?:kind\\s+)?permission|\\b(?:przedrukowan\\w+|przetłumaczon\\w+|opublikowan\\w+|zamieszczon\\w+|publikowan\\w+|tłumaczeni\\w+|wydan\\w+)\\s+(?:artyku\\w+\\s+)?(?:za|na)\\s+(?:zgodą|zezwoleniem|podstawie\\s+zgody)|\\bza\\s+(?:zgodą|zezwoleniem)\\s+(?:wydawcy|wydawnictwa|redakcji|właściciela\\s+praw)|kind\\s+permission",
|
| 382 |
+
"reprint_word": "(?i)\\bprzedruk\\w*|\\bpierwodruk\\w*|(?<![\\w-])reprint(?:ed)?\\b"
|
| 383 |
+
},
|
| 384 |
+
"R2_STATEMENT": "(?i)\\b(?:polish\\s+translation|polski\\s+przekład|przekład\\s+polski|tłumaczenie\\s+polskie|polskie\\s+tłumaczenie|translated\\s+(?:from|into)|przetłumaczon\\w+\\s+(?:z|na)|tłumaczenie\\s+(?:artyku|tekst)\\w*|przekład\\s+(?:artyku|tekst)\\w*|za\\s+zgodą\\s+autora\\s+tłumaczenia|tekst\\s+(?:został\\s+)?przełożon\\w+)",
|
| 385 |
+
"R2_TITLE": {
|
| 386 |
+
"title_reprint": "(?i)\\bprzedruk\\b|\\breprint\\b|\\(przedruk",
|
| 387 |
+
"title_translation": "(?i)\\((?:przekład|tłum\\w*|translation|translated)[^)]*\\)|\\[(?:przekład|tłum\\w*|translation)|\\bprzekład\\s+z\\b|\\btłumaczenie\\s+z\\b|\\btranslated\\s+from\\b|\\btranslation\\s+of\\b"
|
| 388 |
+
}
|
| 389 |
+
},
|
| 390 |
+
"review": {
|
| 391 |
+
"by_reason": {
|
| 392 |
+
"api_flagged_reprint_translation": {
|
| 393 |
+
"characters": 2189037,
|
| 394 |
+
"rows": 5,
|
| 395 |
+
"tokens": 844892
|
| 396 |
+
},
|
| 397 |
+
"arr_only_no_cc_note": {
|
| 398 |
+
"characters": 2104519,
|
| 399 |
+
"rows": 5,
|
| 400 |
+
"tokens": 804452
|
| 401 |
+
},
|
| 402 |
+
"created_before_licence_version": {
|
| 403 |
+
"characters": 181784176,
|
| 404 |
+
"rows": 3957,
|
| 405 |
+
"tokens": 70103154
|
| 406 |
+
},
|
| 407 |
+
"discusses_licence": {
|
| 408 |
+
"characters": 101066,
|
| 409 |
+
"rows": 3,
|
| 410 |
+
"tokens": 36837
|
| 411 |
+
},
|
| 412 |
+
"file_is_another_work": {
|
| 413 |
+
"characters": 1237708,
|
| 414 |
+
"rows": 16,
|
| 415 |
+
"tokens": 455178
|
| 416 |
+
},
|
| 417 |
+
"front_matter_item": {
|
| 418 |
+
"characters": 6914,
|
| 419 |
+
"rows": 2,
|
| 420 |
+
"tokens": 2880
|
| 421 |
+
},
|
| 422 |
+
"item_found_later_in_file": {
|
| 423 |
+
"characters": 178625,
|
| 424 |
+
"rows": 3,
|
| 425 |
+
"tokens": 72855
|
| 426 |
+
},
|
| 427 |
+
"not_a_notice_on_the_work": {
|
| 428 |
+
"characters": 158813,
|
| 429 |
+
"rows": 5,
|
| 430 |
+
"tokens": 61768
|
| 431 |
+
},
|
| 432 |
+
"printed_by_label_sa": {
|
| 433 |
+
"characters": 169732,
|
| 434 |
+
"rows": 2,
|
| 435 |
+
"tokens": 64912
|
| 436 |
+
},
|
| 437 |
+
"printed_licence_nc_or_nd": {
|
| 438 |
+
"characters": 705767,
|
| 439 |
+
"rows": 4,
|
| 440 |
+
"tokens": 269700
|
| 441 |
+
},
|
| 442 |
+
"printed_sa_label_by": {
|
| 443 |
+
"characters": 482353,
|
| 444 |
+
"rows": 1,
|
| 445 |
+
"tokens": 185072
|
| 446 |
+
},
|
| 447 |
+
"reprint_or_prior_publication": {
|
| 448 |
+
"characters": 1475398,
|
| 449 |
+
"rows": 30,
|
| 450 |
+
"tokens": 531012
|
| 451 |
+
},
|
| 452 |
+
"republished_by_permission": {
|
| 453 |
+
"characters": 1359754,
|
| 454 |
+
"rows": 11,
|
| 455 |
+
"tokens": 504063
|
| 456 |
+
},
|
| 457 |
+
"restriction_notice_beside_cc_note": {
|
| 458 |
+
"characters": 2442662,
|
| 459 |
+
"rows": 5,
|
| 460 |
+
"tokens": 915329
|
| 461 |
+
},
|
| 462 |
+
"restriction_notice_no_cc_note": {
|
| 463 |
+
"characters": 14700907,
|
| 464 |
+
"rows": 97,
|
| 465 |
+
"tokens": 5882338
|
| 466 |
+
},
|
| 467 |
+
"same_author_prior_version": {
|
| 468 |
+
"characters": 295509,
|
| 469 |
+
"rows": 5,
|
| 470 |
+
"tokens": 117106
|
| 471 |
+
},
|
| 472 |
+
"text_garbled": {
|
| 473 |
+
"characters": 775097,
|
| 474 |
+
"rows": 25,
|
| 475 |
+
"tokens": 466995
|
| 476 |
+
},
|
| 477 |
+
"title_in_other_language": {
|
| 478 |
+
"characters": 193470,
|
| 479 |
+
"rows": 5,
|
| 480 |
+
"tokens": 74078
|
| 481 |
+
},
|
| 482 |
+
"translation_of_cc_original": {
|
| 483 |
+
"characters": 70772,
|
| 484 |
+
"rows": 2,
|
| 485 |
+
"tokens": 25009
|
| 486 |
+
},
|
| 487 |
+
"translation_of_earlier_publication": {
|
| 488 |
+
"characters": 902932,
|
| 489 |
+
"rows": 17,
|
| 490 |
+
"tokens": 346552
|
| 491 |
+
},
|
| 492 |
+
"translation_title_marker": {
|
| 493 |
+
"characters": 119365,
|
| 494 |
+
"rows": 5,
|
| 495 |
+
"tokens": 47745
|
| 496 |
+
}
|
| 497 |
+
},
|
| 498 |
+
"decided": {
|
| 499 |
+
"drop": {
|
| 500 |
+
"characters": 204475044,
|
| 501 |
+
"rows": 4142,
|
| 502 |
+
"tokens": 78984634
|
| 503 |
+
},
|
| 504 |
+
"keep": {
|
| 505 |
+
"characters": 6979532,
|
| 506 |
+
"rows": 63,
|
| 507 |
+
"tokens": 2827293
|
| 508 |
+
}
|
| 509 |
+
},
|
| 510 |
+
"file": "biblioteka_nauki.review.csv",
|
| 511 |
+
"kept": {
|
| 512 |
+
"note": "SHA-256 of every column of the kept rows (id, text, source, added, created, token_count, license, author), as they were before the review; the test recomputes it from the shipped Parquet",
|
| 513 |
+
"rows": 37843,
|
| 514 |
+
"rows_sha256": "49a6272befa665daa9c36abd616c951efd0459e5d35a56adea1dc04440772744"
|
| 515 |
+
},
|
| 516 |
+
"note": "drops decided by the maintainer on 2026-10-20 (v2#111); the table lists every row a rule nominated, `drop` or `keep`, and nothing else",
|
| 517 |
+
"reasons": {
|
| 518 |
+
"drop": {
|
| 519 |
+
"api_flagged_reprint_translation": "the platform flags the item as a reprint or a translation (`reprintPublication` or `translationPublication`)",
|
| 520 |
+
"created_before_licence_version": "the `created` start year is earlier than the first year of the label's licence version (RELEASE), so the licence on the platform cannot have been the one chosen at publication",
|
| 521 |
+
"file_is_another_work": "neither the title nor any author of the description appears where the text starts, ends or is attributed; the file is a different work",
|
| 522 |
+
"printed_licence_nc_or_nd": "the text prints a NonCommercial or NoDerivatives licence; the platform's label is a CC BY or BY-SA licence",
|
| 523 |
+
"reprint_or_prior_publication": "the text says the work was published before, or is a reprint, in a place other than this platform",
|
| 524 |
+
"republished_by_permission": "the text says it is a reprint or a translation published with the permission of an author or publisher",
|
| 525 |
+
"restriction_notice_no_cc_note": "the front or back matter prints a restriction on copying or reproduction, and prints no CC licence of its own",
|
| 526 |
+
"translation_of_earlier_publication": "the text is a translation of a work published elsewhere, stated in the text or by a translator credit",
|
| 527 |
+
"translation_title_marker": "the citation title marks the item as a translation of a third party's text"
|
| 528 |
+
},
|
| 529 |
+
"keep": {
|
| 530 |
+
"arr_only_no_cc_note": "the front or back matter prints 'all rights reserved' without a clause and prints no CC licence of its own",
|
| 531 |
+
"discusses_licence": "the text discusses licences; the printed licence is not a note about the work",
|
| 532 |
+
"front_matter_item": "the item is a list of reviewers or of abbreviations; the description names a different item of the issue",
|
| 533 |
+
"item_found_later_in_file": "the title and author appear later in the file than the first 6000 characters",
|
| 534 |
+
"not_a_notice_on_the_work": "a phrase found by the rule is a quoted source, a discussion or a notice on something else",
|
| 535 |
+
"printed_by_label_sa": "the text prints CC BY; the label is CC BY-SA (the label is the less permissive)",
|
| 536 |
+
"printed_sa_label_by": "the text prints CC BY-SA; the label is CC BY (the label is the more permissive)",
|
| 537 |
+
"restriction_notice_beside_cc_note": "the front matter prints 'all rights reserved' or a restriction and, in the same front matter, a CC licence with the label's elements",
|
| 538 |
+
"same_author_prior_version": "the text is a revised or translated version of the authors' own earlier publication",
|
| 539 |
+
"text_garbled": "the text is not readable (shifted letters or noise), so no title or author can match; a data-quality issue, not a licence issue",
|
| 540 |
+
"title_in_other_language": "the title appears in another language than the description's",
|
| 541 |
+
"translation_of_cc_original": "the printed CC licence is the licence of the original that the text translates"
|
| 542 |
+
}
|
| 543 |
+
},
|
| 544 |
+
"rows": 4205,
|
| 545 |
+
"rule_order": [
|
| 546 |
+
"printed_note",
|
| 547 |
+
"prior_publication",
|
| 548 |
+
"file_mismatch",
|
| 549 |
+
"restriction_notice",
|
| 550 |
+
"created_before_licence_version"
|
| 551 |
+
],
|
| 552 |
+
"sha256": "25e27c96280b6af547f2fdfb9d49a2d35861e96195a647047d6836af4a68a401",
|
| 553 |
+
"shipped": {
|
| 554 |
+
"characters": 1534529869,
|
| 555 |
+
"rows": 37843,
|
| 556 |
+
"tokens": 590924796
|
| 557 |
+
},
|
| 558 |
+
"source": {
|
| 559 |
+
"characters": 1739004913,
|
| 560 |
+
"rows": 41985,
|
| 561 |
+
"tokens": 669909430
|
| 562 |
+
}
|
| 563 |
+
},
|
| 564 |
+
"rule": "file_note: licence_basis.note_vs_label(text, label) is 'file_note', i.e. a CC note in the front or back matter, not about a photo or a quoted source, with the label's elements; depositor: every other row, whose label is the platform's licence object for the item",
|
| 565 |
+
"rules": {
|
| 566 |
+
"created_before_licence_version": {
|
| 567 |
+
"by_reason": {
|
| 568 |
+
"created_before_licence_version": {
|
| 569 |
+
"characters": 184805600,
|
| 570 |
+
"rows": 3989,
|
| 571 |
+
"tokens": 71278767
|
| 572 |
+
}
|
| 573 |
+
},
|
| 574 |
+
"nominated": "the `created` start year is earlier than RELEASE[label]"
|
| 575 |
+
},
|
| 576 |
+
"file_mismatch": {
|
| 577 |
+
"by_reason": {
|
| 578 |
+
"file_is_another_work": {
|
| 579 |
+
"characters": 1237708,
|
| 580 |
+
"rows": 16,
|
| 581 |
+
"tokens": 455178
|
| 582 |
+
},
|
| 583 |
+
"front_matter_item": {
|
| 584 |
+
"characters": 6914,
|
| 585 |
+
"rows": 2,
|
| 586 |
+
"tokens": 2880
|
| 587 |
+
},
|
| 588 |
+
"item_found_later_in_file": {
|
| 589 |
+
"characters": 178625,
|
| 590 |
+
"rows": 3,
|
| 591 |
+
"tokens": 72855
|
| 592 |
+
},
|
| 593 |
+
"text_garbled": {
|
| 594 |
+
"characters": 775097,
|
| 595 |
+
"rows": 25,
|
| 596 |
+
"tokens": 466995
|
| 597 |
+
},
|
| 598 |
+
"title_in_other_language": {
|
| 599 |
+
"characters": 193470,
|
| 600 |
+
"rows": 5,
|
| 601 |
+
"tokens": 74078
|
| 602 |
+
}
|
| 603 |
+
},
|
| 604 |
+
"nominated": "file_mismatch(text, citation)"
|
| 605 |
+
},
|
| 606 |
+
"printed_note": {
|
| 607 |
+
"by_reason": {
|
| 608 |
+
"discusses_licence": {
|
| 609 |
+
"characters": 101066,
|
| 610 |
+
"rows": 3,
|
| 611 |
+
"tokens": 36837
|
| 612 |
+
},
|
| 613 |
+
"printed_by_label_sa": {
|
| 614 |
+
"characters": 169732,
|
| 615 |
+
"rows": 2,
|
| 616 |
+
"tokens": 64912
|
| 617 |
+
},
|
| 618 |
+
"printed_licence_nc_or_nd": {
|
| 619 |
+
"characters": 705767,
|
| 620 |
+
"rows": 4,
|
| 621 |
+
"tokens": 269700
|
| 622 |
+
},
|
| 623 |
+
"printed_sa_label_by": {
|
| 624 |
+
"characters": 918857,
|
| 625 |
+
"rows": 2,
|
| 626 |
+
"tokens": 342323
|
| 627 |
+
},
|
| 628 |
+
"translation_of_cc_original": {
|
| 629 |
+
"characters": 70772,
|
| 630 |
+
"rows": 2,
|
| 631 |
+
"tokens": 25009
|
| 632 |
+
}
|
| 633 |
+
},
|
| 634 |
+
"nominated": "licence_basis.note_vs_label(...) == 'conflict'"
|
| 635 |
+
},
|
| 636 |
+
"prior_publication": {
|
| 637 |
+
"by_reason": {
|
| 638 |
+
"api_flagged_reprint_translation": {
|
| 639 |
+
"characters": 2189037,
|
| 640 |
+
"rows": 5,
|
| 641 |
+
"tokens": 844892
|
| 642 |
+
},
|
| 643 |
+
"reprint_or_prior_publication": {
|
| 644 |
+
"characters": 1475398,
|
| 645 |
+
"rows": 30,
|
| 646 |
+
"tokens": 531012
|
| 647 |
+
},
|
| 648 |
+
"republished_by_permission": {
|
| 649 |
+
"characters": 1359754,
|
| 650 |
+
"rows": 11,
|
| 651 |
+
"tokens": 504063
|
| 652 |
+
},
|
| 653 |
+
"same_author_prior_version": {
|
| 654 |
+
"characters": 295509,
|
| 655 |
+
"rows": 5,
|
| 656 |
+
"tokens": 117106
|
| 657 |
+
},
|
| 658 |
+
"translation_of_earlier_publication": {
|
| 659 |
+
"characters": 902932,
|
| 660 |
+
"rows": 17,
|
| 661 |
+
"tokens": 346552
|
| 662 |
+
},
|
| 663 |
+
"translation_title_marker": {
|
| 664 |
+
"characters": 119365,
|
| 665 |
+
"rows": 5,
|
| 666 |
+
"tokens": 47745
|
| 667 |
+
}
|
| 668 |
+
},
|
| 669 |
+
"nominated": "any regex family of R2 in the front matter or the citation title, or an API flag; the review lists only the rows whose reading confirmed a reprint, a translation or an earlier publication"
|
| 670 |
+
},
|
| 671 |
+
"restriction_notice": {
|
| 672 |
+
"by_reason": {
|
| 673 |
+
"arr_only_no_cc_note": {
|
| 674 |
+
"characters": 2104519,
|
| 675 |
+
"rows": 5,
|
| 676 |
+
"tokens": 804452
|
| 677 |
+
},
|
| 678 |
+
"not_a_notice_on_the_work": {
|
| 679 |
+
"characters": 185978,
|
| 680 |
+
"rows": 6,
|
| 681 |
+
"tokens": 72765
|
| 682 |
+
},
|
| 683 |
+
"restriction_notice_beside_cc_note": {
|
| 684 |
+
"characters": 4924931,
|
| 685 |
+
"rows": 10,
|
| 686 |
+
"tokens": 1848354
|
| 687 |
+
},
|
| 688 |
+
"restriction_notice_no_cc_note": {
|
| 689 |
+
"characters": 16296650,
|
| 690 |
+
"rows": 99,
|
| 691 |
+
"tokens": 6511000
|
| 692 |
+
}
|
| 693 |
+
},
|
| 694 |
+
"nominated": "restriction(text) is not None"
|
| 695 |
+
}
|
| 696 |
+
},
|
| 697 |
+
"source": "biblioteka_nauki",
|
| 698 |
+
"urls": {
|
| 699 |
+
"depositor": "https://bibliotekanauki.pl/api/{articles|books|chapters}/{n}",
|
| 700 |
+
"file_note": "https://bibliotekanauki.pl/{articles|books|chapters}/{n}"
|
| 701 |
+
}
|
| 702 |
+
}
|
data/biblioteka_nauki/biblioteka_nauki.license-evidence.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
| 5 |
"license_spdx": "MIXED (per row: CC-BY-2.0, CC-BY-3.0, CC-BY-3.0-PL, CC-BY-4.0, CC-BY-SA-3.0, CC-BY-SA-3.0-PL, CC-BY-SA-4.0)",
|
| 6 |
"review_scope": "Licence name, URL and version of every one of the 42,068 rows of the previous release (v0.2.5 after the Public Domain Mark drop, Hub PR 62), read from the platform API. Not a review of the texts, of the authors' standing to license, or of third-party material inside the items.",
|
| 7 |
"finding": "The API gives CC BY 2.0 / 3.0 / 3.0 PL / 4.0 and CC BY-SA 3.0 / 3.0 PL / 4.0 per record; v0.2.5 and the first v0.2.6 build collapsed all of them to 4.0 by keeping only license.iconId. The `license` column now holds the API's version. 12 rows the API no longer serves (HTTP 404) are withheld; so are, by the maintainer's decision of 2026-10-06, 56 rows whose text prints a NonCommercial or NoDerivatives licence and 15 rows whose text says it is reprinted or translated by permission of a publisher. articles_2011995 (API: CC BY-SA 4.0; earlier recovery: CC BY) is kept, labelled CC-BY-SA-4.0. No row's text changed.",
|
|
|
|
| 8 |
"upstream_api": "https://bibliotekanauki.pl/api/{articles|books|chapters}/{id}",
|
| 9 |
"retrieved": "2026-10-05..2026-10-06",
|
| 10 |
"retrieval_script": "data/biblioteka_nauki/recover_license_versions.py (one global request clock, 3 workers, 0.15 s between request starts, back-off on 429/5xx, stops on 403 or a non-JSON 200; no CAPTCHA or terms page was met)",
|
|
|
|
| 5 |
"license_spdx": "MIXED (per row: CC-BY-2.0, CC-BY-3.0, CC-BY-3.0-PL, CC-BY-4.0, CC-BY-SA-3.0, CC-BY-SA-3.0-PL, CC-BY-SA-4.0)",
|
| 6 |
"review_scope": "Licence name, URL and version of every one of the 42,068 rows of the previous release (v0.2.5 after the Public Domain Mark drop, Hub PR 62), read from the platform API. Not a review of the texts, of the authors' standing to license, or of third-party material inside the items.",
|
| 7 |
"finding": "The API gives CC BY 2.0 / 3.0 / 3.0 PL / 4.0 and CC BY-SA 3.0 / 3.0 PL / 4.0 per record; v0.2.5 and the first v0.2.6 build collapsed all of them to 4.0 by keeping only license.iconId. The `license` column now holds the API's version. 12 rows the API no longer serves (HTTP 404) are withheld; so are, by the maintainer's decision of 2026-10-06, 56 rows whose text prints a NonCommercial or NoDerivatives licence and 15 rows whose text says it is reprinted or translated by permission of a publisher. articles_2011995 (API: CC BY-SA 4.0; earlier recovery: CC BY) is kept, labelled CC-BY-SA-4.0. No row's text changed.",
|
| 8 |
+
"after_the_review_of_2026_10_20": "The counts in this file (`shipped`, `withheld`, `flagged_action`, `verified`) describe the state of Hub PR 81, before the review of 2026-10-20 (polish-dynaword-v2#111): 4,142 of those 41,985 shipped rows are dropped, among them the 5 rows flagged as a reprint or translation. Current counts are in biblioteka_nauki.review.csv (the 4,205 reviewed rows, each with its decision and reason), biblioteka_nauki.licence-basis.json (the rules and measurements) and stats.json. The API licence per row is unchanged and still in biblioteka_nauki.license-api.json.",
|
| 9 |
"upstream_api": "https://bibliotekanauki.pl/api/{articles|books|chapters}/{id}",
|
| 10 |
"retrieved": "2026-10-05..2026-10-06",
|
| 11 |
"retrieval_script": "data/biblioteka_nauki/recover_license_versions.py (one global request clock, 3 workers, 0.15 s between request starts, back-off on 429/5xx, stops on 403 or a non-JSON 200; no CAPTCHA or terms page was met)",
|
data/biblioteka_nauki/biblioteka_nauki.md
CHANGED
|
@@ -6,7 +6,7 @@ Biblioteka Nauki — Polish open-access scholarly corpus (scientific articles, b
|
|
| 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, with the version the upstream API gives for each record — CC BY (2.0, 3.0, 3.0 PL, 4.0)
|
| 10 |
- **Created (range):** per-document publication year, from each item's bibliotekanauki.pl metadata
|
| 11 |
- **Added:** 2026-06-27
|
| 12 |
|
|
@@ -22,21 +22,21 @@ name, URL, icon) on 2026-10-05/06, one request per row of the previous release
|
|
| 22 |
| `license` label | documents | API licence (`nameEn`) |
|
| 23 |
|---|---:|---|
|
| 24 |
| CC-BY-2.0 | 1 | CC BY: Creative Commons Attribution 2.0 Generic |
|
| 25 |
-
| CC-BY-3.0 | 2,
|
| 26 |
-
| CC-BY-3.0-PL |
|
| 27 |
-
| CC-BY-4.0 |
|
| 28 |
| CC-BY-SA-3.0 | 7 | CC BY-SA: Creative Commons Attribution-ShareAlike 3.0 Unported |
|
| 29 |
-
| CC-BY-SA-3.0-PL | 2,
|
| 30 |
-
| CC-BY-SA-4.0 |
|
| 31 |
|
| 32 |
The label is carried in the parquet `license` column. `src/clean_biblioteka_nauki.py` accepts a row only
|
| 33 |
when the API licence is a Creative Commons BY or BY-SA licence of version 2.0 to 4.0 (generic or the
|
| 34 |
Polish port), its `creativecommons.org` URL, English name and icon agree, and the kind matches the
|
| 35 |
label recovered earlier. Anything else is withheld, not guessed (12 rows the API now answers with
|
| 36 |
HTTP 404). `articles_2011995` is the one row whose API licence (CC BY-SA 4.0) differs from the earlier
|
| 37 |
-
recovery (CC BY); it is kept and labelled CC-BY-SA-4.0 (maintainer decision 2026-10-06).
|
| 38 |
-
`license` column differs from the previous release; ids, order and text
|
| 39 |
-
|
| 40 |
|
| 41 |
Three items labelled "Domena publiczna" were dropped for v0.2.6 (`src/clean_biblioteka_nauki.py`,
|
| 42 |
polish-dynaword-v2#52): `books_2142716`, `books_2147851`, `articles_2097363` (376,155 tokens).
|
|
@@ -44,8 +44,8 @@ Biblioteka Nauki gives them API licence id 22, the CC Public Domain Mark 1.0, wh
|
|
| 44 |
waiver or a licence. They are original works first published 2019-2022, so the Polish life+70 term has
|
| 45 |
not run out, and `books_2147851` itself prints "Copyright by Jerzy Zając 2019".
|
| 46 |
|
| 47 |
-
The API
|
| 48 |
-
|
| 49 |
|
| 50 |
## Withheld rows
|
| 51 |
83 of the 42,068 rows of the previous release are not shipped. The ids, with one reason per id, are in
|
|
@@ -63,6 +63,55 @@ Rows are kept when the wording is only a citation, a quoted work's own notice, p
|
|
| 63 |
types, a permission for a figure or table, or a translation permitted by the author alone. These
|
| 64 |
readings are one reader's judgement of about 300 characters of context around each match.
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
## Attribution
|
| 67 |
Per-document attribution (author · year · title · publisher) was re-fetched 1:1 from
|
| 68 |
bibliotekanauki.pl (43,576 / 43,576 ok). The parquet `author` column carries the author names and the
|
|
@@ -71,8 +120,9 @@ satisfying the CC BY / CC BY-SA attribution requirement that applies to every do
|
|
| 71 |
|
| 72 |
`author` is the first field of that citation — the name(s), several joined by `; `. A footnote marker
|
| 73 |
glued to the last name in the source (`… Kowol 1`) is dropped, and the `. .` placeholder used for the
|
| 74 |
-
|
| 75 |
-
verbatim: one JSON object `{"id", "attribution"
|
|
|
|
| 76 |
|
| 77 |
## Provenance
|
| 78 |
Text from the SpeakLeash redistribution; licence and attribution recovered per document from the
|
|
@@ -85,7 +135,7 @@ assembled is not re-verified here.
|
|
| 85 |
## Statistics
|
| 86 |
| documents | characters | tokens (tiktoken proxy) |
|
| 87 |
|---:|---:|---:|
|
| 88 |
-
|
|
| 89 |
|
| 90 |
## Filters applied (build_dynaword.py)
|
| 91 |
Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
|
@@ -97,7 +147,8 @@ Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
|
| 97 |
- licence not confirmed by the API as an allowlisted CC BY / BY-SA version, HTTP 404 (`src/clean_biblioteka_nauki.py`): **12**
|
| 98 |
- text prints a NonCommercial or NoDerivatives licence (`src/clean_biblioteka_nauki.py`): **56**
|
| 99 |
- text says it is reprinted or translated by permission of a publisher (`src/clean_biblioteka_nauki.py`): **15**
|
| 100 |
-
-
|
|
|
|
| 101 |
|
| 102 |
Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
|
| 103 |
Llama-3 count is computed at release.
|
|
@@ -106,9 +157,14 @@ Llama-3 count is computed at release.
|
|
| 106 |
- **Mixed license.** Roughly one third of the documents are CC BY-SA (3.0, 3.0 PL or 4.0; share-alike);
|
| 107 |
the exact per-document licence and version is in the `license` column. Downstream redistribution must
|
| 108 |
respect share-alike for those documents, under their own version.
|
| 109 |
-
- **Licence is the API's word.**
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
- **OCR / extraction noise.** Text is extracted from publisher PDFs; some layout and hyphenation
|
| 113 |
artefacts remain after the alpha-ratio filter.
|
| 114 |
- **Per-document dates.** `created` is the publication year from upstream metadata; finer-grained
|
|
|
|
| 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, with the version the upstream API gives for each record — CC BY (2.0, 3.0, 3.0 PL, 4.0) 25,705 · CC BY-SA (3.0, 3.0 PL, 4.0) 12,138; table below
|
| 10 |
- **Created (range):** per-document publication year, from each item's bibliotekanauki.pl metadata
|
| 11 |
- **Added:** 2026-06-27
|
| 12 |
|
|
|
|
| 22 |
| `license` label | documents | API licence (`nameEn`) |
|
| 23 |
|---|---:|---|
|
| 24 |
| CC-BY-2.0 | 1 | CC BY: Creative Commons Attribution 2.0 Generic |
|
| 25 |
+
| CC-BY-3.0 | 2,306 | CC BY: Creative Commons Attribution 3.0 Unported |
|
| 26 |
+
| CC-BY-3.0-PL | 7,949 | CC BY: Creative Commons Attribution 3.0 PL |
|
| 27 |
+
| CC-BY-4.0 | 15,449 | CC BY: Creative Commons Attribution 4.0 |
|
| 28 |
| CC-BY-SA-3.0 | 7 | CC BY-SA: Creative Commons Attribution-ShareAlike 3.0 Unported |
|
| 29 |
+
| CC-BY-SA-3.0-PL | 2,691 | CC BY-SA: Creative Commons Attribution-ShareAlike 3.0 PL |
|
| 30 |
+
| CC-BY-SA-4.0 | 9,440 | CC BY-SA: Creative Commons Attribution-ShareAlike 4.0 |
|
| 31 |
|
| 32 |
The label is carried in the parquet `license` column. `src/clean_biblioteka_nauki.py` accepts a row only
|
| 33 |
when the API licence is a Creative Commons BY or BY-SA licence of version 2.0 to 4.0 (generic or the
|
| 34 |
Polish port), its `creativecommons.org` URL, English name and icon agree, and the kind matches the
|
| 35 |
label recovered earlier. Anything else is withheld, not guessed (12 rows the API now answers with
|
| 36 |
HTTP 404). `articles_2011995` is the one row whose API licence (CC BY-SA 4.0) differs from the earlier
|
| 37 |
+
recovery (CC BY); it is kept and labelled CC-BY-SA-4.0 (maintainer decision 2026-10-06). For the
|
| 38 |
+
37,843 rows shipped, only the `license` column differs from the previous release; ids, order and text
|
| 39 |
+
are unchanged.
|
| 40 |
|
| 41 |
Three items labelled "Domena publiczna" were dropped for v0.2.6 (`src/clean_biblioteka_nauki.py`,
|
| 42 |
polish-dynaword-v2#52): `books_2142716`, `books_2147851`, `articles_2097363` (376,155 tokens).
|
|
|
|
| 44 |
waiver or a licence. They are original works first published 2019-2022, so the Polish life+70 term has
|
| 45 |
not run out, and `books_2147851` itself prints "Copyright by Jerzy Zając 2019".
|
| 46 |
|
| 47 |
+
The API flags 5 rows as a reprint (2) or translation (3) publication; none has `restricted` set. The
|
| 48 |
+
licence check does not look at those flags; the 5 rows are dropped in the review below.
|
| 49 |
|
| 50 |
## Withheld rows
|
| 51 |
83 of the 42,068 rows of the previous release are not shipped. The ids, with one reason per id, are in
|
|
|
|
| 63 |
types, a permission for a figure or table, or a translation permitted by the author alone. These
|
| 64 |
readings are one reader's judgement of about 300 characters of context around each match.
|
| 65 |
|
| 66 |
+
## Per-record licence basis
|
| 67 |
+
Each line of `biblioteka_nauki.attribution.jsonl` also says what the row's licence rests on
|
| 68 |
+
(polish-dynaword-v2#111): `licence_basis`, `licence_basis_url` and `licence_basis_date`.
|
| 69 |
+
|
| 70 |
+
| `licence_basis` | rows | what it is | URL | date |
|
| 71 |
+
|---|---:|---|---|---|
|
| 72 |
+
| `file_note` | 2,657 | the text itself prints a CC licence with the label's elements in its front or back matter | the item's page on bibliotekanauki.pl | the row's `added` date |
|
| 73 |
+
| `depositor` | 35,186 | only the platform's licence field for the item states it; the field is set when the item is uploaded | the item's record at `bibliotekanauki.pl/api/...` | 2026-10-05/2026-10-06, when it was read |
|
| 74 |
+
|
| 75 |
+
No row has `publisher` or `none`: the journals' and publishers' own pages were not read, and the 12
|
| 76 |
+
rows the API did not serve are withheld. The rules and their measurements are in
|
| 77 |
+
`biblioteka_nauki.licence-basis.json`. A seeded sample of 60 `file_note` rows, read in context, held 60
|
| 78 |
+
genuine notes of the work's own licence; rows that print a licence in a form the parser does not read
|
| 79 |
+
were not counted.
|
| 80 |
+
|
| 81 |
+
## Rows dropped after review
|
| 82 |
+
4,142 of the 41,985 rows left by the steps above are dropped (polish-dynaword-v2#111, maintainer
|
| 83 |
+
decisions of 2026-10-20). `biblioteka_nauki.review.csv` (`id,decision,reason`, pinned by SHA-256 in
|
| 84 |
+
`src/clean_biblioteka_nauki.py`) lists the 4,205 rows a rule nominated, each with `drop` or `keep`, and
|
| 85 |
+
nothing else; the build refuses to run when the rules and the table disagree.
|
| 86 |
+
|
| 87 |
+
| reason | rows | what it is |
|
| 88 |
+
|---|---:|---|
|
| 89 |
+
| created_before_licence_version | 3,957 | the `created` start year is earlier than the first year of the label's licence version (CC BY 2.0: 2004; 3.0 and 3.0 PL: 2007; 4.0: 2013), so the licence the platform shows now cannot be the one chosen at publication |
|
| 90 |
+
| restriction_notice_no_cc_note | 97 | the front or back matter prints a restriction on copying or reproduction and no CC licence of its own |
|
| 91 |
+
| reprint_or_prior_publication | 30 | the text says the work was published before, or is a reprint, in a place other than this platform |
|
| 92 |
+
| translation_of_earlier_publication | 17 | the text is a translation of a work published elsewhere, stated in the text or by a translator credit |
|
| 93 |
+
| file_is_another_work | 16 | neither the title nor any author of the description appears where the text starts, ends or is attributed; the file is a different work |
|
| 94 |
+
| republished_by_permission | 11 | the text says it is a reprint or a translation published with the permission of an author or publisher |
|
| 95 |
+
| api_flagged_reprint_translation | 5 | the platform flags the item as a reprint or a translation |
|
| 96 |
+
| translation_title_marker | 5 | the citation title marks the item as a translation of a third party's text |
|
| 97 |
+
| printed_licence_nc_or_nd | 4 | the text prints a NonCommercial or NoDerivatives licence; the platform's label is a CC BY or BY-SA licence |
|
| 98 |
+
|
| 99 |
+
A row gets the first reason in this order: printed licence, prior publication, file mismatch,
|
| 100 |
+
restriction notice, year. 3,989 rows meet the year rule; 32 of them also meet an earlier drop reason and
|
| 101 |
+
keep it, and 7 that an earlier rule had read and kept are dropped under the year rule. In a seeded sample
|
| 102 |
+
of 100 rows dropped under it, 90 print the `created` year in the first 8,000 or last 5,000 characters,
|
| 103 |
+
and the other 10 cite no later year.
|
| 104 |
+
|
| 105 |
+
Journal adoption years could not be obtained: the platform's API gives a journal's current licence
|
| 106 |
+
only, the shipped rows carry no journal key, and asking for every item would take about 26 hours. Issues
|
| 107 |
+
from before a journal adopted Creative Commons may therefore remain where the publication year is not
|
| 108 |
+
earlier than the licence version. The year rule is a lower bound: the years are those of the generic
|
| 109 |
+
licence texts (the Polish port may be later), and the platform shows the licence an item has today.
|
| 110 |
+
|
| 111 |
+
The other 63 nominated rows were read and stay: a printed licence that belongs to an original or to a
|
| 112 |
+
discussion of licences, "all rights reserved" beside a CC note or without a clause, unreadable text,
|
| 113 |
+
and similar. The reasons and counts are in the evidence file.
|
| 114 |
+
|
| 115 |
## Attribution
|
| 116 |
Per-document attribution (author · year · title · publisher) was re-fetched 1:1 from
|
| 117 |
bibliotekanauki.pl (43,576 / 43,576 ok). The parquet `author` column carries the author names and the
|
|
|
|
| 120 |
|
| 121 |
`author` is the first field of that citation — the name(s), several joined by `; `. A footnote marker
|
| 122 |
glued to the last name in the source (`… Kowol 1`) is dropped, and the `. .` placeholder used for the
|
| 123 |
+
25 "Noty o autorach" pages with no single author (27 before the review) becomes an empty value. The sidecar keeps the citation
|
| 124 |
+
verbatim: one JSON object `{"id", "attribution", "licence_basis", "licence_basis_url",
|
| 125 |
+
"licence_basis_date"}` per row, in row order.
|
| 126 |
|
| 127 |
## Provenance
|
| 128 |
Text from the SpeakLeash redistribution; licence and attribution recovered per document from the
|
|
|
|
| 135 |
## Statistics
|
| 136 |
| documents | characters | tokens (tiktoken proxy) |
|
| 137 |
|---:|---:|---:|
|
| 138 |
+
| 37,843 | 1,534,529,869 | 590,924,796 |
|
| 139 |
|
| 140 |
## Filters applied (build_dynaword.py)
|
| 141 |
Minimal, per Dynaword guidelines (heavy filtering left to downstream use):
|
|
|
|
| 147 |
- licence not confirmed by the API as an allowlisted CC BY / BY-SA version, HTTP 404 (`src/clean_biblioteka_nauki.py`): **12**
|
| 148 |
- text prints a NonCommercial or NoDerivatives licence (`src/clean_biblioteka_nauki.py`): **56**
|
| 149 |
- text says it is reprinted or translated by permission of a publisher (`src/clean_biblioteka_nauki.py`): **15**
|
| 150 |
+
- reviewed drops (`src/clean_biblioteka_nauki.py`, polish-dynaword-v2#111): **4,142**
|
| 151 |
+
- read 43,576 → kept 37,843
|
| 152 |
|
| 153 |
Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical
|
| 154 |
Llama-3 count is computed at release.
|
|
|
|
| 157 |
- **Mixed license.** Roughly one third of the documents are CC BY-SA (3.0, 3.0 PL or 4.0; share-alike);
|
| 158 |
the exact per-document licence and version is in the `license` column. Downstream redistribution must
|
| 159 |
respect share-alike for those documents, under their own version.
|
| 160 |
+
- **Licence is the API's word.** For 35,186 of the 37,843 rows the platform's licence field, set by
|
| 161 |
+
the depositor at upload, is the only statement of the licence; 2,657 also print it in their text.
|
| 162 |
+
No journal or publisher page was read. 16 texts contain the phrase "Wszelkie prawa zastrzeżone" or
|
| 163 |
+
"All rights reserved" as written, although their API licence is CC BY or CC BY-SA. The rows are
|
| 164 |
+
kept; the conflict between a footer in the extracted text and the platform's licence field is not
|
| 165 |
+
resolved here.
|
| 166 |
+
- **Journal adoption.** Issues from before a journal adopted Creative Commons may remain; see "Rows
|
| 167 |
+
dropped after review".
|
| 168 |
- **OCR / extraction noise.** Text is extracted from publisher PDFs; some layout and hyphenation
|
| 169 |
artefacts remain after the alpha-ratio filter.
|
| 170 |
- **Per-document dates.** `created` is the publication year from upstream metadata; finer-grained
|
data/biblioteka_nauki/biblioteka_nauki.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:8b031cd9c42921fc8478415a9d8ce79bacb41d2d98f5b24b89ef37065cdccb87
|
| 3 |
+
size 941947131
|
data/biblioteka_nauki/biblioteka_nauki.review.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/biblioteka_nauki/biblioteka_nauki.stats.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
| 1 |
{
|
| 2 |
"read": 43576,
|
| 3 |
-
"kept":
|
| 4 |
"drop_short": 0,
|
| 5 |
"drop_lang": 925,
|
| 6 |
"drop_dup": 180,
|
| 7 |
"drop_ocr": 400,
|
| 8 |
-
"chars":
|
| 9 |
-
"tokens":
|
| 10 |
"secs": 484.1,
|
| 11 |
"license": "CC-BY-2.0 / CC-BY-3.0 / CC-BY-3.0-PL / CC-BY-4.0 / CC-BY-SA-3.0 / CC-BY-SA-3.0-PL / CC-BY-SA-4.0",
|
| 12 |
"drop_rights": 3,
|
| 13 |
"licenses": {
|
| 14 |
"CC-BY-2.0": 1,
|
| 15 |
-
"CC-BY-3.0":
|
| 16 |
-
"CC-BY-3.0-PL":
|
| 17 |
-
"CC-BY-4.0":
|
| 18 |
"CC-BY-SA-3.0": 7,
|
| 19 |
-
"CC-BY-SA-3.0-PL":
|
| 20 |
-
"CC-BY-SA-4.0":
|
| 21 |
},
|
| 22 |
"input_sha256": "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26",
|
| 23 |
"drop_license_unverified": 12,
|
|
@@ -106,7 +106,19 @@
|
|
| 106 |
"biblioteka_nauki_books_2143725": "the text prints CC BY-NC 3.0 PL (its foreword says CC BY)",
|
| 107 |
"biblioteka_nauki_books_2159317": "the text prints CC BY-NC-SA 4.0"
|
| 108 |
},
|
| 109 |
-
"content_sha256": "
|
| 110 |
"drop_text_nc_nd": 56,
|
| 111 |
-
"drop_text_reprint": 15
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"read": 43576,
|
| 3 |
+
"kept": 37843,
|
| 4 |
"drop_short": 0,
|
| 5 |
"drop_lang": 925,
|
| 6 |
"drop_dup": 180,
|
| 7 |
"drop_ocr": 400,
|
| 8 |
+
"chars": 1534529869,
|
| 9 |
+
"tokens": 590924796,
|
| 10 |
"secs": 484.1,
|
| 11 |
"license": "CC-BY-2.0 / CC-BY-3.0 / CC-BY-3.0-PL / CC-BY-4.0 / CC-BY-SA-3.0 / CC-BY-SA-3.0-PL / CC-BY-SA-4.0",
|
| 12 |
"drop_rights": 3,
|
| 13 |
"licenses": {
|
| 14 |
"CC-BY-2.0": 1,
|
| 15 |
+
"CC-BY-3.0": 2306,
|
| 16 |
+
"CC-BY-3.0-PL": 7949,
|
| 17 |
+
"CC-BY-4.0": 15449,
|
| 18 |
"CC-BY-SA-3.0": 7,
|
| 19 |
+
"CC-BY-SA-3.0-PL": 2691,
|
| 20 |
+
"CC-BY-SA-4.0": 9440
|
| 21 |
},
|
| 22 |
"input_sha256": "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26",
|
| 23 |
"drop_license_unverified": 12,
|
|
|
|
| 106 |
"biblioteka_nauki_books_2143725": "the text prints CC BY-NC 3.0 PL (its foreword says CC BY)",
|
| 107 |
"biblioteka_nauki_books_2159317": "the text prints CC BY-NC-SA 4.0"
|
| 108 |
},
|
| 109 |
+
"content_sha256": "5093fd3ec52f5a6abfd11631a9f4f556d37fecdf21c29ad6246cf319086d7819",
|
| 110 |
"drop_text_nc_nd": 56,
|
| 111 |
+
"drop_text_reprint": 15,
|
| 112 |
+
"drop_review": 4142,
|
| 113 |
+
"drop_review_by_reason": {
|
| 114 |
+
"api_flagged_reprint_translation": 5,
|
| 115 |
+
"created_before_licence_version": 3957,
|
| 116 |
+
"file_is_another_work": 16,
|
| 117 |
+
"printed_licence_nc_or_nd": 4,
|
| 118 |
+
"reprint_or_prior_publication": 30,
|
| 119 |
+
"republished_by_permission": 11,
|
| 120 |
+
"restriction_notice_no_cc_note": 97,
|
| 121 |
+
"translation_of_earlier_publication": 17,
|
| 122 |
+
"translation_title_marker": 5
|
| 123 |
+
}
|
| 124 |
}
|
src/biblioteka_nauki_overlap.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
|
| 3 |
The biblioteka_nauki parquet carries only the canonical `author` column. The full citation
|
| 4 |
(`Autor | Rok | Tytuł[ | Wydawca]`) is in data/biblioteka_nauki/biblioteka_nauki.attribution.jsonl, one
|
| 5 |
-
`{"id", "attribution"}` per row, in row order (written by clean_biblioteka_nauki
|
|
|
|
| 6 |
fetch_open_icm_pl, fetch_rock_pollub_pl and build_wiadomosci_statystyczne_pl read it from the Hub revision
|
| 7 |
of main they run against; this module is their one reader, so the format is parsed in one place.
|
| 8 |
"""
|
|
|
|
| 2 |
|
| 3 |
The biblioteka_nauki parquet carries only the canonical `author` column. The full citation
|
| 4 |
(`Autor | Rok | Tytuł[ | Wydawca]`) is in data/biblioteka_nauki/biblioteka_nauki.attribution.jsonl, one
|
| 5 |
+
`{"id", "attribution", ...}` per row, in row order (written by clean_biblioteka_nauki; the line also carries the `licence_basis*` fields,
|
| 6 |
+
which this reader ignores).
|
| 7 |
fetch_open_icm_pl, fetch_rock_pollub_pl and build_wiadomosci_statystyczne_pl read it from the Hub revision
|
| 8 |
of main they run against; this module is their one reader, so the format is parsed in one place.
|
| 9 |
"""
|
src/clean_biblioteka_nauki.py
CHANGED
|
@@ -27,35 +27,55 @@ Maintainer decisions of 2026-10-06 (polish-dynaword-v2#57, Hub PR 81), applied b
|
|
| 27 |
permission (Oxford University Press and 12 other publishers or journals). Withheld.
|
| 28 |
The build fails if a listed id is not reached, i.e. not among the rows that would otherwise be kept.
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
The v0.2.4 assembly script (build_parquet.py) was never committed, so this filters the shipped
|
| 31 |
v0.2.5 Parquet, pinned by SHA-256, and updates the stats file in place. Rerun:
|
| 32 |
git checkout v0.2.5 -- data/biblioteka_nauki/biblioteka_nauki.parquet
|
| 33 |
python3 src/clean_biblioteka_nauki.py
|
|
|
|
|
|
|
| 34 |
"""
|
| 35 |
from __future__ import annotations
|
| 36 |
|
| 37 |
import argparse
|
| 38 |
import hashlib
|
| 39 |
import json
|
| 40 |
-
import os
|
| 41 |
import re
|
|
|
|
| 42 |
from collections import Counter
|
| 43 |
from pathlib import Path
|
|
|
|
| 44 |
|
| 45 |
import pyarrow as pa
|
| 46 |
import pyarrow.compute as pc
|
| 47 |
import pyarrow.parquet as pq
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
SOURCE = "biblioteka_nauki"
|
| 54 |
DATA = Path(__file__).resolve().parents[1] / "data" / SOURCE
|
|
|
|
|
|
|
| 55 |
INPUT_SHA256 = "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26" # v0.2.5
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
KEEP = {"cc-by", "cc-by-sa", "cc0"} # = CLEAN in data/biblioteka_nauki/recover_attribution.py
|
| 57 |
DROP = {"public-domain"} # CC Public Domain Mark: a label, not a grant (see docstring)
|
| 58 |
-
|
| 59 |
# creativecommons.org/licenses/by/3.0/pl/legalcode, .../by-sa/4.0/legalcode.en, .../by/2.0/legalcode
|
| 60 |
LICENSE_URL = re.compile(r"^https://creativecommons\.org/licenses/(by|by-sa)/(\d\.\d)/(?:([a-z]{2})/)?legalcode(?:\.[a-z]{2})?$")
|
| 61 |
VERSIONS = {"2.0", "2.5", "3.0", "4.0"}
|
|
@@ -73,14 +93,9 @@ def split_author(citation: str) -> str:
|
|
| 73 |
return author if _HAS_LETTER.search(author) else ""
|
| 74 |
|
| 75 |
|
| 76 |
-
def split_attribution(table: pa.Table
|
| 77 |
-
"""
|
| 78 |
-
ids = table.column("id").to_pylist()
|
| 79 |
citations = table.column("attribution").to_pylist()
|
| 80 |
-
with sidecar_path.open("w", encoding="utf-8") as fh:
|
| 81 |
-
for row_id, citation in zip(ids, citations):
|
| 82 |
-
# default escaping: a citation may contain U+2028/U+2029, which must not read as a line break
|
| 83 |
-
fh.write(json.dumps({"id": row_id, "attribution": citation or ""}) + "\n")
|
| 84 |
index = table.schema.get_field_index("attribution")
|
| 85 |
table = table.set_column(index, "author", pa.array([split_author(c or "") for c in citations], pa.string()))
|
| 86 |
return table.select(SCHEMA.names)
|
|
@@ -206,59 +221,151 @@ def withhold_listed(table: pa.Table, listed: dict[str, str]) -> tuple[pa.Table,
|
|
| 206 |
return table.filter(pc.invert(pc.is_in(table.column("id"), pa.array(sorted(listed), pa.string())))), dict(listed)
|
| 207 |
|
| 208 |
|
| 209 |
-
def
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
rows in the same order with the same text, whatever the other columns say."""
|
| 212 |
digest = hashlib.sha256()
|
| 213 |
-
for batch in
|
| 214 |
for row_id, text in zip(batch.column("id").to_pylist(), batch.column("text").to_pylist()):
|
| 215 |
if row_id not in skip:
|
| 216 |
digest.update(f"{row_id}\t{hashlib.sha256(text.encode()).hexdigest()}\n".encode())
|
| 217 |
return digest.hexdigest()
|
| 218 |
|
| 219 |
|
| 220 |
-
def
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
granted = filter_table(table)
|
| 224 |
-
|
| 225 |
-
labelled,
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
stats = json.loads(stats_path.read_text(encoding="utf-8")) # keeps build_dynaword's read/drop_* counts
|
| 234 |
stats.update(
|
| 235 |
kept=kept.num_rows,
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
drop_text_reprint=len(reprint),
|
| 240 |
chars=pc.sum(pc.utf8_length(kept.column("text"))).as_py(),
|
| 241 |
tokens=pc.sum(kept.column("token_count")).as_py(),
|
| 242 |
license=" / ".join(sorted(set(kept.column("license").to_pylist()))),
|
| 243 |
licenses=dict(sorted(Counter(kept.column("license").to_pylist()).items())),
|
| 244 |
-
withheld=dict(sorted(withheld.items())),
|
| 245 |
input_sha256=INPUT_SHA256,
|
|
|
|
| 246 |
)
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
|
| 257 |
def main() -> None:
|
| 258 |
parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
| 259 |
-
parser.add_argument("--input", type=Path, default=
|
| 260 |
parser.add_argument("--out", type=Path, default=DATA)
|
|
|
|
| 261 |
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
| 262 |
print(json.dumps(build(args.input, args.out), indent=2, ensure_ascii=False))
|
| 263 |
|
| 264 |
|
|
|
|
| 27 |
permission (Oxford University Press and 12 other publishers or journals). Withheld.
|
| 28 |
The build fails if a listed id is not reached, i.e. not among the rows that would otherwise be kept.
|
| 29 |
|
| 30 |
+
Per-record licence basis and the reviewed drops (polish-dynaword-v2#111, maintainer decisions of 2026-10-20). The rows left by the
|
| 31 |
+
steps above are scanned with src/licence_basis_biblioteka_nauki.py (the rules and the hand decisions). `biblioteka_nauki.review.csv`
|
| 32 |
+
(`id,decision,reason`, pinned by SHA-256) holds one decision for every row a rule nominates and for nothing else; the build refuses to run
|
| 33 |
+
when it differs from what the rules give. Rows it marks `drop` are removed: the 88 rows of the clear-cut reasons, the 97 rows with a
|
| 34 |
+
restriction notice and no CC note of their own, and the rows whose `created` year is earlier than the first year of their label's licence
|
| 35 |
+
version. A kept row is not changed (stats `content_sha256`, and the evidence file records a digest of every column of the kept rows).
|
| 36 |
+
The attribution sidecar carries `licence_basis`, `licence_basis_url` and `licence_basis_date` from the same run.
|
| 37 |
+
|
| 38 |
The v0.2.4 assembly script (build_parquet.py) was never committed, so this filters the shipped
|
| 39 |
v0.2.5 Parquet, pinned by SHA-256, and updates the stats file in place. Rerun:
|
| 40 |
git checkout v0.2.5 -- data/biblioteka_nauki/biblioteka_nauki.parquet
|
| 41 |
python3 src/clean_biblioteka_nauki.py
|
| 42 |
+
After a change to a rule or a hand decision, `--propose-review` rewrites the review table from the rules; read the diff and pin
|
| 43 |
+
the new SHA-256 in REVIEW_SHA256.
|
| 44 |
"""
|
| 45 |
from __future__ import annotations
|
| 46 |
|
| 47 |
import argparse
|
| 48 |
import hashlib
|
| 49 |
import json
|
|
|
|
| 50 |
import re
|
| 51 |
+
import sys
|
| 52 |
from collections import Counter
|
| 53 |
from pathlib import Path
|
| 54 |
+
from typing import Iterator, NamedTuple
|
| 55 |
|
| 56 |
import pyarrow as pa
|
| 57 |
import pyarrow.compute as pc
|
| 58 |
import pyarrow.parquet as pq
|
| 59 |
|
| 60 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 61 |
+
import licence_basis as lb # noqa: E402
|
| 62 |
+
import licence_basis_biblioteka_nauki as lbn # noqa: E402
|
| 63 |
+
from biblioteka_nauki_overlap import ATTRIBUTION_SEP # noqa: E402
|
| 64 |
+
from normalize_schema import SCHEMA # noqa: E402 (the canonical columns every shipped shard carries)
|
| 65 |
+
from sejm_api_common import check_pin, read_pinned_review, replace_all, sha256_file # noqa: E402
|
| 66 |
|
| 67 |
SOURCE = "biblioteka_nauki"
|
| 68 |
DATA = Path(__file__).resolve().parents[1] / "data" / SOURCE
|
| 69 |
+
PARQUET, STATS, ATTRIBUTION, EVIDENCE, REVIEW, LICENSE_API = (
|
| 70 |
+
DATA / f"{SOURCE}.{name}" for name in ("parquet", "stats.json", "attribution.jsonl", "licence-basis.json", "review.csv", "license-api.json"))
|
| 71 |
INPUT_SHA256 = "cc93cdd5ca3e6576a1da0aa294df1308e879b8516ac30911289e430c69a07b26" # v0.2.5
|
| 72 |
+
LICENSE_API_SHA256 = "51e0bf7900e016f4b0102eecfd5032f3969a566899bf8ba094abad9f4f4578b5" # the labels (and so the review) depend on it
|
| 73 |
+
CLEANED_CONTENT_SHA256 = "cc4ad9ce16aaef3c7bc5197743ad58182e3d5011f78cbf53896083e7a8541954" # content_digest of the rows left before the review
|
| 74 |
+
REVIEW_SHA256 = "25e27c96280b6af547f2fdfb9d49a2d35861e96195a647047d6836af4a68a401" # biblioteka_nauki.review.csv
|
| 75 |
+
REVIEW_REASONS = {decision: set(group) for decision, group in lbn.REASONS.items()}
|
| 76 |
KEEP = {"cc-by", "cc-by-sa", "cc0"} # = CLEAN in data/biblioteka_nauki/recover_attribution.py
|
| 77 |
DROP = {"public-domain"} # CC Public Domain Mark: a label, not a grant (see docstring)
|
| 78 |
+
RESTORE = f"restore it with `git checkout v0.2.5 -- data/{SOURCE}/{SOURCE}.parquet`"
|
| 79 |
# creativecommons.org/licenses/by/3.0/pl/legalcode, .../by-sa/4.0/legalcode.en, .../by/2.0/legalcode
|
| 80 |
LICENSE_URL = re.compile(r"^https://creativecommons\.org/licenses/(by|by-sa)/(\d\.\d)/(?:([a-z]{2})/)?legalcode(?:\.[a-z]{2})?$")
|
| 81 |
VERSIONS = {"2.0", "2.5", "3.0", "4.0"}
|
|
|
|
| 93 |
return author if _HAS_LETTER.search(author) else ""
|
| 94 |
|
| 95 |
|
| 96 |
+
def split_attribution(table: pa.Table) -> pa.Table:
|
| 97 |
+
"""The table in the canonical columns: the citation (`attribution`) is replaced by its author names (`author`)."""
|
|
|
|
| 98 |
citations = table.column("attribution").to_pylist()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
index = table.schema.get_field_index("attribution")
|
| 100 |
table = table.set_column(index, "author", pa.array([split_author(c or "") for c in citations], pa.string()))
|
| 101 |
return table.select(SCHEMA.names)
|
|
|
|
| 221 |
return table.filter(pc.invert(pc.is_in(table.column("id"), pa.array(sorted(listed), pa.string())))), dict(listed)
|
| 222 |
|
| 223 |
|
| 224 |
+
def batches(source: Path | pa.Table, columns: list[str] | None = None) -> Iterator[pa.RecordBatch]:
|
| 225 |
+
if isinstance(source, Path):
|
| 226 |
+
yield from pq.ParquetFile(source).iter_batches(columns=columns, batch_size=2000)
|
| 227 |
+
else:
|
| 228 |
+
yield from source.select(columns or source.column_names).to_batches(max_chunksize=2000)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def content_digest(source: Path | pa.Table, skip: frozenset[str] = frozenset()) -> str:
|
| 232 |
+
"""SHA-256 over every (id, SHA-256 of text) in row order, minus ids in `skip`. Equal digests mean the same
|
| 233 |
rows in the same order with the same text, whatever the other columns say."""
|
| 234 |
digest = hashlib.sha256()
|
| 235 |
+
for batch in batches(source, ["id", "text"]):
|
| 236 |
for row_id, text in zip(batch.column("id").to_pylist(), batch.column("text").to_pylist()):
|
| 237 |
if row_id not in skip:
|
| 238 |
digest.update(f"{row_id}\t{hashlib.sha256(text.encode()).hexdigest()}\n".encode())
|
| 239 |
return digest.hexdigest()
|
| 240 |
|
| 241 |
|
| 242 |
+
def rows_digest(source: Path | pa.Table, skip: frozenset[str] = frozenset()) -> str:
|
| 243 |
+
"""SHA-256 over every column of every row in row order (the row as JSON, keys sorted), minus ids in `skip`."""
|
| 244 |
+
digest = hashlib.sha256()
|
| 245 |
+
for batch in batches(source):
|
| 246 |
+
for row in batch.to_pylist():
|
| 247 |
+
if row["id"] not in skip:
|
| 248 |
+
digest.update(json.dumps(row, ensure_ascii=False, sort_keys=True).encode() + b"\n")
|
| 249 |
+
return digest.hexdigest()
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def clean_table(table: pa.Table, api: dict, overrides: dict[str, str] = API_OVERRIDES, nc_nd: dict[str, str] = TEXT_NC_ND,
|
| 253 |
+
reprint: dict[str, str] = TEXT_REPRINT) -> tuple[pa.Table, dict[str, int], dict[str, str]]:
|
| 254 |
+
"""The rows left after the licence steps (a rights label, the API's licence, the two hand lists), the stats counts of
|
| 255 |
+
what each step took, and {id: reason} for the withheld rows. `api` is the license-api sidecar."""
|
| 256 |
granted = filter_table(table)
|
| 257 |
+
labelled, api_withheld = relabel(granted, api, overrides)
|
| 258 |
+
labelled, nc_nd_withheld = withhold_listed(labelled, nc_nd)
|
| 259 |
+
kept, reprint_withheld = withhold_listed(labelled, reprint)
|
| 260 |
+
withheld = {**api_withheld, **nc_nd_withheld, **reprint_withheld}
|
| 261 |
+
assert len(withheld) == len(api_withheld) + len(nc_nd_withheld) + len(reprint_withheld)
|
| 262 |
+
counts = {"drop_rights": table.num_rows - granted.num_rows, "drop_license_unverified": len(api_withheld),
|
| 263 |
+
"drop_text_nc_nd": len(nc_nd_withheld), "drop_text_reprint": len(reprint_withheld)}
|
| 264 |
+
return kept, counts, withheld
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
class Screen(NamedTuple):
|
| 268 |
+
"""The rows left after the licence steps, with what the rules say about them."""
|
| 269 |
+
cleaned: pa.Table
|
| 270 |
+
counts: dict[str, int]
|
| 271 |
+
withheld: dict[str, str]
|
| 272 |
+
recs: list[dict]
|
| 273 |
+
flags: dict[str, list[str]]
|
| 274 |
+
by_rule: dict[str, dict[str, tuple[str, str]]]
|
| 275 |
+
final: dict[str, tuple[str, str, str]]
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def screen(input_path: Path) -> Screen:
|
| 279 |
+
check_pin(input_path, INPUT_SHA256, RESTORE)
|
| 280 |
+
check_pin(LICENSE_API, LICENSE_API_SHA256, "the labels, and so the review, depend on it; it is the committed file")
|
| 281 |
+
api = json.loads(LICENSE_API.read_text(encoding="utf-8"))
|
| 282 |
+
cleaned, counts, withheld = clean_table(pq.read_table(input_path), api)
|
| 283 |
+
if (digest := content_digest(cleaned)) != CLEANED_CONTENT_SHA256:
|
| 284 |
+
raise SystemExit(f"the rows left before the review differ from the ones it was made for ({digest}, expected {CLEANED_CONTENT_SHA256})")
|
| 285 |
+
recs = lbn.scan(cleaned)
|
| 286 |
+
ids = set(cleaned.column("id").to_pylist())
|
| 287 |
+
flags = {i: f for i, f in api["flagged"].items() if i in ids}
|
| 288 |
+
by_rule = lbn.decisions(recs, set(flags))
|
| 289 |
+
return Screen(cleaned, counts, withheld, recs, flags, by_rule, lbn.final_reasons(by_rule))
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def read_review(path: Path = REVIEW, expected: str = REVIEW_SHA256) -> dict[str, tuple[str, str]]:
|
| 293 |
+
"""id -> (decision, reason) from the pinned review table."""
|
| 294 |
+
return read_pinned_review(path, expected, f"it is not the reviewed {REVIEW.name}; `--propose-review` writes the one the rules give", REVIEW_REASONS)
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
def check_review(review: dict[str, tuple[str, str]], final: dict[str, tuple[str, str, str]]) -> None:
|
| 298 |
+
"""The review holds one decision for every row a rule nominates and for nothing else."""
|
| 299 |
+
proposed = lbn.proposed_review(final)
|
| 300 |
+
if review != proposed:
|
| 301 |
+
differing = sorted(i for i in review.keys() | proposed.keys() if review.get(i) != proposed.get(i))
|
| 302 |
+
raise SystemExit(f"the pinned review and the rules disagree on {len(differing)} ids, first {differing[:5]}; "
|
| 303 |
+
"`--propose-review` writes what the rules give: read the difference, pin the new SHA-256")
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def build(input_path: Path, out_dir: Path, review_path: Path = REVIEW, expected_review: str = REVIEW_SHA256) -> dict:
|
| 307 |
+
scr = screen(input_path)
|
| 308 |
+
review = read_review(review_path, expected_review)
|
| 309 |
+
check_review(review, scr.final)
|
| 310 |
+
dropped = {i: reason for i, (decision, reason) in review.items() if decision == lbn.DROP}
|
| 311 |
+
|
| 312 |
+
pre_review = split_attribution(scr.cleaned) # the shard as it was before the review
|
| 313 |
+
kept, _ = withhold_listed(pre_review, dropped)
|
| 314 |
+
skip = frozenset(dropped)
|
| 315 |
+
citations = [c for i, c in zip(scr.cleaned.column("id").to_pylist(), scr.cleaned.column("attribution").to_pylist()) if i not in skip]
|
| 316 |
+
kept_recs = [r for r in scr.recs if r["id"] not in skip]
|
| 317 |
+
lines = lbn.attribution_lines(kept_recs, citations)
|
| 318 |
+
if problems := lb.check_lines(lines, kept.column("id").to_pylist()):
|
| 319 |
+
raise SystemExit(f"the attribution sidecar does not fit the rows: {problems[:5]}")
|
| 320 |
+
|
| 321 |
+
stats_path = out_dir / STATS.name
|
| 322 |
stats = json.loads(stats_path.read_text(encoding="utf-8")) # keeps build_dynaword's read/drop_* counts
|
| 323 |
stats.update(
|
| 324 |
kept=kept.num_rows,
|
| 325 |
+
**scr.counts,
|
| 326 |
+
drop_review=len(dropped),
|
| 327 |
+
drop_review_by_reason=dict(sorted(Counter(dropped.values()).items())),
|
|
|
|
| 328 |
chars=pc.sum(pc.utf8_length(kept.column("text"))).as_py(),
|
| 329 |
tokens=pc.sum(kept.column("token_count")).as_py(),
|
| 330 |
license=" / ".join(sorted(set(kept.column("license").to_pylist()))),
|
| 331 |
licenses=dict(sorted(Counter(kept.column("license").to_pylist()).items())),
|
| 332 |
+
withheld=dict(sorted(scr.withheld.items())),
|
| 333 |
input_sha256=INPUT_SHA256,
|
| 334 |
+
content_sha256=content_digest(kept),
|
| 335 |
)
|
| 336 |
+
pinned = {
|
| 337 |
+
"review": {"file": review_path.name, "sha256": expected_review, "rows": len(review)},
|
| 338 |
+
"input": {"v0.2.5_parquet_sha256": INPUT_SHA256, "license_api_sha256": LICENSE_API_SHA256,
|
| 339 |
+
"rows_before_review": scr.cleaned.num_rows, "rows_before_review_content_sha256": CLEANED_CONTENT_SHA256},
|
| 340 |
+
"kept": {"rows": kept.num_rows, "rows_sha256": rows_digest(pre_review, skip),
|
| 341 |
+
"note": "SHA-256 of every column of the kept rows (id, text, source, added, created, token_count, license, author), as they were before the review; "
|
| 342 |
+
"the test recomputes it from the shipped Parquet"},
|
| 343 |
+
}
|
| 344 |
+
evidence = lbn.evidence(scr.recs, scr.by_rule, scr.final, scr.flags, pinned)
|
| 345 |
+
replace_all({
|
| 346 |
+
out_dir / PARQUET.name: lambda path: pq.write_table(kept, path),
|
| 347 |
+
stats_path: lambda path: path.write_text(json.dumps(stats, indent=2, ensure_ascii=False) + "\n", encoding="utf-8"),
|
| 348 |
+
out_dir / ATTRIBUTION.name: lambda path: path.write_bytes(lbn.sidecar_bytes(lines)),
|
| 349 |
+
out_dir / EVIDENCE.name: lambda path: path.write_text(json.dumps(evidence, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8"),
|
| 350 |
+
})
|
| 351 |
+
return stats
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
def propose_review(input_path: Path, review_path: Path = REVIEW) -> str:
|
| 355 |
+
"""Write the review table the rules give; returns its SHA-256, to be pinned as REVIEW_SHA256."""
|
| 356 |
+
review_path.write_bytes(lbn.review_csv(screen(input_path).final).encode("utf-8"))
|
| 357 |
+
return sha256_file(review_path)
|
| 358 |
|
| 359 |
|
| 360 |
def main() -> None:
|
| 361 |
parser = argparse.ArgumentParser(description=__doc__.split("\n")[0])
|
| 362 |
+
parser.add_argument("--input", type=Path, default=PARQUET)
|
| 363 |
parser.add_argument("--out", type=Path, default=DATA)
|
| 364 |
+
parser.add_argument("--propose-review", action="store_true", help=f"write {REVIEW.name} from the rules and print its SHA-256; nothing else changes")
|
| 365 |
args = parser.parse_args()
|
| 366 |
+
if args.propose_review:
|
| 367 |
+
print(f"{REVIEW}\nREVIEW_SHA256 = {propose_review(args.input)!r}")
|
| 368 |
+
return
|
| 369 |
print(json.dumps(build(args.input, args.out), indent=2, ensure_ascii=False))
|
| 370 |
|
| 371 |
|
src/licence_basis.py
CHANGED
|
@@ -23,6 +23,24 @@ FIELDS = ("licence_basis", "licence_basis_url", "licence_basis_date")
|
|
| 23 |
_DAY = r"\d{4}-\d{2}-\d{2}"
|
| 24 |
DATE = re.compile(rf"^{_DAY}(/{_DAY})?$")
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
_DASH = r"[\s\-‐-―]*"
|
| 27 |
_ANCHOR = re.compile(r"(?i)creativecommons\.org/licen[sc]es/|creative\s*commons|\bCC" + _DASH + r"BY\b|\bCC0\b")
|
| 28 |
_URL_KIND = re.compile(r"(?i)licen[sc]es/(by(?:-nc)?(?:-sa|-nd)?)/(\d\.\d)")
|
|
|
|
| 23 |
_DAY = r"\d{4}-\d{2}-\d{2}"
|
| 24 |
DATE = re.compile(rf"^{_DAY}(/{_DAY})?$")
|
| 25 |
|
| 26 |
+
CREATED_BEFORE = "created_before_licence_version" # the drop reason of the year rule: `created` is earlier than the first year of the label's licence version
|
| 27 |
+
RELEASE = {"CC-BY-2.0": 2004, "CC-BY-3.0": 2007, "CC-BY-3.0-PL": 2007, "CC-BY-SA-3.0": 2007, "CC-BY-SA-3.0-PL": 2007,
|
| 28 |
+
"CC-BY-4.0": 2013, "CC-BY-SA-4.0": 2013} # first year of the licence version (generic text; the Polish port may be later)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def created_year(created: str) -> int:
|
| 32 |
+
"""The start year of a `created` value ("2011", "2021-05", "2024-01-31"); raises for a value that does not start with four digits."""
|
| 33 |
+
if not re.match(r"[0-9]{4}", created):
|
| 34 |
+
raise ValueError(f"no start year in the created value {created!r}")
|
| 35 |
+
return int(created[:4])
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def release_year(label: str) -> int:
|
| 39 |
+
"""First year of the label's licence version; raises for a label RELEASE does not list (the rule needs a year for every label)."""
|
| 40 |
+
if label not in RELEASE:
|
| 41 |
+
raise ValueError(f"no release year for the licence label {label!r}; add it to RELEASE")
|
| 42 |
+
return RELEASE[label]
|
| 43 |
+
|
| 44 |
_DASH = r"[\s\-‐-―]*"
|
| 45 |
_ANCHOR = re.compile(r"(?i)creativecommons\.org/licen[sc]es/|creative\s*commons|\bCC" + _DASH + r"BY\b|\bCC0\b")
|
| 46 |
_URL_KIND = re.compile(r"(?i)licen[sc]es/(by(?:-nc)?(?:-sa|-nd)?)/(\d\.\d)")
|
src/licence_basis_biblioteka_nauki.py
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Per-record licence basis and the reviewed drops for biblioteka_nauki (v0.2.6, slayerlabs/polish-dynaword-v2#111).
|
| 3 |
+
|
| 4 |
+
The rules, the hand decisions and the evidence file. src/clean_biblioteka_nauki.py runs them in its build, on the rows it
|
| 5 |
+
would otherwise ship, and applies the pinned review table; nothing here is run on its own.
|
| 6 |
+
|
| 7 |
+
Adds `licence_basis`, `licence_basis_url` and `licence_basis_date` (src/licence_basis.py) to each attribution line:
|
| 8 |
+
file_note the shipped text prints a CC licence with the label's elements (licence_basis.note_vs_label);
|
| 9 |
+
URL: the item's page on bibliotekanauki.pl; date: the row's `added` date
|
| 10 |
+
depositor only the platform's licence field states it (https://bibliotekanauki.pl/api/{articles|books|chapters}/{n}, read 2026-10-05/06);
|
| 11 |
+
the field is set when the item is uploaded
|
| 12 |
+
No `publisher` basis was looked for: the journals' own pages were not read. No row has `none`: the 12 rows the API did not serve are
|
| 13 |
+
already withheld.
|
| 14 |
+
|
| 15 |
+
Review (`biblioteka_nauki.review.csv`: `id,decision,reason`, decision `drop` or `keep`) lists every row that a rule in PRIORITY
|
| 16 |
+
nominates and that someone decided. The first `drop` in PRIORITY order gives a row its reason; a row some rule dropped keeps
|
| 17 |
+
that reason when a later rule nominates it too; a row only `keep`-decided by an earlier rule is dropped by a later `drop`.
|
| 18 |
+
A new rule is a new entry in PRIORITY, in `decisions` and in REASONS; the build refuses a pinned table that differs from what the
|
| 19 |
+
rules give. Maintainer decisions of 2026-10-20 (v2#111): the 88 rows of the clear-cut reasons, the 97 `restriction_notice_no_cc_note`
|
| 20 |
+
rows and the rows created before their licence version existed are dropped; the other review rows are kept.
|
| 21 |
+
|
| 22 |
+
`biblioteka_nauki.licence-basis.json` holds the counts, the rules with their measurements and hand checks, and the drops.
|
| 23 |
+
The screens were measured on the 41,985 rows before the review; the ids decided by hand are listed in HAND below and each is checked
|
| 24 |
+
against its rule.
|
| 25 |
+
"""
|
| 26 |
+
from __future__ import annotations
|
| 27 |
+
|
| 28 |
+
from collections import Counter, deque
|
| 29 |
+
from concurrent.futures import ProcessPoolExecutor
|
| 30 |
+
import json
|
| 31 |
+
import os
|
| 32 |
+
from pathlib import Path
|
| 33 |
+
import re
|
| 34 |
+
import sys
|
| 35 |
+
import unicodedata
|
| 36 |
+
|
| 37 |
+
import pyarrow as pa
|
| 38 |
+
|
| 39 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 40 |
+
import licence_basis as lb # noqa: E402
|
| 41 |
+
|
| 42 |
+
SOURCE = "biblioteka_nauki"
|
| 43 |
+
WEB, API_URL = "https://bibliotekanauki.pl/", "https://bibliotekanauki.pl/api/"
|
| 44 |
+
DEPOSITOR_DATE = "2026-10-05/2026-10-06"
|
| 45 |
+
DROP, KEEP = "drop", "keep"
|
| 46 |
+
CREATED_BEFORE = lb.CREATED_BEFORE
|
| 47 |
+
|
| 48 |
+
# --- rule texts -------------------------------------------------------------------------------------------------------
|
| 49 |
+
FRONT, BACK, HEAD, TAIL = 4000, 3000, 8000, 5000 # characters searched: front matter, back matter, head and tail for the author
|
| 50 |
+
CREDIT_HEAD = 2500
|
| 51 |
+
R2_FRONT = { # first FRONT characters
|
| 52 |
+
"reprint_word": r"(?i)\bprzedruk\w*|\bpierwodruk\w*|(?<![\w-])reprint(?:ed)?\b",
|
| 53 |
+
"permission": r"(?i)\b(?:reprinted|reproduced|translated|published|republished|printed)\s+(?:here\s+)?(?:with|by)\s+(?:the\s+)?(?:kind\s+)?permission"
|
| 54 |
+
r"|\b(?:przedrukowan\w+|przetłumaczon\w+|opublikowan\w+|zamieszczon\w+|publikowan\w+|tłumaczeni\w+|wydan\w+)\s+(?:artyku\w+\s+)?(?:za|na)\s+(?:zgodą|zezwoleniem|podstawie\s+zgody)"
|
| 55 |
+
r"|\bza\s+(?:zgodą|zezwoleniem)\s+(?:wydawcy|wydawnictwa|redakcji|właściciela\s+praw)"
|
| 56 |
+
r"|kind\s+permission",
|
| 57 |
+
"earlier": r"(?i)\b(?:first|originally|previously|earlier)\s+(?:published|appeared)\b|\boriginally\s+appeared\b|\bpublished\s+(?:earlier|previously|originally|first)\b"
|
| 58 |
+
r"|\bpierwotnie\s+(?:opublik|ukaza|wydan)\w+|\bukaza\w+\s+się\s+(?:po\s+raz\s+pierwszy|wcześniej|pierwotnie|uprzednio)"
|
| 59 |
+
r"|\b(?:publikowan|opublikowan|drukowan)\w+\s+(?:wcześniej|uprzednio|pierwotnie)",
|
| 60 |
+
}
|
| 61 |
+
R2_TITLE = { # the citation title
|
| 62 |
+
"title_translation": r"(?i)\((?:przekład|tłum\w*|translation|translated)[^)]*\)|\[(?:przekład|tłum\w*|translation)|\bprzekład\s+z\b|\btłumaczenie\s+z\b|\btranslated\s+from\b|\btranslation\s+of\b",
|
| 63 |
+
"title_reprint": r"(?i)\bprzedruk\b|\breprint\b|\(przedruk",
|
| 64 |
+
}
|
| 65 |
+
_NAME = r"[A-ZŁŚŻŹĆ][a-ząęółśżźćńü\-]{2,}(?:\s+[A-ZŁŚŻŹĆ][a-ząęółśżźćńü\-]{2,}){1,2}"
|
| 66 |
+
R2_CREDIT = (r"(?:\bPrzekład|\bTłumaczenie|\bTranslated by|\bTranslation by|\bPrzełożył[a]?|\bTłumaczył[a]?|\bTłum\.|\bPrzeł\.|\bPrzekład z [^.]{3,40}:)\s*:?\s*("
|
| 67 |
+
+ _NAME + r")\s*(?:[.\n]|$|\s(?=[A-Z0-9]))")
|
| 68 |
+
R2_STATEMENT = (r"(?i)\b(?:polish\s+translation|polski\s+przekład|przekład\s+polski|tłumaczenie\s+polskie|polskie\s+tłumaczenie|translated\s+(?:from|into)"
|
| 69 |
+
r"|przetłumaczon\w+\s+(?:z|na)|tłumaczenie\s+(?:artyku|tekst)\w*|przekład\s+(?:artyku|tekst)\w*|za\s+zgodą\s+autora\s+tłumaczenia"
|
| 70 |
+
r"|tekst\s+(?:został\s+)?przełożon\w+)")
|
| 71 |
+
R2 = {**{k: (re.compile(v), "front") for k, v in R2_FRONT.items()}, **{k: (re.compile(v), "title") for k, v in R2_TITLE.items()},
|
| 72 |
+
"translator_credit": (re.compile(R2_CREDIT), "credit"), "translation_statement": (re.compile(R2_STATEMENT), "credit")}
|
| 73 |
+
ARR = re.compile(r"(?i)wszelkie\s+prawa\s+(?:zastrzeżone|autorskie\s+zastrzeżone)|wszystkie\s+prawa\s+zastrzeżone|all\s+rights\s+reserved|tous\s+droits\s+réservés|alle\s+rechte\s+vorbehalten")
|
| 74 |
+
CONSENT = re.compile(
|
| 75 |
+
r"(?i)(?:przedrukowywanie|przedruk\w*|kopiowanie|powielanie|rozpowszechnianie|reprodukowanie|rozpowszechniania)[^.]{0,100}"
|
| 76 |
+
r"(?:bez\s+(?:pisemnej\s+|uprzedniej\s+|uprzedniego\s+)?(?:zgody|zezwolenia)|zabronion\w+|wymaga\w*\s+zgody)"
|
| 77 |
+
r"|(?:reprint\w*|reproduc\w*|copying|redistribut\w*|duplicat\w*)[^.]{0,80}(?:without\s+(?:the\s+)?(?:prior\s+)?(?:written\s+)?(?:permission|consent)|prohibited|forbidden|not\s+permitted)"
|
| 78 |
+
r"|bez\s+(?:pisemnej\s+)?zgody\s+(?:wydawcy|autora|redakcji)|zabrania\s+się\s+(?:kopiowania|powielania|przedruk)|swoboda\s+użytkownika\s+ograniczona")
|
| 79 |
+
CLAUSE_AFTER_ARR = re.compile(r"(?i)nie\s+(?:może|mogą)\b|bez\s+(?:pisemnej\s+)?zgody|without\s+(?:the\s+)?(?:prior\s+)?(?:written\s+)?permission|zabronion|ograniczona")
|
| 80 |
+
|
| 81 |
+
# --- decisions made by reading the text (every id is checked against its rule in decisions()) --------------------------------
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def ids(s: str) -> tuple[str, ...]:
|
| 85 |
+
return tuple(f"{SOURCE}_{i}" for i in s.split())
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
HAND = {
|
| 89 |
+
# the 13 rows whose text prints a CC licence with other elements than the label (all read)
|
| 90 |
+
"printed_note": {
|
| 91 |
+
(DROP, "printed_licence_nc_or_nd"): ids("books_1035301 books_1076500 articles_2089611 articles_520828"),
|
| 92 |
+
(KEEP, "printed_sa_label_by"): ids("books_1182283 books_2036704"),
|
| 93 |
+
(KEEP, "printed_by_label_sa"): ids("books_1705635 articles_1848138"),
|
| 94 |
+
(KEEP, "translation_of_cc_original"): ids("articles_910940 articles_911982"),
|
| 95 |
+
(KEEP, "discusses_licence"): ids("articles_474574 articles_474664 articles_953975"),
|
| 96 |
+
},
|
| 97 |
+
# rows the regex families or the platform's flags nominated and whose text says the work is a reprint, a translation or an earlier publication
|
| 98 |
+
"prior_publication": {
|
| 99 |
+
(DROP, "api_flagged_reprint_translation"): ids("books_1954543 books_2139603 articles_508678 articles_1194786 articles_2154637"),
|
| 100 |
+
(DROP, "republished_by_permission"): ids("articles_346483 articles_520042 articles_699742 articles_1964616 articles_1966200 "
|
| 101 |
+
"articles_520050 articles_520074 articles_1202427 articles_633657 books_1041711 articles_1374053"),
|
| 102 |
+
(DROP, "reprint_or_prior_publication"): ids(
|
| 103 |
+
"articles_371128 articles_508708 articles_511041 articles_520083 articles_534737 articles_634900 articles_782734 articles_1595585 "
|
| 104 |
+
"articles_1595639 articles_1808275 articles_1810424 articles_1936222 articles_1939790 articles_1965953 articles_2075829 articles_474667 "
|
| 105 |
+
"articles_484859 articles_486914 articles_520058 articles_520068 articles_611730 articles_643795 articles_643799 articles_666502 "
|
| 106 |
+
"articles_1202404 articles_2091081 articles_2095983 articles_2153254 articles_2054013 articles_2054042"),
|
| 107 |
+
(DROP, "translation_of_earlier_publication"): ids(
|
| 108 |
+
"articles_2141629 articles_2141775 articles_394624 articles_511176 articles_616723 articles_1373931 articles_1912267 articles_2136031 "
|
| 109 |
+
"articles_2153244 articles_646622 articles_2127589 articles_2137969 articles_1966127 articles_2058299 articles_645298 articles_1070475 articles_2158481"),
|
| 110 |
+
(DROP, "translation_title_marker"): ids("articles_699524 articles_699526 articles_699750 articles_699752 articles_783754"),
|
| 111 |
+
(KEEP, "same_author_prior_version"): ids("articles_275580 articles_1198505 articles_534891 articles_643777 articles_647385"),
|
| 112 |
+
},
|
| 113 |
+
# rows whose title and author are both absent from the first 6000 characters / the head and tail (all read)
|
| 114 |
+
"file_mismatch": {
|
| 115 |
+
(DROP, "file_is_another_work"): ids("books_1623111 articles_95765 articles_112558 articles_322929 articles_483009 articles_629493 articles_631744 "
|
| 116 |
+
"articles_646733 articles_646887 articles_646910 articles_646974 articles_647170 articles_694754 articles_1396194 "
|
| 117 |
+
"articles_1788320 articles_1834965"),
|
| 118 |
+
(KEEP, "item_found_later_in_file"): ids("articles_506975 articles_604494 articles_604538"),
|
| 119 |
+
(KEEP, "title_in_other_language"): ids("articles_604544 articles_619442 articles_620103 articles_681481 articles_695405"),
|
| 120 |
+
(KEEP, "front_matter_item"): ids("articles_694701 articles_694705"),
|
| 121 |
+
(KEEP, "text_garbled"): ids(
|
| 122 |
+
"articles_609659 articles_609697 articles_609782 articles_609876 articles_610006 articles_610073 articles_610129 articles_610157 articles_610257 "
|
| 123 |
+
"articles_610295 articles_610442 articles_610446 articles_610469 articles_610578 articles_610592 articles_610664 articles_610798 articles_611091 "
|
| 124 |
+
"articles_611109 articles_611113 articles_611138 articles_611170 articles_545065 articles_545096 articles_545192"),
|
| 125 |
+
},
|
| 126 |
+
}
|
| 127 |
+
# restriction hits that are not a notice about the work (a quoted source, a discussion of unauthorised copying, a notice on a questionnaire)
|
| 128 |
+
NOT_A_NOTICE = ids("articles_336963 articles_417422 articles_548260 articles_617638 articles_699550 articles_2053946")
|
| 129 |
+
# translations of ancient, archival or literary source texts: not screened (see the evidence file)
|
| 130 |
+
SOURCE_TEXT_TRANSLATIONS = ids("articles_1806845 articles_1806823 articles_1806867 articles_2057384 articles_1194054 articles_1917278 articles_534737 articles_699650 articles_555820")
|
| 131 |
+
PRIORITY = ("printed_note", "prior_publication", "file_mismatch", "restriction_notice", CREATED_BEFORE)
|
| 132 |
+
REASONS = { # decision -> {reason: what it means}
|
| 133 |
+
DROP: {
|
| 134 |
+
"printed_licence_nc_or_nd": "the text prints a NonCommercial or NoDerivatives licence; the platform's label is a CC BY or BY-SA licence",
|
| 135 |
+
"api_flagged_reprint_translation": "the platform flags the item as a reprint or a translation (`reprintPublication` or `translationPublication`)",
|
| 136 |
+
"republished_by_permission": "the text says it is a reprint or a translation published with the permission of an author or publisher",
|
| 137 |
+
"reprint_or_prior_publication": "the text says the work was published before, or is a reprint, in a place other than this platform",
|
| 138 |
+
"translation_of_earlier_publication": "the text is a translation of a work published elsewhere, stated in the text or by a translator credit",
|
| 139 |
+
"translation_title_marker": "the citation title marks the item as a translation of a third party's text",
|
| 140 |
+
"file_is_another_work": "neither the title nor any author of the description appears where the text starts, ends or is attributed; the file is a different work",
|
| 141 |
+
"restriction_notice_no_cc_note": "the front or back matter prints a restriction on copying or reproduction, and prints no CC licence of its own",
|
| 142 |
+
CREATED_BEFORE: "the `created` start year is earlier than the first year of the label's licence version (RELEASE), so the licence on the platform cannot have been the one chosen at publication",
|
| 143 |
+
},
|
| 144 |
+
KEEP: {
|
| 145 |
+
"printed_sa_label_by": "the text prints CC BY-SA; the label is CC BY (the label is the more permissive)",
|
| 146 |
+
"printed_by_label_sa": "the text prints CC BY; the label is CC BY-SA (the label is the less permissive)",
|
| 147 |
+
"translation_of_cc_original": "the printed CC licence is the licence of the original that the text translates",
|
| 148 |
+
"discusses_licence": "the text discusses licences; the printed licence is not a note about the work",
|
| 149 |
+
"same_author_prior_version": "the text is a revised or translated version of the authors' own earlier publication",
|
| 150 |
+
"item_found_later_in_file": "the title and author appear later in the file than the first 6000 characters",
|
| 151 |
+
"title_in_other_language": "the title appears in another language than the description's",
|
| 152 |
+
"front_matter_item": "the item is a list of reviewers or of abbreviations; the description names a different item of the issue",
|
| 153 |
+
"text_garbled": "the text is not readable (shifted letters or noise), so no title or author can match; a data-quality issue, not a licence issue",
|
| 154 |
+
"arr_only_no_cc_note": "the front or back matter prints 'all rights reserved' without a clause and prints no CC licence of its own",
|
| 155 |
+
"restriction_notice_beside_cc_note": "the front matter prints 'all rights reserved' or a restriction and, in the same front matter, a CC licence with the label's elements",
|
| 156 |
+
"not_a_notice_on_the_work": "a phrase found by the rule is a quoted source, a discussion or a notice on something else",
|
| 157 |
+
},
|
| 158 |
+
}
|
| 159 |
+
REASON_TEXT = {reason: text for group in REASONS.values() for reason, text in group.items()}
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# --- text rules --------------------------------------------------------------------------------------------------------
|
| 163 |
+
def fold(s: str) -> str:
|
| 164 |
+
s = unicodedata.normalize("NFKD", s.casefold().replace("ł", "l"))
|
| 165 |
+
return "".join(c for c in s if not unicodedata.combining(c))
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def words(s: str, n: int = 4) -> list[str]:
|
| 169 |
+
return [w for w in re.findall(r"[a-z0-9]+", fold(s)) if len(w) >= n]
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def parts_of(citation: str) -> tuple[str, str]:
|
| 173 |
+
"""(author field, title field) of 'Autor | Rok | Tytuł[ | Wydawca]'."""
|
| 174 |
+
parts = citation.split(" | ")
|
| 175 |
+
return parts[0], parts[2] if len(parts) > 2 else ""
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def file_mismatch(text: str, citation: str) -> bool:
|
| 179 |
+
"""True when no title word (>=4 letters) is in the first 6000 characters and no author surname (first 5 letters) is in the head or tail."""
|
| 180 |
+
author, title = parts_of(citation)
|
| 181 |
+
title_words = words(title)
|
| 182 |
+
surnames = [w[0][:5] for a in author.split(";") if a.strip() and (w := words(a.split()[-1], 3))]
|
| 183 |
+
if not title_words or not surnames:
|
| 184 |
+
return False
|
| 185 |
+
head = set(words(text[:6000]))
|
| 186 |
+
area = fold(text[:HEAD] + " " + text[-TAIL:])
|
| 187 |
+
return not any(w in head for w in title_words) and not any(s in area for s in surnames)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def restriction(text: str) -> str | None:
|
| 191 |
+
"""'clause' (a restriction on copying or reproduction, or 'all rights reserved' followed by one), 'arr_only', or None; front and back matter."""
|
| 192 |
+
kind = None
|
| 193 |
+
for segment in (text[:FRONT], text[-BACK:]):
|
| 194 |
+
arr = ARR.search(segment)
|
| 195 |
+
if CONSENT.search(segment) or (arr and CLAUSE_AFTER_ARR.search(segment[arr.end(): arr.end() + 300])):
|
| 196 |
+
return "clause"
|
| 197 |
+
kind = "arr_only" if arr else kind
|
| 198 |
+
return kind
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def prior_publication_hits(text: str, citation: str) -> tuple[str, ...]:
|
| 202 |
+
front, title = text[:FRONT], parts_of(citation)[1]
|
| 203 |
+
area = {"front": front, "title": title, "credit": text[:CREDIT_HEAD]}
|
| 204 |
+
return tuple(name for name, (pattern, where) in R2.items() if pattern.search(area[where]))
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
BATCH, COLUMNS = 200, ["id", "text", "license", "created", "token_count", "added", "attribution"]
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def scan_batch(rows: list[tuple]) -> list[dict]:
|
| 211 |
+
recs = []
|
| 212 |
+
for row_id, text, label, created, tokens, added, citation in rows:
|
| 213 |
+
kind, _ = lb.note_vs_label(text, label)
|
| 214 |
+
citation = citation or ""
|
| 215 |
+
recs.append({"id": row_id, "chars": len(text), "tokens": tokens, "label": label, "year": lb.created_year(created), "added": added,
|
| 216 |
+
"note": kind, "mismatch": file_mismatch(text, citation), "restriction": restriction(text),
|
| 217 |
+
"prior": prior_publication_hits(text, citation)})
|
| 218 |
+
return recs
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def scan(table: pa.Table, workers: int = min(8, os.cpu_count() or 1)) -> list[dict]:
|
| 222 |
+
"""One small record per row of `table` (columns COLUMNS, `attribution` = the full citation), in row order; the texts are not kept.
|
| 223 |
+
The batches go to a pool."""
|
| 224 |
+
out, pending = [], deque()
|
| 225 |
+
with ProcessPoolExecutor(workers) as pool:
|
| 226 |
+
for batch in table.select(COLUMNS).to_batches(max_chunksize=BATCH):
|
| 227 |
+
pending.append(pool.submit(scan_batch, list(zip(*(column.to_pylist() for column in batch.columns)))))
|
| 228 |
+
if len(pending) >= 2 * workers:
|
| 229 |
+
out += pending.popleft().result()
|
| 230 |
+
out += [r for future in pending for r in future.result()]
|
| 231 |
+
return out
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
# --- decisions ---------------------------------------------------------------------------------------------------------
|
| 235 |
+
def decisions(recs: list[dict], flagged: set[str]) -> dict[str, dict[str, tuple[str, str]]]:
|
| 236 |
+
"""{rule: {id: (decision, reason)}}. Raises when a hand-decided id is not nominated by its rule, or a rule nominates an id nobody decided."""
|
| 237 |
+
by_id = {r["id"]: r for r in recs}
|
| 238 |
+
out: dict[str, dict[str, tuple[str, str]]] = {}
|
| 239 |
+
for rule, groups in HAND.items():
|
| 240 |
+
out[rule] = {i: key for key, group in groups.items() for i in group}
|
| 241 |
+
if sum(len(g) for g in groups.values()) != len(out[rule]):
|
| 242 |
+
raise ValueError(f"{rule}: an id has two decisions")
|
| 243 |
+
missing = set(out[rule]) - by_id.keys()
|
| 244 |
+
if missing:
|
| 245 |
+
raise ValueError(f"{rule}: ids not in the shard: {sorted(missing)}")
|
| 246 |
+
nominated = {"printed_note": {r["id"] for r in recs if r["note"] == "conflict"},
|
| 247 |
+
"file_mismatch": {r["id"] for r in recs if r["mismatch"]},
|
| 248 |
+
"prior_publication": {r["id"] for r in recs if r["prior"]} | flagged}
|
| 249 |
+
for rule, ids_ in nominated.items():
|
| 250 |
+
decided = set(out[rule])
|
| 251 |
+
if (rule == "prior_publication" and decided - ids_) or (rule != "prior_publication" and decided != ids_):
|
| 252 |
+
raise ValueError(f"{rule}: decided {len(decided)}, nominated {len(ids_)}, differing {sorted(decided ^ ids_)[:10]}")
|
| 253 |
+
out["restriction_notice"] = {r["id"]: restriction_decision(r) for r in recs if r["restriction"]}
|
| 254 |
+
if not set(NOT_A_NOTICE) <= set(out["restriction_notice"]):
|
| 255 |
+
raise ValueError("a hand-listed non-notice is no longer a hit of the restriction rule")
|
| 256 |
+
out[CREATED_BEFORE] = {r["id"]: (DROP, CREATED_BEFORE) for r in recs if r["year"] < lb.release_year(r["label"])}
|
| 257 |
+
return out
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def restriction_decision(rec: dict) -> tuple[str, str]:
|
| 261 |
+
return ((KEEP, "not_a_notice_on_the_work") if rec["id"] in NOT_A_NOTICE else
|
| 262 |
+
(KEEP, "restriction_notice_beside_cc_note") if rec["note"] == "file_note" else
|
| 263 |
+
(DROP, "restriction_notice_no_cc_note") if rec["restriction"] == "clause" else (KEEP, "arr_only_no_cc_note"))
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def final_reasons(by_rule: dict[str, dict[str, tuple[str, str]]]) -> dict[str, tuple[str, str, str]]:
|
| 267 |
+
"""{id: (decision, reason, rule)}: the first `drop` in PRIORITY order, else the first `keep`."""
|
| 268 |
+
final: dict[str, tuple[str, str, str]] = {}
|
| 269 |
+
for rule in PRIORITY:
|
| 270 |
+
for row_id, (decision, reason) in by_rule[rule].items():
|
| 271 |
+
if row_id not in final or (final[row_id][0] == KEEP and decision == DROP):
|
| 272 |
+
final[row_id] = (decision, reason, rule)
|
| 273 |
+
return final
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def proposed_review(final: dict[str, tuple[str, str, str]]) -> dict[str, tuple[str, str]]:
|
| 277 |
+
"""{id: (decision, reason)}: the table the rules give, to be equal to the pinned one."""
|
| 278 |
+
return {i: (d, r) for i, (d, r, _) in final.items()}
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def review_csv(final: dict[str, tuple[str, str, str]]) -> str:
|
| 282 |
+
return "id,decision,reason\n" + "".join(f"{i},{d},{r}\n" for i, (d, r) in sorted(proposed_review(final).items()))
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
# --- sidecar ------------------------------------------------------------------------------------------------------------
|
| 286 |
+
def read_sidecar(path: Path) -> list[dict]:
|
| 287 |
+
return [json.loads(line) for line in path.read_bytes().decode("utf-8").split("\n") if line]
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def sidecar_bytes(lines: list[dict]) -> bytes:
|
| 291 |
+
"""Default `json.dumps` escaping: a citation may contain U+2028/U+2029, which must not read as a line break."""
|
| 292 |
+
return "".join(json.dumps(line) + "\n" for line in lines).encode("utf-8")
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
def item_url(row_id: str, api: bool) -> str:
|
| 296 |
+
kind, number = row_id.removeprefix(f"{SOURCE}_").split("_")
|
| 297 |
+
if kind not in ("articles", "books", "chapters") or not number.isdigit():
|
| 298 |
+
raise ValueError(row_id)
|
| 299 |
+
return f"{API_URL if api else WEB}{kind}/{number}"
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
def basis_of(rec: dict) -> tuple[str, str, str]:
|
| 303 |
+
"""(code, url, date) of one row."""
|
| 304 |
+
if rec["note"] == "file_note":
|
| 305 |
+
return "file_note", item_url(rec["id"], False), rec["added"]
|
| 306 |
+
return "depositor", item_url(rec["id"], True), DEPOSITOR_DATE
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def attribution_lines(recs: list[dict], citations: list[str]) -> list[dict]:
|
| 310 |
+
"""The sidecar's lines in row order: id, full citation and the basis fields."""
|
| 311 |
+
return [lb.merge_basis({"id": r["id"], "attribution": c or ""}, *basis_of(r)) for r, c in zip(recs, citations, strict=True)]
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def measure(recs: list[dict]) -> dict[str, int]:
|
| 315 |
+
return {"rows": len(recs), "characters": sum(r["chars"] for r in recs), "tokens": sum(r["tokens"] for r in recs)}
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
NOMINATED = {
|
| 319 |
+
"printed_note": "licence_basis.note_vs_label(...) == 'conflict'",
|
| 320 |
+
"prior_publication": "any regex family of R2 in the front matter or the citation title, or an API flag; "
|
| 321 |
+
"the review lists only the rows whose reading confirmed a reprint, a translation or an earlier publication",
|
| 322 |
+
"file_mismatch": "file_mismatch(text, citation)",
|
| 323 |
+
"restriction_notice": "restriction(text) is not None",
|
| 324 |
+
CREATED_BEFORE: "the `created` start year is earlier than RELEASE[label]",
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def evidence(recs: list[dict], by_rule: dict[str, dict[str, tuple[str, str]]], final: dict[str, tuple[str, str, str]],
|
| 329 |
+
flags: dict[str, list[str]], pinned: dict) -> dict:
|
| 330 |
+
"""The evidence file. `recs` are the rows before the review (the screens were measured on them); the counts by basis describe the rows
|
| 331 |
+
that stay. `pinned` is what the build knows: {"review": {"file", "sha256"}, "input": {...}, "kept": {...}}."""
|
| 332 |
+
by_id = {r["id"]: r for r in recs}
|
| 333 |
+
shipped = [r for r in recs if final.get(r["id"], (KEEP,))[0] != DROP]
|
| 334 |
+
dropped_ids = {i for i, v in final.items() if v[0] == DROP}
|
| 335 |
+
basis = [basis_of(r) for r in shipped]
|
| 336 |
+
counts = Counter(code for code, _, _ in basis)
|
| 337 |
+
rule_rows = {rule: {reason: measure([by_id[i] for i, (_, rsn) in group.items() if rsn == reason]) for reason in sorted({rsn for _, rsn in group.values()})}
|
| 338 |
+
for rule, group in by_rule.items()}
|
| 339 |
+
review_rows = {reason: measure([by_id[i] for i, (_, rsn, _) in final.items() if rsn == reason]) for reason in sorted({v[1] for v in final.values()})}
|
| 340 |
+
decided = {decision: measure([by_id[i] for i, v in final.items() if v[0] == decision]) for decision in (DROP, KEEP)}
|
| 341 |
+
proxy = set(by_rule[CREATED_BEFORE])
|
| 342 |
+
earlier = {i: [by_rule[rule][i] for rule in PRIORITY if rule != CREATED_BEFORE and i in by_rule[rule]] for i in proxy} # what the other rules decided
|
| 343 |
+
dropped_before = Counter(final[i][1] for i in proxy if any(d == DROP for d, _ in earlier[i])) # these keep the reason of their first drop
|
| 344 |
+
flipped = Counter(earlier[i][0][1] for i in proxy if earlier[i] and all(d == KEEP for d, _ in earlier[i])) # kept by the others, dropped here
|
| 345 |
+
result = {
|
| 346 |
+
"source": SOURCE, "issue": "slayerlabs/polish-dynaword-v2#111", "codes": list(lb.CODES), "counts": {c: counts.get(c, 0) for c in lb.CODES},
|
| 347 |
+
"dates": {"file_note": "the row's `added` date", "depositor": DEPOSITOR_DATE}, "added_dates": sorted({r["added"] for r in shipped}),
|
| 348 |
+
"by_label": {label: {c: sum(1 for r, b in zip(shipped, basis) if r["label"] == label and b[0] == c) for c in lb.CODES}
|
| 349 |
+
for label in sorted({r["label"] for r in shipped})},
|
| 350 |
+
"by_code": {c: measure([r for r, b in zip(shipped, basis) if b[0] == c]) for c in lb.CODES if counts.get(c)},
|
| 351 |
+
"urls": {"file_note": f"{WEB}{{articles|books|chapters}}/{{n}}", "depositor": f"{API_URL}{{articles|books|chapters}}/{{n}}"},
|
| 352 |
+
"rule": "file_note: licence_basis.note_vs_label(text, label) is 'file_note', i.e. a CC note in the front or back matter, not about a photo or a quoted source, "
|
| 353 |
+
"with the label's elements; depositor: every other row, whose label is the platform's licence object for the item",
|
| 354 |
+
"hand_check": {
|
| 355 |
+
"file_note": "seeded sample of 60 of the file_note rows read in context: 60 genuine notes of the work's own licence "
|
| 356 |
+
"(one carries a general 'unless stated otherwise' note of the publishing university)",
|
| 357 |
+
"not_measured": "rows with a licence printed in words or a form the parser does not read (false negatives of file_note) were not counted",
|
| 358 |
+
},
|
| 359 |
+
"platform_check": {"retrieved": "2026-10-05..2026-10-06", "rows_asked": 42068, "answered_200": 42056, "http404": 12,
|
| 360 |
+
"note": "the 12 http404 rows are withheld, so no shipped row has `none`; see biblioteka_nauki.license-evidence.json"},
|
| 361 |
+
"publisher_check": {"done": False, "note": "no journal or publisher page was read; the issue allows `publisher` as a second basis"},
|
| 362 |
+
"journal_adoption": {"obtainable": False,
|
| 363 |
+
"reason": "GET /api/journals/{id} returns the journal's current licence only, the shipped rows carry no journal key, and fetching every item takes about 26 hours at the polite rate",
|
| 364 |
+
"consequence": "an issue from before its journal adopted CC may remain wherever the publication year is not earlier than the licence version",
|
| 365 |
+
"proxy": CREATED_BEFORE},
|
| 366 |
+
CREATED_BEFORE: {
|
| 367 |
+
"rule": "the `created` start year is earlier than the first year of the label's licence version; the row is dropped",
|
| 368 |
+
"release_year": lb.RELEASE, "note": "a lower bound: the years are those of the generic licence texts (the Polish port may be later, which would add rows), "
|
| 369 |
+
"and the platform shows the licence it has today, which may be later than the issue",
|
| 370 |
+
**measure([by_id[i] for i in proxy]), "by_label": dict(sorted(Counter(by_id[i]["label"] for i in proxy).items())),
|
| 371 |
+
"precedence": "a row some other rule dropped keeps that rule's reason; a row only kept by another rule is dropped here",
|
| 372 |
+
"overlap": {"already_dropped_by_another_rule": dict(sorted(dropped_before.items())), "flipped_from_keep": dict(sorted(flipped.items())),
|
| 373 |
+
"not_otherwise_in_review": sum(1 for i in proxy if not earlier[i]),
|
| 374 |
+
"dropped_with_this_reason": review_rows.get(CREATED_BEFORE, {}).get("rows", 0)},
|
| 375 |
+
"hand_check": "seeded sample of 100 of these rows: in 90 the `created` year is printed in the first 8000 or last 5000 characters; "
|
| 376 |
+
"in the other 10 the text cites no later year than `created`",
|
| 377 |
+
},
|
| 378 |
+
"rules": {rule: {"nominated": NOMINATED[rule], "by_reason": rule_rows[rule]} for rule in PRIORITY},
|
| 379 |
+
"regexes": {"R2_FRONT": R2_FRONT, "R2_TITLE": R2_TITLE, "R2_CREDIT": R2_CREDIT, "R2_STATEMENT": R2_STATEMENT, "ARR": ARR.pattern,
|
| 380 |
+
"CONSENT": CONSENT.pattern, "CLAUSE_AFTER_ARR": CLAUSE_AFTER_ARR.pattern},
|
| 381 |
+
"nominated_rows": {
|
| 382 |
+
"prior_publication": {name: sum(1 for r in recs if name in r["prior"]) for name in R2},
|
| 383 |
+
"prior_publication_any": sum(1 for r in recs if r["prior"] or r["id"] in flags),
|
| 384 |
+
"prior_publication_in_review": len(by_rule["prior_publication"]),
|
| 385 |
+
"file_mismatch": sum(r["mismatch"] for r in recs), "printed_note": sum(r["note"] == "conflict" for r in recs),
|
| 386 |
+
"restriction_notice": Counter(f"{r['restriction']}/{r['note']}" for r in recs if r["restriction"]),
|
| 387 |
+
},
|
| 388 |
+
"hand_read": {
|
| 389 |
+
"printed_note": "all 13 rows read",
|
| 390 |
+
"file_mismatch": "all 51 rows read; the looser sets (title only absent: 476 rows, author only absent: 458, the 51 excluded) were sampled, 30 of each: "
|
| 391 |
+
"0 of the 60 were a different work (other language, encoding or front matter)",
|
| 392 |
+
"prior_publication": "every row with a hit of the tight families (reprint words in the front matter, permission, earlier publication, title markers, "
|
| 393 |
+
"translator credit and translation statement) was read in context; the broad translator-word family (1,326 rows, mostly footnotes) was not. "
|
| 394 |
+
"Rows read and not confirmed (prior_publication_any minus prior_publication_in_review) are not in the review",
|
| 395 |
+
"restriction_notice": "all 120 hits read in context; 6 of the 110 outside file_note rows are not a notice on the work",
|
| 396 |
+
},
|
| 397 |
+
"not_screened": {"translations_of_source_texts": {
|
| 398 |
+
**measure([r for r in shipped if r["id"] in SOURCE_TEXT_TRANSLATIONS]), "ids": [i for i in SOURCE_TEXT_TRANSLATIONS if i not in dropped_ids],
|
| 399 |
+
"dropped_by_review": {i: final[i][1] for i in SOURCE_TEXT_TRANSLATIONS if i in dropped_ids},
|
| 400 |
+
"note": "translations of ancient, archival or literary texts by the item's author; the original is not a rights-held work in the sense of the rule. "
|
| 401 |
+
"One of the 9 is in the review under a prior-publication reason and is dropped (`dropped_by_review`)"}},
|
| 402 |
+
"api_flags": {i: f for i, f in sorted(flags.items())},
|
| 403 |
+
"overlaps": {i: sorted({by_rule[rule][i][1] for rule in PRIORITY if i in by_rule[rule]})
|
| 404 |
+
for i in sorted(final) if sum(i in by_rule[rule] for rule in PRIORITY) > 1},
|
| 405 |
+
"review": {**pinned["review"], "rows": len(final), "reasons": {d: {k: v for k, v in group.items() if k in review_rows} for d, group in REASONS.items()},
|
| 406 |
+
"rule_order": list(PRIORITY), "by_reason": review_rows, "decided": decided, "source": measure(recs), "shipped": measure(shipped),
|
| 407 |
+
"note": "drops decided by the maintainer on 2026-10-20 (v2#111); the table lists every row a rule nominated, `drop` or `keep`, and nothing else",
|
| 408 |
+
"kept": pinned["kept"]},
|
| 409 |
+
"input": pinned["input"],
|
| 410 |
+
}
|
| 411 |
+
return result
|
src/sources.py
CHANGED
|
@@ -990,7 +990,11 @@ SOURCES = {
|
|
| 990 |
"Biblioteka Nauki API gave for that record on 2026-10-05/06 "
|
| 991 |
"(CC BY 2.0, 3.0, 3.0 PL, 4.0; CC BY-SA 3.0, 3.0 PL, 4.0), checked "
|
| 992 |
"against the licence URL and icon. The API licence objects are "
|
| 993 |
-
"committed as biblioteka_nauki.license-api.json."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 994 |
"upstream": "https://bibliotekanauki.pl/",
|
| 995 |
"provenance": "Text from the SpeakLeash redistribution; licence and attribution "
|
| 996 |
"recovered per document from the Biblioteka Nauki API (Hub PR 11); "
|
|
@@ -998,7 +1002,8 @@ SOURCES = {
|
|
| 998 |
"bibliotekanauki.pl/api/{type}/{id} "
|
| 999 |
"(recover_license_versions.py, recover_attribution.py); rows the API "
|
| 1000 |
"did not resolve to an allowlisted CC BY or CC BY-SA licence are "
|
| 1001 |
-
"withheld by clean_biblioteka_nauki.py
|
|
|
|
| 1002 |
"legal_note": "The `license` column holds the per-record version, not a single "
|
| 1003 |
"CC BY 4.0 / CC BY-SA 4.0 label: CC BY-SA rows (about one third) are "
|
| 1004 |
"share-alike under their own version (3.0, 3.0 PL or 4.0). Dropped: "
|
|
@@ -1006,9 +1011,18 @@ SOURCES = {
|
|
| 1006 |
"v2#52), 12 rows the API no longer serves (HTTP 404), 56 rows whose own "
|
| 1007 |
"text prints a NonCommercial or NoDerivatives licence and 15 rows whose "
|
| 1008 |
"text says it is reprinted or translated by permission of a publisher "
|
| 1009 |
-
"(maintainer decision 2026-10-06, v2#57).
|
| 1010 |
-
"
|
| 1011 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1012 |
"blob is not re-verified: the assembly script was not committed.",
|
| 1013 |
"domain": "academic",
|
| 1014 |
"created": "unknown",
|
|
|
|
| 990 |
"Biblioteka Nauki API gave for that record on 2026-10-05/06 "
|
| 991 |
"(CC BY 2.0, 3.0, 3.0 PL, 4.0; CC BY-SA 3.0, 3.0 PL, 4.0), checked "
|
| 992 |
"against the licence URL and icon. The API licence objects are "
|
| 993 |
+
"committed as biblioteka_nauki.license-api.json. Each attribution "
|
| 994 |
+
"sidecar line also gives the basis: the platform's licence field "
|
| 995 |
+
"for 35,186 rows (depositor), a CC licence printed in the text for "
|
| 996 |
+
"2,657 (file_note); no journal or publisher page was read "
|
| 997 |
+
"(v2#111).",
|
| 998 |
"upstream": "https://bibliotekanauki.pl/",
|
| 999 |
"provenance": "Text from the SpeakLeash redistribution; licence and attribution "
|
| 1000 |
"recovered per document from the Biblioteka Nauki API (Hub PR 11); "
|
|
|
|
| 1002 |
"bibliotekanauki.pl/api/{type}/{id} "
|
| 1003 |
"(recover_license_versions.py, recover_attribution.py); rows the API "
|
| 1004 |
"did not resolve to an allowlisted CC BY or CC BY-SA licence are "
|
| 1005 |
+
"withheld by clean_biblioteka_nauki.py, which then drops the rows "
|
| 1006 |
+
"of a pinned review table (biblioteka_nauki.review.csv, v2#111).",
|
| 1007 |
"legal_note": "The `license` column holds the per-record version, not a single "
|
| 1008 |
"CC BY 4.0 / CC BY-SA 4.0 label: CC BY-SA rows (about one third) are "
|
| 1009 |
"share-alike under their own version (3.0, 3.0 PL or 4.0). Dropped: "
|
|
|
|
| 1011 |
"v2#52), 12 rows the API no longer serves (HTTP 404), 56 rows whose own "
|
| 1012 |
"text prints a NonCommercial or NoDerivatives licence and 15 rows whose "
|
| 1013 |
"text says it is reprinted or translated by permission of a publisher "
|
| 1014 |
+
"(maintainer decision 2026-10-06, v2#57). Dropped after review "
|
| 1015 |
+
"(maintainer decisions 2026-10-20, v2#111): 4,142 rows, of which 3,957 "
|
| 1016 |
+
"because the `created` year is earlier than the first year of the "
|
| 1017 |
+
"label's licence version (2.0: 2004; 3.0 and 3.0 PL: 2007; 4.0: 2013) "
|
| 1018 |
+
"and 185 because the text prints a NonCommercial or NoDerivatives "
|
| 1019 |
+
"licence, is a reprint, a translation or another work, or prints a "
|
| 1020 |
+
"restriction on copying and no CC licence of its own. Journal adoption "
|
| 1021 |
+
"years could not be obtained, so issues from before a journal adopted "
|
| 1022 |
+
"Creative Commons may remain where the publication year is not earlier "
|
| 1023 |
+
"than the licence version. 16 texts contain the phrase \"all rights "
|
| 1024 |
+
"reserved\" as written although their API licence is CC; that is not "
|
| 1025 |
+
"resolved here. How the text layer was assembled from the SpeakLeash "
|
| 1026 |
"blob is not re-verified: the assembly script was not committed.",
|
| 1027 |
"domain": "academic",
|
| 1028 |
"created": "unknown",
|
src/test_biblioteka_nauki_contract.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
-
"""Contract checks for biblioteka_nauki: public-domain drop, per-record licence versions
|
| 2 |
-
(src/clean_biblioteka_nauki.py, data/biblioteka_nauki/recover_license_versions.py).
|
|
|
|
| 3 |
|
| 4 |
import hashlib
|
| 5 |
import importlib.util
|
|
@@ -17,8 +18,10 @@ import pytest
|
|
| 17 |
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 18 |
|
| 19 |
from clean_biblioteka_nauki import (
|
| 20 |
-
API_OVERRIDES, ATTRIBUTION_SEP, DATA, KEEP,
|
| 21 |
-
license_label, relabel, split_attribution, split_author,
|
|
|
|
|
|
|
| 22 |
from normalize_schema import SCHEMA
|
| 23 |
from sources import SOURCES
|
| 24 |
|
|
@@ -59,8 +62,8 @@ def stats():
|
|
| 59 |
|
| 60 |
|
| 61 |
@pytest.fixture(scope="module")
|
| 62 |
-
def
|
| 63 |
-
return json.loads(
|
| 64 |
|
| 65 |
|
| 66 |
def test_shard_has_no_public_domain_rows_and_matches_stats(stats):
|
|
@@ -80,10 +83,11 @@ def test_shard_has_no_public_domain_rows_and_matches_stats(stats):
|
|
| 80 |
assert pc.min(table.column("token_count")).as_py() > 0
|
| 81 |
authors = table.column("author").to_pylist()
|
| 82 |
assert all(isinstance(a, str) for a in authors)
|
| 83 |
-
assert sum(1 for a in authors if not a) ==
|
| 84 |
drops = ("drop_short", "drop_lang", "drop_dup", "drop_ocr", "drop_rights",
|
| 85 |
-
"drop_license_unverified", "drop_text_nc_nd", "drop_text_reprint")
|
| 86 |
assert stats["read"] - sum(stats[k] for k in drops) == stats["kept"]
|
|
|
|
| 87 |
assert stats["drop_rights"] == 3
|
| 88 |
assert stats["drop_license_unverified"] + stats["drop_text_nc_nd"] + stats["drop_text_reprint"] == len(stats["withheld"])
|
| 89 |
|
|
@@ -114,43 +118,52 @@ def test_maintainer_withholds_and_relabel_of_2026_10_06(stats):
|
|
| 114 |
assert (stats["drop_text_nc_nd"], stats["drop_text_reprint"]) == (56, 15)
|
| 115 |
assert API_OVERRIDES == {RELABELLED_ID: "CC-BY-SA-4.0"}
|
| 116 |
assert labels[RELABELLED_ID] == "CC-BY-SA-4.0" and RELABELLED_ID not in stats["withheld"]
|
| 117 |
-
assert stats["kept"] == 42055 + 1 - 71
|
| 118 |
|
| 119 |
|
| 120 |
-
def test_shard_labels_are_the_api_licences_in_the_sidecar(stats,
|
| 121 |
-
"""Every row's label is the one its API licence gives, and every shipped or
|
| 122 |
table = pq.read_table(DATA / "biblioteka_nauki.parquet", columns=["id", "license"])
|
| 123 |
ids = table.column("id").to_pylist()
|
| 124 |
for row_id, label in zip(ids, table.column("license").to_pylist()):
|
| 125 |
-
lic =
|
| 126 |
assert label == license_label(lic, lic["iconId"]), row_id
|
| 127 |
-
|
| 128 |
-
assert
|
| 129 |
-
assert
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
-
def test_evidence_file_matches_sidecar_and_stats(stats,
|
|
|
|
| 133 |
evidence = json.loads((DATA / "biblioteka_nauki.license-evidence.json").read_text(encoding="utf-8"))
|
| 134 |
-
assert evidence["sidecar_sha256"] == hashlib.sha256(
|
| 135 |
-
assert evidence["retrieved"] ==
|
| 136 |
by_id = {str(row["api_license_id"]): row for row in evidence["api_licenses"]}
|
| 137 |
-
assert set(by_id) == set(
|
| 138 |
-
rows_per_license = Counter(
|
| 139 |
-
for lid, lic in
|
| 140 |
row = by_id[lid]
|
| 141 |
assert (row["nameEn"], row["urlEn"]) == (lic["nameEn"], lic["urlEn"])
|
| 142 |
assert row["label"] == license_label(lic, lic["iconId"])
|
| 143 |
assert row["api_rows"] == rows_per_license[int(lid)]
|
| 144 |
-
assert
|
|
|
|
| 145 |
assert evidence["withheld"] == len(stats["withheld"])
|
| 146 |
-
assert evidence["flagged"] == Counter(flag for flags in
|
| 147 |
-
assert evidence["unchanged_vs_pr62"]["content_sha256"] ==
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
-
def
|
| 151 |
-
"""
|
| 152 |
-
|
| 153 |
-
assert content_digest(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
|
| 156 |
def test_content_digest_sees_text_ids_and_order_but_not_other_columns(tmp_path):
|
|
@@ -167,6 +180,62 @@ def test_content_digest_sees_text_ids_and_order_but_not_other_columns(tmp_path):
|
|
| 167 |
assert digest("f.parquet", ["x", "y", "w"], ["tx", "ty", "tw"], skip=frozenset({"w"})) == base
|
| 168 |
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
def test_build_fails_closed_on_an_unpinned_input(tmp_path):
|
| 172 |
fake = tmp_path / "biblioteka_nauki.parquet"
|
|
@@ -191,6 +260,13 @@ def test_datasheet_counts_match_stats(stats):
|
|
| 191 |
for name, count in classes.items():
|
| 192 |
assert f"| {name} | {count} |" in card, name
|
| 193 |
assert f"read {stats['read']:,} → kept {stats['kept']:,}" in card
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
assert "| Public Domain |" not in card
|
| 195 |
assert PROVENANCE in " ".join(card.lower().split())
|
| 196 |
assert "direct rebuild" not in card.lower()
|
|
@@ -410,21 +486,17 @@ def test_split_author_takes_the_first_citation_field():
|
|
| 410 |
assert split_author("Jolanta Kowol 1 | 2017 | Tytuł") == "Jolanta Kowol"
|
| 411 |
|
| 412 |
|
| 413 |
-
def
|
| 414 |
table = pa.table({
|
| 415 |
-
"id": ["a", "b"], "text": ["ta", "tb"], "source": ["biblioteka_nauki"] *
|
| 416 |
-
"added": ["2026-01-01"] *
|
| 417 |
-
"license": ["CC-BY-4.0"] *
|
| 418 |
-
"attribution": ["Jan Kowalski | 2020 | Tytuł | Wydawca", "Anna Nowak | 2021 | Inna"],
|
| 419 |
})
|
| 420 |
-
sidecar = tmp_path / "biblioteka_nauki.attribution.jsonl"
|
| 421 |
|
| 422 |
-
out = split_attribution(table
|
| 423 |
|
| 424 |
assert out.schema.names == SCHEMA.names
|
| 425 |
-
assert out.column("author").to_pylist() == ["Jan Kowalski", "Anna Nowak"]
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
{"id": "a", "attribution": "Jan Kowalski | 2020 | Tytuł | Wydawca"},
|
| 429 |
-
{"id": "b", "attribution": "Anna Nowak | 2021 | Inna"},
|
| 430 |
-
]
|
|
|
|
| 1 |
+
"""Contract checks for biblioteka_nauki: public-domain drop, per-record licence versions, the withheld rows and the reviewed drops
|
| 2 |
+
(src/clean_biblioteka_nauki.py, data/biblioteka_nauki/recover_license_versions.py). The review and the rules are tested in
|
| 3 |
+
src/test_licence_basis_biblioteka_nauki.py."""
|
| 4 |
|
| 5 |
import hashlib
|
| 6 |
import importlib.util
|
|
|
|
| 18 |
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 19 |
|
| 20 |
from clean_biblioteka_nauki import (
|
| 21 |
+
API_OVERRIDES, ATTRIBUTION_SEP, CLEANED_CONTENT_SHA256, DATA, KEEP, LICENSE_API, TEXT_NC_ND, TEXT_REPRINT, build, check_review,
|
| 22 |
+
clean_table, content_digest, filter_table, license_label, read_review, relabel, rows_digest, split_attribution, split_author,
|
| 23 |
+
withhold_listed)
|
| 24 |
+
import licence_basis_biblioteka_nauki as lbn
|
| 25 |
from normalize_schema import SCHEMA
|
| 26 |
from sources import SOURCES
|
| 27 |
|
|
|
|
| 62 |
|
| 63 |
|
| 64 |
@pytest.fixture(scope="module")
|
| 65 |
+
def api():
|
| 66 |
+
return json.loads(LICENSE_API.read_text(encoding="utf-8"))
|
| 67 |
|
| 68 |
|
| 69 |
def test_shard_has_no_public_domain_rows_and_matches_stats(stats):
|
|
|
|
| 83 |
assert pc.min(table.column("token_count")).as_py() > 0
|
| 84 |
authors = table.column("author").to_pylist()
|
| 85 |
assert all(isinstance(a, str) for a in authors)
|
| 86 |
+
assert sum(1 for a in authors if not a) == 25 # the `. .` placeholder citations (27 before the year rule dropped 2)
|
| 87 |
drops = ("drop_short", "drop_lang", "drop_dup", "drop_ocr", "drop_rights",
|
| 88 |
+
"drop_license_unverified", "drop_text_nc_nd", "drop_text_reprint", "drop_review")
|
| 89 |
assert stats["read"] - sum(stats[k] for k in drops) == stats["kept"]
|
| 90 |
+
assert stats["drop_review"] == sum(stats["drop_review_by_reason"].values())
|
| 91 |
assert stats["drop_rights"] == 3
|
| 92 |
assert stats["drop_license_unverified"] + stats["drop_text_nc_nd"] + stats["drop_text_reprint"] == len(stats["withheld"])
|
| 93 |
|
|
|
|
| 118 |
assert (stats["drop_text_nc_nd"], stats["drop_text_reprint"]) == (56, 15)
|
| 119 |
assert API_OVERRIDES == {RELABELLED_ID: "CC-BY-SA-4.0"}
|
| 120 |
assert labels[RELABELLED_ID] == "CC-BY-SA-4.0" and RELABELLED_ID not in stats["withheld"]
|
| 121 |
+
assert stats["kept"] + stats["drop_review"] == 42055 + 1 - 71 # the rows before the reviewed drops
|
| 122 |
|
| 123 |
|
| 124 |
+
def test_shard_labels_are_the_api_licences_in_the_sidecar(stats, api):
|
| 125 |
+
"""Every row's label is the one its API licence gives, and every shipped, withheld or review-dropped id is in the API file."""
|
| 126 |
table = pq.read_table(DATA / "biblioteka_nauki.parquet", columns=["id", "license"])
|
| 127 |
ids = table.column("id").to_pylist()
|
| 128 |
for row_id, label in zip(ids, table.column("license").to_pylist()):
|
| 129 |
+
lic = api["licenses"][str(api["rows"][row_id])]
|
| 130 |
assert label == license_label(lic, lic["iconId"]), row_id
|
| 131 |
+
review_dropped = {i for i, (decision, _) in read_review().items() if decision == lbn.DROP}
|
| 132 |
+
assert len(review_dropped) == stats["drop_review"]
|
| 133 |
+
assert not set(ids) & set(stats["withheld"]) and not set(ids) & review_dropped and not set(stats["withheld"]) & review_dropped
|
| 134 |
+
assert set(ids) | set(stats["withheld"]) | review_dropped == set(api["rows"]) | set(api["unresolved"])
|
| 135 |
+
assert api["rows_total"] == len(api["rows"]) + len(api["unresolved"]) == len(ids) + len(stats["withheld"]) + len(review_dropped)
|
| 136 |
|
| 137 |
|
| 138 |
+
def test_evidence_file_matches_sidecar_and_stats(stats, api):
|
| 139 |
+
"""The file records the state of Hub PR 81 (before the reviewed drops of v2#111); the checks below hold for that state."""
|
| 140 |
evidence = json.loads((DATA / "biblioteka_nauki.license-evidence.json").read_text(encoding="utf-8"))
|
| 141 |
+
assert evidence["sidecar_sha256"] == hashlib.sha256(LICENSE_API.read_bytes()).hexdigest()
|
| 142 |
+
assert evidence["retrieved"] == api["retrieved"]
|
| 143 |
by_id = {str(row["api_license_id"]): row for row in evidence["api_licenses"]}
|
| 144 |
+
assert set(by_id) == set(api["licenses"])
|
| 145 |
+
rows_per_license = Counter(api["rows"].values())
|
| 146 |
+
for lid, lic in api["licenses"].items():
|
| 147 |
row = by_id[lid]
|
| 148 |
assert (row["nameEn"], row["urlEn"]) == (lic["nameEn"], lic["urlEn"])
|
| 149 |
assert row["label"] == license_label(lic, lic["iconId"])
|
| 150 |
assert row["api_rows"] == rows_per_license[int(lid)]
|
| 151 |
+
assert stats["licenses"].get(row["label"], 0) <= row["shipped"] # the reviewed drops only remove rows
|
| 152 |
+
assert sum(row["shipped"] for row in evidence["api_licenses"]) == stats["kept"] + stats["drop_review"] == 41985
|
| 153 |
assert evidence["withheld"] == len(stats["withheld"])
|
| 154 |
+
assert evidence["flagged"] == Counter(flag for flags in api["flagged"].values() for flag in flags)
|
| 155 |
+
assert evidence["unchanged_vs_pr62"]["content_sha256"] == CLEANED_CONTENT_SHA256
|
| 156 |
+
assert "review.csv" in evidence["after_the_review_of_2026_10_20"]
|
| 157 |
|
| 158 |
|
| 159 |
+
def test_shard_text_and_ids_match_the_recorded_digests(stats):
|
| 160 |
+
"""The shard on disk hashes to the digest in the stats, and every column of every row to the one in the evidence file."""
|
| 161 |
+
path = DATA / "biblioteka_nauki.parquet"
|
| 162 |
+
assert content_digest(path) == stats["content_sha256"]
|
| 163 |
+
evidence = json.loads((DATA / "biblioteka_nauki.licence-basis.json").read_text(encoding="utf-8"))
|
| 164 |
+
assert evidence["review"]["kept"] == {**evidence["review"]["kept"], "rows": stats["kept"], "rows_sha256": rows_digest(path)}
|
| 165 |
+
assert evidence["input"]["rows_before_review_content_sha256"] == CLEANED_CONTENT_SHA256
|
| 166 |
+
assert evidence["input"]["rows_before_review"] == stats["kept"] + stats["drop_review"]
|
| 167 |
|
| 168 |
|
| 169 |
def test_content_digest_sees_text_ids_and_order_but_not_other_columns(tmp_path):
|
|
|
|
| 180 |
assert digest("f.parquet", ["x", "y", "w"], ["tx", "ty", "tw"], skip=frozenset({"w"})) == base
|
| 181 |
|
| 182 |
|
| 183 |
+
def test_rows_digest_sees_every_column_and_the_row_order(tmp_path):
|
| 184 |
+
columns = {"id": ["x", "y"], "text": ["tx", "ty"], "license": ["CC-BY-4.0", "CC-BY-4.0"]}
|
| 185 |
+
base = rows_digest(pa.table(columns))
|
| 186 |
+
assert rows_digest(pa.table({**columns, "license": ["CC-BY-4.0", "CC-BY-SA-4.0"]})) != base
|
| 187 |
+
assert rows_digest(pa.table({**columns, "text": ["tx", "tY"]})) != base
|
| 188 |
+
assert rows_digest(pa.table({k: v[::-1] for k, v in columns.items()})) != base
|
| 189 |
+
assert rows_digest(pa.table({k: v + ["w"] for k, v in columns.items()}), skip=frozenset({"w"})) == base
|
| 190 |
+
path = tmp_path / "a.parquet"
|
| 191 |
+
pq.write_table(pa.table(columns), path)
|
| 192 |
+
assert rows_digest(path) == base # a file and its table digest alike
|
| 193 |
+
assert content_digest(path) == content_digest(pa.table(columns))
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def test_clean_table_counts_what_each_step_takes_and_lists_the_withheld():
|
| 197 |
+
table = pa.table({"id": ["a", "b", "c", "d", "e", "f"], "text": ["ta", "tb", "tc", "td", "te", "tf"],
|
| 198 |
+
"license": ["cc-by", "cc-by-sa", "public-domain", "cc-by", "cc-by", "cc-by"]})
|
| 199 |
+
api = {"licenses": {"1": BY_40, "2": BYSA_40}, "rows": {"a": 1, "b": 2, "d": 1, "e": 1}, "unresolved": {"f": "http404"}}
|
| 200 |
+
kept, counts, withheld = clean_table(table, api, overrides={}, nc_nd={"d": "NC"}, reprint={"e": "reprint"})
|
| 201 |
+
assert kept.column("id").to_pylist() == ["a", "b"]
|
| 202 |
+
assert kept.column("license").to_pylist() == ["CC-BY-4.0", "CC-BY-SA-4.0"]
|
| 203 |
+
assert counts == {"drop_rights": 1, "drop_license_unverified": 1, "drop_text_nc_nd": 1, "drop_text_reprint": 1}
|
| 204 |
+
assert withheld == {"f": "API: http404", "d": "NC", "e": "reprint"}
|
| 205 |
+
with pytest.raises(SystemExit, match="listed ids not reached"):
|
| 206 |
+
clean_table(table, api, overrides={}, nc_nd={"c": "already dropped as public domain"}, reprint={})
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
def test_the_pinned_review_refuses_a_changed_table(tmp_path):
|
| 210 |
+
review = read_review()
|
| 211 |
+
assert len(review) == 4205 and Counter(decision for decision, _ in review.values()) == {lbn.DROP: 4142, lbn.KEEP: 63}
|
| 212 |
+
altered = tmp_path / "biblioteka_nauki.review.csv"
|
| 213 |
+
altered.write_bytes((DATA / "biblioteka_nauki.review.csv").read_bytes() + b"biblioteka_nauki_articles_1,drop,text_garbled\n")
|
| 214 |
+
with pytest.raises(SystemExit):
|
| 215 |
+
read_review(altered) # changed after it was pinned
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def test_check_review_refuses_a_review_the_rules_do_not_give():
|
| 219 |
+
final = {"a": (lbn.DROP, "file_is_another_work", "file_mismatch"), "b": (lbn.KEEP, "text_garbled", "file_mismatch")}
|
| 220 |
+
proposed = lbn.proposed_review(final)
|
| 221 |
+
assert proposed == {"a": (lbn.DROP, "file_is_another_work"), "b": (lbn.KEEP, "text_garbled")}
|
| 222 |
+
check_review(dict(proposed), final)
|
| 223 |
+
for review in ({**proposed, "a": (lbn.KEEP, "text_garbled")}, # a decision changed
|
| 224 |
+
{**proposed, "c": (lbn.DROP, "file_is_another_work")}, # a row no rule nominates
|
| 225 |
+
{"a": proposed["a"]}): # a nominated row without a decision
|
| 226 |
+
with pytest.raises(SystemExit, match="disagree"):
|
| 227 |
+
check_review(review, final)
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
def test_kept_rows_are_the_rows_before_the_review_minus_the_dropped(stats):
|
| 231 |
+
"""Every column of every kept row hashes to the digest the build recorded from the rows before the review."""
|
| 232 |
+
path = DATA / "biblioteka_nauki.parquet"
|
| 233 |
+
evidence = json.loads((DATA / "biblioteka_nauki.licence-basis.json").read_text(encoding="utf-8"))
|
| 234 |
+
dropped = {i for i, (decision, _) in read_review().items() if decision == lbn.DROP}
|
| 235 |
+
ids = pq.read_table(path, columns=["id"]).column("id").to_pylist()
|
| 236 |
+
assert not set(ids) & dropped and len(ids) == stats["kept"]
|
| 237 |
+
assert rows_digest(path) == evidence["review"]["kept"]["rows_sha256"]
|
| 238 |
+
|
| 239 |
|
| 240 |
def test_build_fails_closed_on_an_unpinned_input(tmp_path):
|
| 241 |
fake = tmp_path / "biblioteka_nauki.parquet"
|
|
|
|
| 260 |
for name, count in classes.items():
|
| 261 |
assert f"| {name} | {count} |" in card, name
|
| 262 |
assert f"read {stats['read']:,} → kept {stats['kept']:,}" in card
|
| 263 |
+
assert f"(`src/clean_biblioteka_nauki.py`, polish-dynaword-v2#111): **{stats['drop_review']:,}**" in card
|
| 264 |
+
for reason, count in stats["drop_review_by_reason"].items():
|
| 265 |
+
assert f"| {reason} | {count:,} |" in card, reason
|
| 266 |
+
basis = Counter(json.loads(line)["licence_basis"] for line in (DATA / "biblioteka_nauki.attribution.jsonl").read_text(encoding="utf-8").splitlines())
|
| 267 |
+
for code, count in basis.items():
|
| 268 |
+
assert f"| `{code}` | {count:,} |" in card, code
|
| 269 |
+
assert "Journal adoption years could not be obtained" in card and "may therefore remain" in card
|
| 270 |
assert "| Public Domain |" not in card
|
| 271 |
assert PROVENANCE in " ".join(card.lower().split())
|
| 272 |
assert "direct rebuild" not in card.lower()
|
|
|
|
| 486 |
assert split_author("Jolanta Kowol 1 | 2017 | Tytuł") == "Jolanta Kowol"
|
| 487 |
|
| 488 |
|
| 489 |
+
def test_split_attribution_replaces_the_citation_by_its_author_in_the_canonical_columns():
|
| 490 |
table = pa.table({
|
| 491 |
+
"id": ["a", "b", "c"], "text": ["ta", "tb", "tc"], "source": ["biblioteka_nauki"] * 3,
|
| 492 |
+
"added": ["2026-01-01"] * 3, "created": [""] * 3, "token_count": [1, 2, 3],
|
| 493 |
+
"license": ["CC-BY-4.0"] * 3,
|
| 494 |
+
"attribution": ["Jan Kowalski | 2020 | Tytuł | Wydawca", "Anna Nowak | 2021 | Inna", ". . | 2015 | Noty o autorach"],
|
| 495 |
})
|
|
|
|
| 496 |
|
| 497 |
+
out = split_attribution(table)
|
| 498 |
|
| 499 |
assert out.schema.names == SCHEMA.names
|
| 500 |
+
assert out.column("author").to_pylist() == ["Jan Kowalski", "Anna Nowak", ""]
|
| 501 |
+
for name in ("id", "text", "license", "token_count"):
|
| 502 |
+
assert out.column(name).to_pylist() == table.column(name).to_pylist()
|
|
|
|
|
|
|
|
|
src/test_biblioteka_nauki_overlap.py
CHANGED
|
@@ -6,12 +6,12 @@ import sys
|
|
| 6 |
import types
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
import pyarrow as pa
|
| 10 |
import pytest
|
| 11 |
|
| 12 |
from biblioteka_nauki_overlap import (
|
| 13 |
SIDECAR, citation_title, fetch_attribution_targets, normalize_title, read_attribution_targets)
|
| 14 |
-
from
|
|
|
|
| 15 |
|
| 16 |
SRC = Path(__file__).resolve().parent
|
| 17 |
REPO = "SlayerLab/polish-dynaword"
|
|
@@ -24,16 +24,11 @@ CITATIONS = {
|
|
| 24 |
|
| 25 |
|
| 26 |
@pytest.fixture
|
| 27 |
-
def sidecar_bytes(
|
| 28 |
-
"""The sidecar as clean_biblioteka_nauki writes it, so a change to the writer breaks the reader's test."""
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
"created": [""] * n, "token_count": [1] * n, "license": ["CC-BY-4.0"] * n, "attribution": list(CITATIONS.values()),
|
| 33 |
-
})
|
| 34 |
-
path = tmp_path / "biblioteka_nauki.attribution.jsonl"
|
| 35 |
-
split_attribution(table, path)
|
| 36 |
-
return path.read_bytes()
|
| 37 |
|
| 38 |
|
| 39 |
def fake_hub(monkeypatch, files):
|
|
|
|
| 6 |
import types
|
| 7 |
from pathlib import Path
|
| 8 |
|
|
|
|
| 9 |
import pytest
|
| 10 |
|
| 11 |
from biblioteka_nauki_overlap import (
|
| 12 |
SIDECAR, citation_title, fetch_attribution_targets, normalize_title, read_attribution_targets)
|
| 13 |
+
from licence_basis import merge_basis
|
| 14 |
+
from licence_basis_biblioteka_nauki import sidecar_bytes as write_sidecar
|
| 15 |
|
| 16 |
SRC = Path(__file__).resolve().parent
|
| 17 |
REPO = "SlayerLab/polish-dynaword"
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
@pytest.fixture
|
| 27 |
+
def sidecar_bytes():
|
| 28 |
+
"""The sidecar as clean_biblioteka_nauki writes it (its line shape and serialiser), so a change to the writer breaks the reader's test."""
|
| 29 |
+
lines = [merge_basis({"id": row_id, "attribution": citation}, "depositor", "https://bibliotekanauki.pl/api/articles/1", "2026-10-05/2026-10-06")
|
| 30 |
+
for row_id, citation in CITATIONS.items()]
|
| 31 |
+
return write_sidecar(lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
def fake_hub(monkeypatch, files):
|
src/test_licence_basis.py
CHANGED
|
@@ -115,5 +115,39 @@ class MergeBasisTest(unittest.TestCase):
|
|
| 115 |
self.assertEqual(line["licence_basis"], "none") # the input is not mutated
|
| 116 |
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
if __name__ == "__main__":
|
| 119 |
unittest.main()
|
|
|
|
| 115 |
self.assertEqual(line["licence_basis"], "none") # the input is not mutated
|
| 116 |
|
| 117 |
|
| 118 |
+
class ReleaseYearTest(unittest.TestCase):
|
| 119 |
+
"""The year rule's table, shared by biblioteka_nauki and open_icm_pl."""
|
| 120 |
+
|
| 121 |
+
def test_release_year_is_the_first_year_of_the_licence_version(self):
|
| 122 |
+
for label, year in [("CC-BY-2.0", 2004), ("CC-BY-3.0", 2007), ("CC-BY-3.0-PL", 2007), ("CC-BY-SA-3.0", 2007),
|
| 123 |
+
("CC-BY-SA-3.0-PL", 2007), ("CC-BY-4.0", 2013), ("CC-BY-SA-4.0", 2013)]:
|
| 124 |
+
with self.subTest(label=label):
|
| 125 |
+
self.assertEqual(lb.release_year(label), year)
|
| 126 |
+
self.assertEqual(set(lb.RELEASE), {"CC-BY-2.0", "CC-BY-3.0", "CC-BY-3.0-PL", "CC-BY-SA-3.0", "CC-BY-SA-3.0-PL", "CC-BY-4.0", "CC-BY-SA-4.0"})
|
| 127 |
+
|
| 128 |
+
def test_release_year_fails_for_a_label_it_does_not_list(self):
|
| 129 |
+
for label in ("CC-BY-2.5", "CC-BY-2.0-PL", "CC-BY-NC-4.0", "cc-by", ""):
|
| 130 |
+
with self.subTest(label=label), self.assertRaisesRegex(ValueError, "no release year"):
|
| 131 |
+
lb.release_year(label)
|
| 132 |
+
|
| 133 |
+
def test_a_polish_port_is_given_the_year_of_its_generic_version(self):
|
| 134 |
+
for generic, port in [("CC-BY-3.0", "CC-BY-3.0-PL"), ("CC-BY-SA-3.0", "CC-BY-SA-3.0-PL")]:
|
| 135 |
+
with self.subTest(port=port):
|
| 136 |
+
self.assertEqual(lb.release_year(port), lb.release_year(generic))
|
| 137 |
+
|
| 138 |
+
def test_created_year_is_the_start_year(self):
|
| 139 |
+
for created, year in [("2011", 2011), ("2021-05", 2021), ("2024-01-31", 2024), ("2013-12-31/2014-01-02", 2013)]:
|
| 140 |
+
with self.subTest(created=created):
|
| 141 |
+
self.assertEqual(lb.created_year(created), year)
|
| 142 |
+
|
| 143 |
+
def test_created_year_fails_without_four_leading_digits(self):
|
| 144 |
+
for created in ("", "201", "n.d.", " 2011", "x2011"):
|
| 145 |
+
with self.subTest(created=created), self.assertRaisesRegex(ValueError, "no start year"):
|
| 146 |
+
lb.created_year(created)
|
| 147 |
+
|
| 148 |
+
def test_reason_name(self):
|
| 149 |
+
self.assertEqual(lb.CREATED_BEFORE, "created_before_licence_version")
|
| 150 |
+
|
| 151 |
+
|
| 152 |
if __name__ == "__main__":
|
| 153 |
unittest.main()
|
src/test_licence_basis_biblioteka_nauki.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Per-record licence basis and reviewed drops of biblioteka_nauki (v2#111): sidecar, evidence file and review table, checked against the shipped
|
| 2 |
+
parquet. The step from the v0.2.5 shard to these files (src/clean_biblioteka_nauki.py) needs that shard, which only git history holds; its pure parts
|
| 3 |
+
are tested in src/test_biblioteka_nauki_contract.py."""
|
| 4 |
+
import json
|
| 5 |
+
import re
|
| 6 |
+
import sys
|
| 7 |
+
from collections import Counter
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import pyarrow.parquet as pq
|
| 11 |
+
import pytest
|
| 12 |
+
|
| 13 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 14 |
+
import licence_basis as lb # noqa: E402
|
| 15 |
+
import licence_basis_biblioteka_nauki as lbn # noqa: E402
|
| 16 |
+
from clean_biblioteka_nauki import ATTRIBUTION, DATA, EVIDENCE, LICENSE_API, PARQUET, REVIEW, REVIEW_SHA256, STATS, read_review # noqa: E402
|
| 17 |
+
from sejm_api_common import sha256_file # noqa: E402
|
| 18 |
+
from sources import SOURCES # noqa: E402
|
| 19 |
+
|
| 20 |
+
RESTRICTION_REASONS = {"restriction_notice_no_cc_note", "arr_only_no_cc_note", "restriction_notice_beside_cc_note", "not_a_notice_on_the_work"}
|
| 21 |
+
RULE_OF = {**{reason: rule for rule, groups in lbn.HAND.items() for _, reason in groups}, **dict.fromkeys(RESTRICTION_REASONS, "restriction_notice"),
|
| 22 |
+
lbn.CREATED_BEFORE: lbn.CREATED_BEFORE}
|
| 23 |
+
_PEOPLE_OR_ADVISERS = re.compile("(?i)" + "law" + "yer|legal " + "advis|prawn" + "ik|radca")
|
| 24 |
+
LABELS = {"CC-BY-4.0": 15449, "CC-BY-SA-4.0": 9440, "CC-BY-3.0-PL": 7949, "CC-BY-SA-3.0-PL": 2691, "CC-BY-3.0": 2306, "CC-BY-SA-3.0": 7, "CC-BY-2.0": 1}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def parquet_ids():
|
| 28 |
+
return pq.read_table(PARQUET, columns=["id"]).column("id").to_pylist()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def sidecar():
|
| 32 |
+
return lbn.read_sidecar(ATTRIBUTION)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def review_table():
|
| 36 |
+
return [line.split(",") for line in REVIEW.read_text(encoding="utf-8").splitlines()]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def evidence():
|
| 40 |
+
return json.loads(EVIDENCE.read_text(encoding="utf-8"))
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@pytest.fixture(scope="module")
|
| 44 |
+
def recs():
|
| 45 |
+
"""The shipped rows scanned by the rules, as the build scans them (the citation comes from the sidecar)."""
|
| 46 |
+
table = pq.read_table(PARQUET)
|
| 47 |
+
table = table.drop_columns(["author"]).append_column("attribution", [[line["attribution"] for line in sidecar()]])
|
| 48 |
+
return lbn.scan(table)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# --- the shipped files -------------------------------------------------------------------------------------------------
|
| 52 |
+
def test_sidecar_has_a_valid_basis_for_every_row_in_order_and_keeps_its_bytes():
|
| 53 |
+
lines, raw = sidecar(), ATTRIBUTION.read_bytes()
|
| 54 |
+
assert lb.check_lines(lines, parquet_ids()) == []
|
| 55 |
+
assert lbn.sidecar_bytes(lines) == raw and b"\r" not in raw # LF, default json.dumps, as before
|
| 56 |
+
assert all(list(line) == ["id", "attribution", *lb.FIELDS] for line in lines)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def test_counts_urls_and_dates_per_code():
|
| 60 |
+
table = pq.read_table(PARQUET, columns=["id", "added", "license", "token_count"]).to_pylist()
|
| 61 |
+
lines = sidecar()
|
| 62 |
+
assert Counter(line["licence_basis"] for line in lines) == Counter(file_note=2657, depositor=35186)
|
| 63 |
+
tokens = Counter()
|
| 64 |
+
for row, line in zip(table, lines):
|
| 65 |
+
kind, number = row["id"].removeprefix("biblioteka_nauki_").split("_")
|
| 66 |
+
code = line["licence_basis"]
|
| 67 |
+
tokens[code] += row["token_count"]
|
| 68 |
+
if code == "file_note":
|
| 69 |
+
assert (line["licence_basis_url"], line["licence_basis_date"]) == (f"https://bibliotekanauki.pl/{kind}/{number}", row["added"])
|
| 70 |
+
else:
|
| 71 |
+
assert (line["licence_basis_url"], line["licence_basis_date"]) == (f"https://bibliotekanauki.pl/api/{kind}/{number}", "2026-10-05/2026-10-06")
|
| 72 |
+
ev = evidence()
|
| 73 |
+
assert {c: tokens[c] for c in tokens} == {c: v["tokens"] for c, v in ev["by_code"].items()} == {"file_note": 72177558, "depositor": 518747238}
|
| 74 |
+
assert ev["counts"] == {"file_note": 2657, "publisher": 0, "depositor": 35186, "none": 0} and ev["added_dates"] == ["2026-06-27"]
|
| 75 |
+
labels = Counter(row["license"] for row in table)
|
| 76 |
+
assert labels == Counter(LABELS)
|
| 77 |
+
assert {k: sum(v.values()) for k, v in ev["by_label"].items()} == labels
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def test_the_basis_fields_are_what_the_rules_give_for_the_shipped_rows(recs):
|
| 81 |
+
assert [r["id"] for r in recs] == parquet_ids()
|
| 82 |
+
citations = [line["attribution"] for line in sidecar()]
|
| 83 |
+
assert lbn.attribution_lines(recs, citations) == sidecar() # code, URL and date of every line
|
| 84 |
+
stats = json.loads(STATS.read_text(encoding="utf-8"))
|
| 85 |
+
assert lbn.measure(recs) == {"rows": stats["kept"], "characters": stats["chars"], "tokens": stats["tokens"]} == evidence()["review"]["shipped"]
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def test_file_note_rows_are_exactly_the_rows_whose_text_prints_the_labels_licence(recs):
|
| 89 |
+
noted = {r["id"] for r in recs if r["note"] == "file_note"}
|
| 90 |
+
assert len(noted) == 2657 and noted == {line["id"] for line in sidecar() if line["licence_basis"] == "file_note"}
|
| 91 |
+
assert Counter(r["note"] for r in recs) == Counter(file_note=2657, conflict=8, none=37843 - 2657 - 8)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def test_no_shipped_row_is_one_a_rule_drops(recs):
|
| 95 |
+
"""A shipped row that a rule nominates is in the review table as `keep`; the year rule leaves no shipped row."""
|
| 96 |
+
review = {r[0]: (r[1], r[2]) for r in review_table()[1:]}
|
| 97 |
+
nominated = {r["id"] for r in recs if r["note"] == "conflict" or r["mismatch"] or r["restriction"]}
|
| 98 |
+
assert {i: review[i][0] for i in nominated} == dict.fromkeys(nominated, lbn.KEEP)
|
| 99 |
+
assert all(r["year"] >= lb.release_year(r["label"]) for r in recs)
|
| 100 |
+
assert not {r["id"] for r in recs} & {i for i, (decision, _) in review.items() if decision == lbn.DROP}
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
# --- the review table ------------------------------------------------------------------------------------------------
|
| 104 |
+
def test_review_table_is_pinned_and_well_formed():
|
| 105 |
+
assert sha256_file(REVIEW) == REVIEW_SHA256
|
| 106 |
+
raw, table = REVIEW.read_bytes(), review_table()
|
| 107 |
+
assert b"\r" not in raw and raw.endswith(b"\n")
|
| 108 |
+
assert table[0] == ["id", "decision", "reason"] and all(len(r) == 3 for r in table)
|
| 109 |
+
ids = [r[0] for r in table[1:]]
|
| 110 |
+
assert ids == sorted(set(ids))
|
| 111 |
+
assert {r[1] for r in table[1:]} == {lbn.DROP, lbn.KEEP} and {r[2] for r in table[1:]} <= set(lbn.REASON_TEXT)
|
| 112 |
+
by_reason = {}
|
| 113 |
+
for _, decision, reason in table[1:]:
|
| 114 |
+
by_reason.setdefault(reason, set()).add(decision)
|
| 115 |
+
assert all(len(v) == 1 and v == {d for d, group in lbn.REASONS.items() if reason in group} for reason, v in by_reason.items())
|
| 116 |
+
assert Counter(r[1] for r in table[1:]) == Counter(drop=4142, keep=63) and len(table) == 4206
|
| 117 |
+
assert read_review() == {i: (d, r) for i, d, r in table[1:]}
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def test_review_matches_the_shipped_rows_the_stats_and_the_evidence():
|
| 121 |
+
stats, ev = json.loads(STATS.read_text(encoding="utf-8")), evidence()
|
| 122 |
+
table = review_table()[1:]
|
| 123 |
+
shipped = set(parquet_ids())
|
| 124 |
+
assert {i for i, d, _ in table if d == lbn.KEEP} <= shipped and not {i for i, d, _ in table if d == lbn.DROP} & shipped
|
| 125 |
+
dropped = Counter(reason for _, d, reason in table if d == lbn.DROP)
|
| 126 |
+
assert dropped == stats["drop_review_by_reason"] and sum(dropped.values()) == stats["drop_review"] == 4142
|
| 127 |
+
assert {reason: v["rows"] for reason, v in ev["review"]["by_reason"].items()} == Counter(reason for _, _, reason in table)
|
| 128 |
+
assert ev["review"]["sha256"] == REVIEW_SHA256 and ev["review"]["rows"] == len(table) == 4205
|
| 129 |
+
assert ev["review"]["decided"]["drop"]["rows"] == 4142 and ev["review"]["rule_order"] == list(lbn.PRIORITY)
|
| 130 |
+
assert ev["input"]["rows_before_review"] == 41985 == stats["kept"] + stats["drop_review"]
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def test_clear_cut_drops_of_decision_1a_and_2a():
|
| 134 |
+
dropped = Counter(r[2] for r in review_table()[1:] if r[1] == lbn.DROP)
|
| 135 |
+
assert {k: dropped[k] for k in dropped if k != lbn.CREATED_BEFORE} == {
|
| 136 |
+
"printed_licence_nc_or_nd": 4, "file_is_another_work": 16, "reprint_or_prior_publication": 30, "republished_by_permission": 11,
|
| 137 |
+
"translation_of_earlier_publication": 17, "translation_title_marker": 5, "api_flagged_reprint_translation": 5, # decision 1A: 88
|
| 138 |
+
"restriction_notice_no_cc_note": 97} # decision 2A
|
| 139 |
+
assert sum(v for k, v in dropped.items() if k not in (lbn.CREATED_BEFORE, "restriction_notice_no_cc_note")) == 88
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def test_known_rows_are_in_the_review():
|
| 143 |
+
reasons = {r[0]: (r[1], r[2]) for r in review_table()[1:]}
|
| 144 |
+
flagged = set(evidence()["api_flags"])
|
| 145 |
+
assert len(flagged) == 5 and all(reasons[i] == (lbn.DROP, "api_flagged_reprint_translation") for i in flagged)
|
| 146 |
+
overlaps = evidence()["overlaps"]
|
| 147 |
+
assert len(overlaps) == 40 and all(len(rules) > 1 for rules in overlaps.values())
|
| 148 |
+
ids = {i for i, rules in overlaps.items() if lbn.CREATED_BEFORE in rules}
|
| 149 |
+
assert len(ids) == 39 and len(set(overlaps) - ids) == 1 # the 40th: an API flag that is also a restriction notice
|
| 150 |
+
assert Counter(reasons[i][1] == lbn.CREATED_BEFORE for i in ids) == Counter({False: 32, True: 7}) # 32 keep their first drop reason, 7 flip from keep
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def test_year_rule_numbers_the_report_quotes():
|
| 154 |
+
ev = evidence()
|
| 155 |
+
year = ev[lbn.CREATED_BEFORE]
|
| 156 |
+
assert {k: year[k] for k in ("rows", "characters", "tokens")} == {"rows": 3989, "characters": 184805600, "tokens": 71278767}
|
| 157 |
+
assert sum(year["by_label"].values()) == 3989 and set(year["release_year"]) == set(lb.RELEASE)
|
| 158 |
+
overlap = year["overlap"]
|
| 159 |
+
assert sum(overlap["already_dropped_by_another_rule"].values()) == 32 and sum(overlap["flipped_from_keep"].values()) == 7
|
| 160 |
+
assert overlap["not_otherwise_in_review"] == 3950 and overlap["dropped_with_this_reason"] == 3957 == 3989 - 32
|
| 161 |
+
assert ev["review"]["by_reason"][lbn.CREATED_BEFORE] == {"rows": 3957, "characters": 181784176, "tokens": 70103154}
|
| 162 |
+
assert ev["review"]["by_reason"]["restriction_notice_no_cc_note"] == {"rows": 97, "characters": 14700907, "tokens": 5882338}
|
| 163 |
+
assert ev["review"]["source"] == {"rows": 41985, "characters": 1739004913, "tokens": 669909430}
|
| 164 |
+
assert ev["journal_adoption"]["obtainable"] is False and ev["publisher_check"]["done"] is False
|
| 165 |
+
assert ev["not_screened"]["translations_of_source_texts"]["dropped_by_review"] == {"biblioteka_nauki_articles_534737": "reprint_or_prior_publication"}
|
| 166 |
+
assert ev["not_screened"]["translations_of_source_texts"]["rows"] == 8
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
# --- hand decisions and rule functions ---------------------------------------------------------------------------------
|
| 170 |
+
def test_hand_decisions_are_unique_per_rule_and_use_known_reasons():
|
| 171 |
+
for rule, groups in lbn.HAND.items():
|
| 172 |
+
flat = [i for group in groups.values() for i in group]
|
| 173 |
+
assert len(flat) == len(set(flat)), rule
|
| 174 |
+
assert {decision for decision, _ in groups} <= {lbn.DROP, lbn.KEEP} and {reason for _, reason in groups} <= set(lbn.REASON_TEXT)
|
| 175 |
+
assert all((decision, reason) in {(d, r) for d, g in lbn.REASONS.items() for r in g} for decision, reason in groups)
|
| 176 |
+
assert list(lbn.PRIORITY) == ["printed_note", "prior_publication", "file_mismatch", "restriction_notice", lbn.CREATED_BEFORE]
|
| 177 |
+
assert set(RULE_OF.values()) <= set(lbn.PRIORITY) and set(lbn.NOMINATED) == set(lbn.PRIORITY)
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def test_every_reason_has_a_text_and_one_decision():
|
| 181 |
+
assert set(lbn.REASONS) == {lbn.DROP, lbn.KEEP} and not set(lbn.REASONS[lbn.DROP]) & set(lbn.REASONS[lbn.KEEP])
|
| 182 |
+
assert all(text.strip() for text in lbn.REASON_TEXT.values()) and len(lbn.REASON_TEXT) == len(lbn.REASONS[lbn.DROP]) + len(lbn.REASONS[lbn.KEEP])
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def test_restriction_rule():
|
| 186 |
+
assert lbn.restriction("Tytuł. Wszelkie prawa zastrzeżone. Kopiowanie bez zgody wydawcy zabronione. " + "x" * 9000) == "clause"
|
| 187 |
+
assert lbn.restriction("Wszelkie prawa zastrzeżone.\n" + "x" * 9000) == "arr_only"
|
| 188 |
+
assert lbn.restriction("Przedruk w całości lub w części bez pisemnej zgody redakcji jest zabroniony. " + "x" * 9000) == "clause"
|
| 189 |
+
assert lbn.restriction("Treść.\n" + "x" * 9000 + "\n All rights reserved. Reproduction without prior written permission is prohibited") == "clause"
|
| 190 |
+
assert lbn.restriction("Treść. " + "x" * 5000 + " wszelkie prawa zastrzeżone " + "x" * 5000) is None # middle of the text
|
| 191 |
+
assert lbn.restriction("Treść bez uwag.") is None
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def test_file_mismatch_rule():
|
| 195 |
+
citation = "Jan Kowalski; Anna Nowak | 2020 | Ptaki wodne Mazowsza | Wydawca"
|
| 196 |
+
assert lbn.file_mismatch("Zupełnie inny tekst o gospodarce. " * 400, citation) is True
|
| 197 |
+
assert lbn.file_mismatch("Ptaki wodne w Polsce. " + "x " * 500, citation) is False # a title word in the first 6000 characters
|
| 198 |
+
assert lbn.file_mismatch("Inny tytuł. " + "x " * 500 + " Autor: Nowak", citation) is False # a surname in the head
|
| 199 |
+
assert lbn.file_mismatch("Inny tekst. " * 400, "Jan Kowalski | 2020 | Dom | Wydawca") is False # no title word of 4 letters: not decidable
|
| 200 |
+
assert lbn.file_mismatch("Inny tekst. " * 400, " | 2020 | Ptaki wodne | Wydawca") is False # no author: not decidable
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def test_prior_publication_rule():
|
| 204 |
+
citation = "Jan Kowalski | 2020 | Ptaki wodne | Wydawca"
|
| 205 |
+
assert "reprint_word" in lbn.prior_publication_hits("Przedruk z czasopisma X.\n" + "x" * 5000, citation)
|
| 206 |
+
assert lbn.prior_publication_hits("Przedruk w tekście dalekim. ".rjust(5000, "x"), citation) == () # beyond the front matter
|
| 207 |
+
assert lbn.prior_publication_hits("Treść.", "Jan Kowalski | 2020 | Ptaki wodne (tłum. z angielskiego) | Wydawca") == ("title_translation",)
|
| 208 |
+
assert "translator_credit" in lbn.prior_publication_hits("Ptaki wodne\nPrzekład: Jan Kowalski\nTreść artykułu", citation)
|
| 209 |
+
assert lbn.prior_publication_hits("Treść bez uwag.", citation) == ()
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
def _rec(row_id, label, year, **over):
|
| 213 |
+
return {"id": row_id, "label": label, "year": year, "note": "none", "mismatch": False, "restriction": None, "prior": (), **over}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def test_year_rule_selects_rows_created_before_the_licence_version(monkeypatch):
|
| 217 |
+
monkeypatch.setattr(lbn, "HAND", {rule: {} for rule in lbn.HAND})
|
| 218 |
+
monkeypatch.setattr(lbn, "NOT_A_NOTICE", ())
|
| 219 |
+
recs = [_rec("a", "CC-BY-4.0", 2012), _rec("b", "CC-BY-4.0", 2013), _rec("c", "CC-BY-3.0-PL", 2006), _rec("d", "CC-BY-3.0-PL", 2007),
|
| 220 |
+
_rec("e", "CC-BY-2.0", 2003), _rec("f", "CC-BY-2.0", 2004)]
|
| 221 |
+
assert lbn.decisions(recs, set())[lbn.CREATED_BEFORE] == dict.fromkeys("ace", (lbn.DROP, lbn.CREATED_BEFORE))
|
| 222 |
+
with pytest.raises(ValueError, match="no release year"):
|
| 223 |
+
lbn.decisions([_rec("z", "CC-BY-NC-4.0", 2020)], set())
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
def test_a_row_dropped_by_an_earlier_rule_keeps_its_first_reason_and_a_kept_one_is_dropped_by_the_year_rule():
|
| 227 |
+
by_rule = {"printed_note": {"a": (lbn.KEEP, "discusses_licence")},
|
| 228 |
+
"prior_publication": {"b": (lbn.DROP, "republished_by_permission")},
|
| 229 |
+
"file_mismatch": {}, "restriction_notice": {"c": (lbn.DROP, "restriction_notice_no_cc_note")},
|
| 230 |
+
lbn.CREATED_BEFORE: {i: (lbn.DROP, lbn.CREATED_BEFORE) for i in "abcd"}}
|
| 231 |
+
final = lbn.final_reasons(by_rule)
|
| 232 |
+
assert final == {"a": (lbn.DROP, lbn.CREATED_BEFORE, lbn.CREATED_BEFORE), # kept by the printed-note rule, dropped by the year
|
| 233 |
+
"b": (lbn.DROP, "republished_by_permission", "prior_publication"), "c": (lbn.DROP, "restriction_notice_no_cc_note", "restriction_notice"),
|
| 234 |
+
"d": (lbn.DROP, lbn.CREATED_BEFORE, lbn.CREATED_BEFORE)}
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def test_basis_url_and_final_reason_helpers():
|
| 238 |
+
assert lbn.item_url("biblioteka_nauki_articles_12", False) == "https://bibliotekanauki.pl/articles/12"
|
| 239 |
+
assert lbn.item_url("biblioteka_nauki_books_7", True) == "https://bibliotekanauki.pl/api/books/7"
|
| 240 |
+
for bad in ("biblioteka_nauki_x_1", "biblioteka_nauki_books_a"):
|
| 241 |
+
with pytest.raises(ValueError):
|
| 242 |
+
lbn.item_url(bad, False)
|
| 243 |
+
assert lbn.basis_of({"id": "biblioteka_nauki_books_7", "note": "file_note", "added": "2026-06-27"}) == ("file_note", "https://bibliotekanauki.pl/books/7", "2026-06-27")
|
| 244 |
+
assert lbn.basis_of({"id": "biblioteka_nauki_books_7", "note": "none", "added": "2026-06-27"}) == ("depositor", "https://bibliotekanauki.pl/api/books/7", lbn.DEPOSITOR_DATE)
|
| 245 |
+
by_rule = {"printed_note": {"a": (lbn.KEEP, "discusses_licence"), "b": (lbn.KEEP, "discusses_licence")},
|
| 246 |
+
"prior_publication": {"a": (lbn.DROP, "republished_by_permission")},
|
| 247 |
+
"file_mismatch": {"b": (lbn.DROP, "file_is_another_work"), "c": (lbn.KEEP, "text_garbled")},
|
| 248 |
+
"restriction_notice": {"b": (lbn.DROP, "restriction_notice_no_cc_note")}, lbn.CREATED_BEFORE: {}}
|
| 249 |
+
final = lbn.final_reasons(by_rule)
|
| 250 |
+
assert final == {"a": (lbn.DROP, "republished_by_permission", "prior_publication"), "b": (lbn.DROP, "file_is_another_work", "file_mismatch"),
|
| 251 |
+
"c": (lbn.KEEP, "text_garbled", "file_mismatch")} # a drop beats a keep of an earlier rule; the first drop in rule order wins
|
| 252 |
+
assert lbn.review_csv(final) == "id,decision,reason\na,drop,republished_by_permission\nb,drop,file_is_another_work\nc,keep,text_garbled\n"
|
| 253 |
+
assert lbn.restriction_decision({"id": "x", "note": "file_note", "restriction": "clause"}) == (lbn.KEEP, "restriction_notice_beside_cc_note")
|
| 254 |
+
assert lbn.restriction_decision({"id": "x", "note": "none", "restriction": "arr_only"}) == (lbn.KEEP, "arr_only_no_cc_note")
|
| 255 |
+
assert lbn.restriction_decision({"id": lbn.NOT_A_NOTICE[0], "note": "none", "restriction": "clause"}) == (lbn.KEEP, "not_a_notice_on_the_work")
|
| 256 |
+
assert lbn.restriction_decision({"id": "x", "note": "none", "restriction": "clause"}) == (lbn.DROP, "restriction_notice_no_cc_note")
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
def test_committed_notes_name_no_adviser_and_no_people():
|
| 260 |
+
paths = (EVIDENCE, REVIEW, Path(lbn.__file__), DATA / "biblioteka_nauki.md", DATA / "biblioteka_nauki.license-evidence.json")
|
| 261 |
+
for path in paths:
|
| 262 |
+
assert not _PEOPLE_OR_ADVISERS.search(path.read_text(encoding="utf-8")), path.name
|
| 263 |
+
assert not _PEOPLE_OR_ADVISERS.search(json.dumps(SOURCES["biblioteka_nauki"]))
|
| 264 |
+
assert "@" not in EVIDENCE.read_text(encoding="utf-8") and "@" not in REVIEW.read_text(encoding="utf-8")
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def test_the_card_and_the_registry_say_journal_adoption_is_unknown():
|
| 268 |
+
card = " ".join((DATA / "biblioteka_nauki.md").read_text(encoding="utf-8").split())
|
| 269 |
+
assert "Journal adoption years could not be obtained" in card and "before a journal adopted Creative Commons may therefore remain" in card
|
| 270 |
+
assert "Journal adoption years could not be obtained" in SOURCES["biblioteka_nauki"]["legal_note"]
|
| 271 |
+
assert LICENSE_API.exists()
|