Add typo check with undo

The summary now has a Spelling line: "no typos found" or each fix listed by
slide ("fixed "OBEDIANCE" -> "OBEDIENCE""), with r to undo all or some.

- Uses macOS's own spelling checker and autocorrect via JXA, so it runs
  offline with nothing installed; ALL-CAPS emphasis words are checked too,
  and doubled small words ("the the") are removed
- Never changes names it doesn't know, Greek/Hebrew sermon words, or Bible
  compounds it would split (lampstand, firstfruits)
- An undone word goes into allowed-words.txt and is never changed again;
  undo re-runs the check from the text as it was before the fixes
- Tests: planted typos are fixed, all 18 real notes files are unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 12:37:18 -04:00
co-authored by Claude Opus 5.5
parent 7122fd144d
commit 153ca3263d
5 changed files with 526 additions and 3 deletions
+16
View File
@@ -96,6 +96,22 @@ def main():
check("only shared references reused (%d)" % len(shared), all(
x.decode() in open(SERIES, "rb").read().decode("latin-1") for x in shared) and len(shared) <= 12)
# 6. typo check (macOS's spelling checker, so this needs a Mac): planted typos are fixed,
# real notes are left alone
import spelling
try:
p = notes.parse(open(os.path.join(HERE, "typos", "Slides - Typo Test - Part 7.rtf"), "rb").read())
rep = spelling.check_and_fix(p, skip=set())
got = sorted((f.word, f.new) for f in rep.fixes)
want = sorted([("teh", "the"), ("the the", "the"), ("OBEDIANCE", "OBEDIENCE"), ("beleived", "believed")])
check("typos: planted typos fixed", got == want, "got %s" % got)
for f in sorted(os.listdir(NOTES)):
p = notes.parse(open(os.path.join(NOTES, f), "rb").read())
rep = spelling.check_and_fix(p)
check("typos: nothing changed in %s" % f, not rep.fixes, ", ".join("%s->%s" % (x.word, x.new) for x in rep.fixes))
except spelling.Unavailable as e:
print("skip typo checks (%s)" % e)
print()
print("FAILED: %s" % failures if failures else "all checks passed")
return 1 if failures else 0