Download scripts/register_majma_source.py from bravesigma/quran-md-data: direct link, hf CLI and curl.
- Browser
- Download file 8.8 kB
-
https://huggingface.co/datasets/bravesigma/quran-md-data/resolve/main/scripts/register_majma_source.py
- Command line
-
hf download hf://datasets/bravesigma/quran-md-data/scripts/register_majma_source.py
-
curl -L -o register_majma_source.py https://huggingface.co/datasets/bravesigma/quran-md-data/resolve/main/scripts/register_majma_source.py
8.8 kB
| #!/usr/bin/env python3 | |
| """ | |
| Register tafsir_majma_albayan in sources/manifest.json (proposed_state | |
| use_with_notice) and append the audit addendum + permission-request draft. | |
| Idempotent: skips if the source id already present / markers already appended. | |
| """ | |
| import json | |
| from hashlib import sha256 | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| MANIFEST = ROOT / "sources" / "manifest.json" | |
| AUDIT = ROOT / "docs" / "LICENSE_AUDIT.md" | |
| REQ = ROOT / "docs" / "PERMISSION_REQUESTS.md" | |
| REPORT = ROOT / "raw" / "sources" / "tafsir_majma_albayan" / "extraction_report.json" | |
| AUDIT_MARK = "<!-- majma-addendum-2026-11-27 -->" | |
| REQ_MARK = "<!-- majma-permission-2026-11-27 -->" | |
| ENTRY = { | |
| "id": "tafsir_majma_albayan", | |
| "category": "tafsir", | |
| "traditions": ["imami"], | |
| "title_ar": "مجمع البيان في تفسير القرآن", | |
| "title_en": "Majma' al-Bayan fi Tafsir al-Quran (Tafsir al-Tabrisi)", | |
| "author": "al-Fadl ibn al-Hasan al-Tabrisi", | |
| "author_death": "548 AH / 1153 CE", | |
| "work_class": "classical", | |
| "license": { | |
| "value": "public_domain_underlying_text_transcription_hosted", | |
| "verified": "legal_analysis + site inspection 2026-11-27", | |
| "evidence_urls": [ | |
| "https://ar.lib.eshia.ir/86854", | |
| "https://ar.wikipedia.org/wiki/%D9%85%D8%AC%D9%85%D8%B9_%D8%A7%D9%84%D8%A8%D9%8A%D8%A7%D9%86", | |
| ], | |
| "summary": ( | |
| "Underlying classical text is public domain (author d. 548 AH / 1153 CE). " | |
| "Digital transcription acquired from ar.lib.eshia.ir (Maktabat Madrasat al-Fiqahah, book 86854, " | |
| "Dar al-Ma'rifa edition), a free-access Islamic digital library. Pages inspected 2026-11-27 show " | |
| "NO terms forbidding scholarly extraction, but no explicit license is granted either, so the " | |
| "modern digital transcription is taken as use_with_notice with attribution, a permission request " | |
| "(docs/PERMISSION_REQUESTS.md) and a removal pledge. The host's AI-assist features (auto-i'rab, " | |
| "translation widgets) were NOT used; only the page text itself was stored." | |
| ), | |
| }, | |
| "redistribution": { | |
| "huggingface": "allowed_with_notice", | |
| "basis": ( | |
| "Public-domain classical Arabic text as transcribed on ar.lib.eshia.ir; host credited in every " | |
| "unit's provenance and in DATASET_CARD; removal on rights-holder request." | |
| ), | |
| }, | |
| "access": { | |
| "method": "programmatic_page_fetch", | |
| "urls": [ | |
| "https://ar.lib.eshia.ir/86854/1/87", | |
| "https://ar.lib.eshia.ir/1/111", | |
| "https://ar.lib.eshia.ir/86854/4/481", | |
| "https://ar.lib.eshia.ir/86854/5/108", | |
| "https://ar.lib.eshia.ir/86854/6/486", | |
| "https://ar.lib.eshia.ir/86854/6/773", | |
| "https://ar.lib.eshia.ir/86854/9/405", | |
| ], | |
| "terms_verified": False, | |
| "rate_or_key": "0.65 s per page, UA quran-md-research/0.1, no key required", | |
| "notes": ( | |
| "Volume/page numbering of the Dar al-Ma'rifa set restarts across volumes and eshia's vol->page " | |
| "URL mapping is non-monotonic; all 289 stored pages carry their own self-label (h1) and sha256 " | |
| "(raw/sources/tafsir_majma_albayan/extraction_report.json). Substrate normalization: bidi/ZWNJ " | |
| "control chars removed, whitespace collapsed; diacritics kept verbatim. The host's surahs 17-19 " | |
| "ordering has gaps in vol 6->7 (Isra/Kahf/Maryam zone is continuous but pages of surah 19 sit at " | |
| "vol 6 pp. 773-826); spans resolved empirically by verse-quote matching against stored Tanzil text." | |
| ), | |
| }, | |
| "format": "Dar al-Ma'rifa, Beirut (digital transcription on eshia), 10 vols; 289 per-page HTML files + per-surah/per-verse text substrates", | |
| "provenance_plan": { | |
| "recorded_fields": [ | |
| "source_id", "edition", "volume", "page", "sha256", "char_offsets", "retrieval_url", "retrieval_date", | |
| ], | |
| "retrieval_url": "https://ar.lib.eshia.ir/86854", | |
| "retrieval_date": "2026-11-27", | |
| "sha256": None, | |
| }, | |
| "planned_use": [ | |
| "Imami positions side-by-side with the Sunni trio on the same ingested verses", | |
| "compare_traditions plugin output", | |
| "exegetical xref edges with citing_mufassir=tafsir_majma_albayan", | |
| ], | |
| "proposed_state": "use_with_notice", | |
| "blocking_issues": [ | |
| "eshia explicit permission pending (letter drafted in docs/PERMISSION_REQUESTS.md)", | |
| "Dar al-Ma'rifa edition footnote text is not separable in the eshia HTML; it remains in the " | |
| "substrate and is flagged per commentary unit (attribution_flags)", | |
| "citations of short ayahs (< 12 folded chars) are undetectable in plain text (same documented " | |
| "detection limit as the Sunni works)", | |
| ], | |
| } | |
| def main(): | |
| report_sha = sha256(REPORT.read_bytes()).hexdigest() | |
| ENTRY["provenance_plan"]["sha256"] = report_sha | |
| m = json.loads(MANIFEST.read_text(encoding="utf-8")) | |
| if not any(x["id"] == ENTRY["id"] for x in m["sources"]): | |
| m["sources"].append(ENTRY) | |
| MANIFEST.write_text(json.dumps(m, ensure_ascii=False, indent=1) + "\n", encoding="utf-8") | |
| print(f"manifest: {ENTRY['id']} added (total sources {len(m['sources'])})") | |
| else: | |
| print("manifest: already present") | |
| audit_add = AUDIT_MARK + """ | |
| ## Addendum 2026-11-27 — Majma' al-Bayan (Imami) acquisition | |
| - Work: Majma' al-Bayan fi Tafsir al-Qur'an, al-Fadl ibn al-Hasan al-Tabrisi (d. 548 AH / 1153 CE). The | |
| classical Arabic original is public domain by duration everywhere. | |
| - Acquisition channel: ar.lib.eshia.ir book 86854 (Dar al-Ma'rifa edition), free-access Islamic library. | |
| Site pages inspected on 2026-11-27 contain no terms forbidding scholarly extraction; no explicit | |
| license is granted. Classification: use_with_notice (same category the audit already uses for | |
| restricted-but-not-forbidden sources). Permission letter drafted; removal pledge recorded. | |
| - ar.wikisource.org was checked first (tafsir index page): it hosts ONLY Sunni works (Tabari, Ibn Kathir, | |
| Qurtubi, Jalalayn, ...) — Majma' al-Bayan and Tafsir al-Qummi are absent there. shamela.ws was not used | |
| (bulk ToS unverified, consistent with the existing Tabari/Ibn Kathir access notes). | |
| - Text integrity: per-page HTML stored with sha256 (289 pages); substrate = normalized page text | |
| (bidi/ZWNJ removed, whitespace collapsed; diacritics kept); every commentary quote must be a verbatim | |
| substring of its stored per-verse file (G2). The host's AI widgets (translation/i'rab) were not used. | |
| - Detection limits carried into unit flags: short-ayah (<12 folded chars) citations undetectable; verses | |
| whose discussion carries no directly matchable quote get merged segments flagged in attribution_flags. | |
| - Still open: Tafsir al-Qummi (d. 329 AH) — no machine-usable transcription located yet (eshia hosting | |
| status unverified); Al-Mizan remains license-blocked as before. | |
| """ | |
| if AUDIT_MARK not in AUDIT.read_text(encoding="utf-8"): | |
| AUDIT.write_text(AUDIT.read_text(encoding="utf-8") + audit_add, encoding="utf-8") | |
| print("LICENSE_AUDIT.md: addendum appended") | |
| else: | |
| print("LICENSE_AUDIT.md: already appended") | |
| req_add = REQ_MARK + """ | |
| ### ar.lib.eshia.ir (Maktabat Madrasat al-Fiqahah) — Majma' al-Bayan, Dar al-Ma'rifa edition (book 86854) | |
| To: the Madrasat al-Fiqahah library team (contact via eshia.ir) | |
| We (the quran.md project) have stored per-page Arabic text of Majma' al-Bayan fi Tafsir al-Qur'an | |
| (Tabrisi, d. 548 AH), Dar al-Ma'rifa edition, as served by your library at ar.lib.eshia.ir/86854, | |
| for a non-profit scholarly dataset whose every quote is verified verbatim against the stored substrate | |
| and attributed to your library in every record (source field `retrieval_url`). | |
| The underlying work is a public-domain classical text. We found no terms on your site forbidding such | |
| extraction, but since no explicit license is stated either, we are asking for your explicit permission | |
| to keep and redistribute this transcription within an openly licensed research dataset. We commit to | |
| remove it promptly on your request and to keep your attribution regardless. | |
| Fetch profile: 289 pages on 2026-11-27, 0.65 s between requests, generic research user-agent, no | |
| account/key bypass, no AI-derived paraphrase of your text (verbatim storage only). | |
| """ | |
| if REQ_MARK not in REQ.read_text(encoding="utf-8"): | |
| REQ.write_text(REQ.read_text(encoding="utf-8") + req_add, encoding="utf-8") | |
| print("PERMISSION_REQUESTS.md: draft appended") | |
| else: | |
| print("PERMISSION_REQUESTS.md: already appended") | |
| if __name__ == "__main__": | |
| main() | |