From 95b600ebdd729018a8ef61ff76bd460e40ef11d5 Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Thu, 20 Aug 2026 08:02:20 -0700 Subject: [PATCH] docs(search): correct the recall claim in the pattern normalizer The docstring said a shorter prefix "only widens recall". That holds for a stem that truncates, not for one that substitutes: English y -> i moves the pattern sideways, so "copy*" gains "copies" and loses "copyright". Stating it as a general invariant is what hid that class in the first place. Length stays the rule; only its justification is corrected. No behavior change -- no executable line is touched. Co-Authored-By: Claude Opus 5 --- src/documents/search/_registry.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/documents/search/_registry.py b/src/documents/search/_registry.py index da6a6e678..9877781ba 100644 --- a/src/documents/search/_registry.py +++ b/src/documents/search/_registry.py @@ -34,8 +34,12 @@ def _make_pattern_normalizer(language: str | None) -> Callable[[str], str]: therefore stemmed here too. A stem can be longer than the fragment the user typed, though, and a - longer prefix matches nothing while a shorter one only widens recall, - so the stem is used only when it is no longer than the typed run. + longer prefix matches nothing, so the stem is used only when it is no + longer than the typed run. Length is a proxy for "the stem stayed close + to what was typed", not a guarantee of wider recall: a stem that + substitutes rather than truncates ("copy" -> "copi") moves the pattern + sideways instead of widening it, so "copy*" gains "copies" and loses + "copyright". test_pattern_stemming.py pins that trade. """ folded = ascii_fold(text.lower()) stemmed = stem_pattern_text(folded, language)