Repository navigation
Book scan: ranked alternatives for edit-1 findings (mirror of #34, with QA fixes) - #41
Merged
Merged
Conversation
…ng words (off by default) The edit-1 rule finds several common words one edit away from a rare word and keeps only the best by word-level score; the same suggestion is then made at every occurrence. `--alternatives N` lists, per occurrence, up to N of the candidates that rule accepted, ranked by the bigram/trigram model of the real-word check (realword.posterior) over the occurrence's neighbours, counted in the --book-verify-ctx pass without the book's own rows. The detector's first choice keeps first place unless the context prefers another candidate by MARGIN (2.0 log10 odds). With no counts, no neighbour or no candidate seen beside them, the detector's order is kept. `--alt-rerank 1` makes the finding's suggestion follow that first place. * core.edit1_scored / core.edit1_record: the edit-1 loop of evaluate_word, factored out unchanged (evaluate_word gives the same records). * magiah/alternatives.py: candidates, needs, rank, reranked. * book_scan: the alternatives' n-grams join the real-word counts of the same pass; findings get an `alternatives` field only when on. * webui: merge_book_scan puts them in the finding's `extra`, which the drawer already shows as "הצעות חלופיות" (labels for the two new `by` values); Hebrew labels for the two settings; README (en/he). * tests/test_alternatives.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # README.he.md # README.md # magiah/book_scan.py # magiah/cli.py # magiah/config.py
…s for MARGIN and detector agreement - alternatives.anchor(): rank/rerank work relative to the suggestion the finding actually carries (by string), so a candidate-list mismatch can never be reported as a context rerank; no alternatives if it is absent. reranked() tolerates empty/missing candidates. - alternatives.scores() factored out of rank() (same arithmetic). - tests/test_alt_robust.py: fuzz over synthetic library and file books (detector suggestion == first candidate, invariants of plain and rerank scans); MARGIN with real n-gram counts on both sides, for the alternatives order and the --alt-rerank suggestion; mismatch tests. - README: the 2.0 margin of --alt-rerank and its extra pair counting. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of #34 (fork PR; CodeQL does not run on forks) plus QA fixes: alternatives anchored to the finding's own suggestion, tests for the MARGIN path and detector agreement, README notes on rerank cost. Merged with main (domain gate, extra lexicon, guard); conflicts resolved by keeping both sides.
🤖 Generated with Claude Code