feat(spellcheck): spelling marks on the handwriting (#53 part 2) #59
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/53-ink-marks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #53 (part 2: spelling marks on the handwriting). Based on
main(#58 is merged).Per
reports/53-ink-build-plan.md:test/support/fixtures/files/rmscene/.Remarkable.Lines.WordBoxes): a page's strokes grouped into lines and words (i-dots and crossbars join their word, strikethroughs and heading underlines are rules that never weld words, the widest gaps are word breaks). Armstrong's audit F6/F7 fixed in60db9e8.Spellcheck.InkMarks): the transcription'sWords.tokenslined up with the boxes in order; falls back (no marks, with a reason) on no ink, typed text, a drawing, a word count the ink can't make, unclear gaps (margin < 1.5) or uneven word widths. Hits on struck/illegible/unsure words and list markers are never marked. Logs each page's outcome with rm_hash, transcription id, numbers and ms.Spellcheck.InkCheck): runs the gate on current handwritten transcriptions and prints each page's outcome and gap margin, the pass rate, the reasons and the margins' spread (read-only, no checker). From a checkout:mix spellcheck.ink_check [--user EMAIL] [--limit 50]; from a release:RmAnalyzer.Release.ink_check/1(see Open).docs/spellcheck.md, "On the handwriting".Nothing is written to the tablet. No new deps.
Checked:
mix precommit, 1002 tests pass (8bcce00). In Chromium on the mock app (scripts/screenshots) against a real LanguageTool, at 1280 and 390x844: on "Team meetings" p. 1 with "serch" and "notse" in the transcription, exactly those two words get marks (gate margin 2.01, 3 ms). On p. 3, whose drawn box around two lines isn't words, it falls back ("gaps aren't clear enough", margin 1.27) and marks only the text.Open:
OCR prompt v2 keeps the page's line breaks (
d76ad72): one transcription line per handwritten line, so each ink line pins its own words. Markdown still renders it as one paragraph, and search, highlights and snippets read it the same way (wrapped phrases,ket-/tleandself-/awareline-end hyphens). Existing pages gain marks only after they're re-transcribed: v2 marks older AI transcriptions outdated, and re-running them stays the user's call. Migration20261028190000moves the transcription trigram index onto the rejoined-text expression (runs on app start).Line margin is 1.3 (
1a1b03c) so tightly spaced lines on real pages can be sure; word fit stays 0.6 (0.7 put words on the wrong box).Gate margin 1.5 stays (Armstrong's audit at
bde600b: no findings). rmscene's cursive multi-line sample scores 1.34 and gets no marks; that's now a test inink_marks_test.exs. Retune on real notebooks (plan step 6).Real-notebook pass rate needs Jeremy's data. It's read-only (SELECTs and blob reads only) and runs beside the app. On a running release (the Docker image built from this branch):
If the deployed app is still on main, the function isn't in it yet: run a one-off container of this branch's image against the same database and blob volume instead, e.g.
docker run --rm --network host -e DATABASE_URL=... -e ENCRYPTION_KEY=... -e SECRET_KEY_BASE=... -e OIDC_ISSUER=... -e OIDC_CLIENT_ID=... -e OIDC_CLIENT_SECRET=... -v BLOBS:/data/remarkable/blobs:ro rm-analyzer:ink-marks /app/bin/rm_analyzer eval 'RmAnalyzer.Release.ink_check(limit: 200)'(runtime.exs wants the same env as the app).Tried that way on the mock notebooks (
scripts/screenshotsdatabase, blobs mounted read-only): 24 pages, 11 line up (46%), 12ambiguous_gaps, 1uneven_widths; margins min 1.02, median 1.50, max 8.30. The mock pages are synthetic, so this says nothing yet about real handwriting.Real handwriting (
c116515)Jeremy's real page fell back with
count_mismatch. Slant, descender loops and t-bars make neighbouring words' boxes overlap in x, so words merge and there are too few gaps, or the gaps that are left fall inside words. When the plain box split runs short or isn't clear,WordBoxesnow splits again: it shears out the measured slant, lets only words' own strokes make segments (dots and crossbars join the one they sit over), and as a second try measures strokes across the middle of the line only. The same gate applies (margin 1.5, word widths). A re-split with no gap left inside words is never used.count_mismatchis nowtoo_many_lines/too_few_gaps(panel + log, which also gives gaps and split).ink_checkprints the split per page.test/support/fixtures/handwriting_fixtures.ex), every word on its own ink.Color_and_toolnow lines up deslanted (1.86) with the same 7 boxes.8bcce0078ff6cc6f035aJoined paragraphs leave most ink lines with no line break to hold their words in place, so a word off on one line unpins its neighbours and the ink marks fall back. One transcription line per handwritten line still renders as one Markdown paragraph. Version 2 marks earlier AI transcriptions outdated; re-running them stays the user's call. Search reads those lines as Markdown does, so line-broken pages search as well as joined ones: a quoted phrase matches with any whitespace between its words (a regex the trigram index still serves), its highlight crosses the break, and snippets join a paragraph's lines with a space, keeping " · " for blank lines, headings, list items and quotes. The opened page marks a wrapped phrase too: SearchHighlight (and the PDF page's marks) match each term as its escaped words joined by \s+, the same pattern Search.phrase_regex builds. A word hyphenated at a line end ("ket-" then "tle") is searched, marked and shown whole: a hyphen ending a line between lowercase letters is dropped, in plain_text and in the database, where the trigram index moves onto that same expression. A compound broken at its own hyphen ("self-" then "aware") is still found by "self-aware": the term's hyphen is optional in the database, and a search for it keeps the hyphen in the snippet and marks it on the page. Refs #53