File size: 11,877 Bytes
e046739 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | #!/usr/bin/env python3
"""
Register the acquired state of tafsir_al_qummi in sources/manifest.json
(replace the pre-acquisition stub) and append the audit addendum +
permission-request draft.
Idempotent: markers prevent duplicate appends; manifest replacement is
in-place by source id.
"""
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_al_qummi" / "extraction_report.json"
AUDIT_MARK = "<!-- qummi-addendum-2026-11-27 -->"
REQ_MARK = "<!-- qummi-permission-2026-11-27 -->"
ENTRY = {
"id": "tafsir_al_qummi",
"category": "tafsir",
"traditions": ["imami"],
"title_ar": "تفسير القمي",
"title_en": "Tafsir al-Qummi (attributed)",
"author": "attributed to Ali ibn Ibrahim al-Qummi (d. 307/329 AH)",
"author_death": "307 or 329 AH / 919-940 CE",
"work_class": "classical",
"license": {
"value": "public_domain_underlying_text_transcription_hosted",
"verified": "legal_analysis",
"evidence_urls": [
"https://ar.lib.eshia.ir/12015",
"https://sites.dlib.nyu.edu/viewer/books/nyu_aco000157/1",
],
"summary": (
"Underlying classical text is public domain (author d. 307/329 AH; attribution is by "
"transmission — a data-quality matter handled by Phase 4 flags, not a license matter). "
"Digital transcription acquired from ar.lib.eshia.ir (Maktabat Madrasat al-Fiqahah, book "
"12015, Najaf: Maktabat al-Huda 1387 AH / 1967 edition, ed. Sayyid Tayyib al-Musawi "
"al-Jaza'iri), 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_attribution",
"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/12015/1/28",
"https://ar.lib.eshia.ir/12015/1/30",
"https://ar.lib.eshia.ir/12015/1/205",
"https://ar.lib.eshia.ir/12015/1/290",
"https://ar.lib.eshia.ir/12015/1/371",
"https://ar.lib.eshia.ir/12015/2/48",
"https://ar.lib.eshia.ir/12015/2/361",
],
"terms_verified": False,
"rate_or_key": "0.65 s per page, UA quran-md-research/0.1, no key required",
"notes": (
"Vol 1 = surahs 1-16 (content pages 3-396), vol 2 = surahs 17-114 (content pages 3-452); "
"eshia serves the edition's complete pericope TOC as out-of-range digital pages "
"(vol 1 -> p.400, vol 2 -> p.457); that TOC maps [surah(n): verse-range] -> printed page "
"and all fetch spans were derived from it (raw/sources/tafsir_al_qummi/fetch_plan.json). "
"Pages stored per page with sha256 (extraction_report.json). Substrate normalization: "
"bidi/ZWNJ control chars removed, whitespace collapsed; diacritics kept verbatim. Anchoring: "
"bracketed quotes or longest consecutive word-run under a nospace fold (the Najaf edition "
"interleaves Qummi's own word-glosses between verse phrases, so full-verse contiguity is "
"impossible by design); hamza-loose second pass and whole-word opener pass are method-flagged "
"per unit. Verses with no anchor are NOT ingested (honest gap)."
),
},
"format": ("Najaf: Maktabat al-Huda 1387 AH / 1967 (digital transcription on eshia), 2 vols; "
"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/12015",
"retrieval_date": "2026-11-27",
"sha256": None,
},
"planned_use": [
"earliest-layer Imami tafsir side-by-side with Majma' al-Bayan and the Sunni trio",
"compare_traditions plugin output",
"exegetical xref edges with citing_mufassir=tafsir_al_qummi",
],
"flags": [
"use_with_notice: host (ar.lib.eshia.ir) grants no explicit license; permission requested, "
"removal pledged (NOTICE.md 3b)",
"inline Najaf edition footnote text/markers are retained inside flagged segments "
"(attribution_flags on every unit) and never presented as al-Qummi's own words",
"attribution is by transmission (student transmission, not autograph) - data-quality note "
"carried on every unit",
],
"proposed_state": "use_with_notice",
"blocking_issues": [
"eshia explicit permission pending (letter drafted in docs/PERMISSION_REQUESTS.md)",
"Najaf edition inline footnote text/markers are not separable in the eshia HTML; they remain "
"in the substrate and are flagged per commentary unit (attribution_flags)",
"verses whose discussion carries no directly matchable anchor are not ingested; skip list "
"preserved in extraction_report.json (uncovered_verses + per-verse flags)",
"citations of short ayahs (< 12 folded chars) are undetectable in plain text (same documented "
"detection limit as the other 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"))
idx = next((i for i, x in enumerate(m["sources"]) if x["id"] == ENTRY["id"]), None)
if idx is None:
m["sources"].append(ENTRY)
print(f"manifest: {ENTRY['id']} added (total sources {len(m['sources'])})")
else:
old_state = m["sources"][idx].get("proposed_state")
m["sources"][idx] = ENTRY
print(f"manifest: {ENTRY['id']} replaced in place "
f"(proposed_state {old_state!r} -> {ENTRY['proposed_state']!r}; "
f"total sources {len(m['sources'])})")
# reconcile stored summary_counts with the new per-source states
counts = {"use": 0, "use_with_notice": 0, "exclude_until_resolved": 0, "exclude_entirely": 0}
for s in m["sources"]:
counts[s["proposed_state"]] += 1
m["summary_counts"] = {
"total_sources": len(m["sources"]),
"proposed_use": counts["use"],
"proposed_use_with_notice": counts["use_with_notice"],
"exclude_until_resolved": counts["exclude_until_resolved"],
"exclude_entirely": counts["exclude_entirely"],
"note": ("proposed_use counts plain 'use' only; 'use_with_notice' is counted "
"separately (see per-source proposed_state)"),
}
print(f"manifest: summary_counts reconciled -> use={counts['use']}, "
f"use_with_notice={counts['use_with_notice']}, "
f"exclude_until_resolved={counts['exclude_until_resolved']}, "
f"exclude_entirely={counts['exclude_entirely']}")
MANIFEST.write_text(json.dumps(m, ensure_ascii=False, indent=1) + "\n", encoding="utf-8")
audit_add = AUDIT_MARK + """
## Addendum 2026-11-27 — Tafsir al-Qummi (Imami) acquisition
- Work: Tafsir al-Qummi, attributed to Ali ibn Ibrahim al-Qummi (d. 307 AH / 919-920 CE; 329 AH per
some biographers). The classical Arabic original is public domain by duration everywhere; the
attribution is by transmission (student transmission, not autograph) — a data-quality matter already
handled by Phase 4 attribution flags, not a license matter.
- Acquisition channel: ar.lib.eshia.ir book 12015 (Najaf: Maktabat al-Huda 1387 AH / 1967, ed. Sayyid
Tayyib al-Musawi al-Jaza'iri), free-access Islamic library — the same host already classified
use_with_notice for Majma' al-Bayan (addendum above). Pages inspected 2026-11-27: no terms forbidding
scholarly extraction, no explicit license granted. Classification: use_with_notice; permission letter
drafted; removal pledge recorded.
- Resolution of the open item in the Majma' addendum above ("no machine-usable transcription located
yet"): FOUND on the same host, book 12015.
- Text integrity: per-page HTML stored with sha256; 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 method (no recall): page spans derived from the edition's own pericope TOC as served by the
host; anchoring by bracketed quote, longest consecutive word-run under a nospace fold (the Najaf text
interleaves Qummi's word-glosses between verse phrases), a hamza-loose second pass, and a whole-word
pass for muqatta'ah-class openers — all method-flagged per unit. Verses with no anchor are NOT
ingested; the skip list is preserved in raw/sources/tafsir_al_qummi/extraction_report.json.
- Coverage outcome on the 192 ingested verses: 130 anchored units (surah yields: S1 5/7, S2 34/55,
S6 17/17, S9 1/1, S14 1/1, S19 63/98, S60 9/13); 62 verses without a Qummi comment remain Sunni+Majma
only and are listed in the report (honest gap).
"""
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) — Tafsir al-Qummi, Najaf: Maktabat al-Huda 1387/1967 edition (book 12015)
To: the Madrasat al-Fiqahah library team (contact via eshia.ir) — extends the request above to a
second work hosted in the same library.
We (the quran.md project) have stored per-page Arabic text of Tafsir al-Qummi (attributed to Ali ibn
Ibrahim al-Qummi, d. 307/329 AH), Najaf: Maktabat al-Huda 1387 AH / 1967 edition, as served by your
library at ar.lib.eshia.ir/12015, 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: 63 pages on 2026-11-27 (plus the two TOC pages the host serves as out-of-range ids),
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()
|