#!/usr/bin/env python3 """Compare the Great Isaiah Scroll (1QIsa-a) with the Leningrad Codex, word by word. Jesus Saves Cities, November 2026. Write-up: https://jesussavescities.com/read/great-isaiah-scroll-copying-test/ Standard library only. This script downloads nothing. Get the data yourself: 1. Dead Sea Scrolls (Abegg, Bowley and Cook; ETCBC Text-Fabric edition, CC BY-NC 4.0). From https://github.com/ETCBC/dss/tree/master/tf/2.0.5 put these files in one folder: otype oslots scroll book chapter verse glyph type rec rem after (each ending in .tf) 2. Leningrad Codex, Isaiah (Westminster Leningrad Codex, public domain, via OSHB): https://github.com/openscriptures/morphhb/blob/master/wlc/Isa.xml Run: python3 isaiah-scroll-diff.py [scroll ...] Scroll names in the data: 1Qisaa (Great Isaiah Scroll), 1Q8 (1QIsa-b). What it does: - Rebuilds each scroll's written words verse by verse. Letters a scribe erased are dropped; letters added above the line are kept. Words that modern editors reconstructed in a damaged spot are left out. - Takes the consonants of the Leningrad Codex as written (ketiv), without vowel points. - Treats final letter forms as ordinary letters. - Aligns each scroll verse with the same Leningrad verse (Python difflib) and counts scroll words that line up with an identical word. - "Normalized" also ignores spelling: the letters waw and yod after the first letter (mostly vowel letters), and a few standard long spellings (ki'/ki, lo'/lo, hu'ah/hu, hi'ah/hi, -kah/-k, -tah/-t, -hemah/-hem, -kemah/-kem). """ import re import sys import difflib from collections import defaultdict FINALS = str.maketrans("ךםןףץ", "כמנפצ") def letters(s): return re.sub("[^א-ת]", "", s).translate(FINALS) def normalize(w): w = {"כיא": "כי", "מיא": "מי", "לוא": "לא", "הואה": "הוא", "היאה": "היא"}.get(w, w) if w: w = w[0] + re.sub("[וי]", "", w[1:]) w = re.sub("כה$", "כ", w) w = re.sub("תה$", "ת", w) w = re.sub("(?<=[הכ])מה$", "מ", w) return w def expand(spec): out = [] for part in spec.split(","): if "-" in part: a, b = part.split("-") out.extend(range(int(a), int(b) + 1)) else: out.append(int(part)) return out def load_tf(path): """Minimal reader for Text-Fabric node and edge features.""" data, prev, body = {}, 0, False with open(path, encoding="utf-8") as f: for line in f: line = line.rstrip("\n") if not body: body = line == "" continue parts = line.split("\t") nodes = expand(parts[0]) if len(parts) == 2 else [prev + 1] for n in nodes: data[n] = parts[-1] prev = nodes[-1] return data def node_range(otype, name): for n, v in otype.items(): if v == name: yield n def scroll_words(tf, name): feat = {f: load_tf(f"{tf}/{f}.tf") for f in ("otype", "scroll", "book", "chapter", "verse", "glyph", "type", "rec", "rem", "after")} oslots = load_tf(f"{tf}/oslots.tf") scroll_nodes = [n for n, v in feat["scroll"].items() if v == name and feat["otype"].get(n) == "scroll"] if not scroll_nodes: sys.exit(f"scroll {name} not found") s = expand(oslots[scroll_nodes[0]]) lo, hi = min(s), max(s) verses, cur = defaultdict(list), None for w in (n for n, v in feat["otype"].items() if v == "word"): if w not in oslots: continue sl = expand(oslots[w]) if not lo <= sl[0] <= hi or feat["book"].get(w) != "Is": continue try: key = (int(feat["chapter"][w]), int(feat["verse"][w])) except (KeyError, ValueError): continue cons = [x for x in sl if feat["type"].get(x) == "cons" and not feat["rem"].get(x)] if cur is None or cur["key"] != key: cur = {"key": key, "text": "", "rec": False} verses[key].append(cur) cur["text"] += "".join(feat["glyph"].get(x, "") for x in cons) cur["rec"] |= any(feat["rec"].get(x) for x in cons) if feat["after"].get(w, "") in (" ", "\xa0"): cur = None return {k: [letters(x["text"]) for x in v if letters(x["text"]) and not x["rec"]] for k, v in verses.items()} def leningrad(path): xml = open(path, encoding="utf-8").read() xml = re.sub(r"]*>.*?", "", xml, flags=re.S) # drop qere, keep ketiv out = {} for m in re.finditer(r'(.*?)', xml, re.S): words = [letters(x) for x in re.findall(r"]*>(.*?)", m.group(3))] out[(int(m.group(1)), int(m.group(2)))] = [x for x in words if x] return out def compare(scroll, mt): totals = {"exact": [0, 0], "normalized": [0, 0]} verses = 0 for key, words in scroll.items(): if not words or key not in mt: continue verses += 1 for label, f in (("exact", lambda w: w), ("normalized", normalize)): a = [f(w) for w in mt[key]] b = [f(w) for w in words] sm = difflib.SequenceMatcher(None, a, b, autojunk=False) totals[label][0] += sum(x.size for x in sm.get_matching_blocks()) totals[label][1] += len(b) return verses, totals def main(): if len(sys.argv) < 3: sys.exit(__doc__) tf, isa = sys.argv[1], sys.argv[2] names = sys.argv[3:] or ["1Qisaa", "1Q8"] mt = leningrad(isa) print(f"Leningrad Codex, Isaiah: {len(mt)} verses, {sum(map(len, mt.values()))} words") for name in names: verses, t = compare(scroll_words(tf, name), mt) e, n = t["exact"], t["normalized"] print(f"{name}: {verses} verses, {e[1]} preserved words; " f"identical letter for letter {100 * e[0] / e[1]:.1f}%, " f"identical ignoring spelling {100 * n[0] / n[1]:.1f}%") if __name__ == "__main__": main()