Skip to content

feat: harvest meaningful search categories for autocomplete - #3570

Open
EliezerIsrael wants to merge 2 commits into
masterfrom
feat/autospell-search-categories
Open

feat: harvest meaningful search categories for autocomplete#3570
EliezerIsrael wants to merge 2 commits into
masterfrom
feat/autospell-search-categories

Conversation

@EliezerIsrael

Copy link
Copy Markdown
Member

Replace AutoCompleter._get_main_categories with _get_search_categories, which builds the category feed for autocomplete from the TOC tree.

  • Keep the base-text browse taxonomy (categories with >= 2 children), recursing to full depth instead of stopping at two levels.
  • At commentary/era/"Other" boundaries ("Commentary", "Rishonim on X", "Acharonim", "Modern", "Other ... Works", "Targum", "Guides"): drop the boundary node but harvest the good names one level below it (Rashi, Ramban, Kessef Mishneh, ...), without descending into their repeated per-book structure.

This removes the tens of duplicated commentary sub-trees (e.g. a full "Mishneh Torah" structure repeated under each of its commentators) while surfacing the commentator/author names that are valuable as search terms.

Description

A brief description of the PR

Code Changes

The following changes were made to the files below

Notes

Any additional notes go here

Replace AutoCompleter._get_main_categories with _get_search_categories,
which builds the category feed for autocomplete from the TOC tree.

- Keep the base-text browse taxonomy (categories with >= 2 children),
  recursing to full depth instead of stopping at two levels.
- At commentary/era/"Other" boundaries ("Commentary", "Rishonim on X",
  "Acharonim", "Modern", "Other ... Works", "Targum", "Guides"): drop the
  boundary node but harvest the good names one level below it (Rashi,
  Ramban, Kessef Mishneh, ...), without descending into their repeated
  per-book structure.

This removes the tens of duplicated commentary sub-trees (e.g. a full
"Mishneh Torah" structure repeated under each of its commentators) while
surfacing the commentator/author names that are valuable as search terms.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gitvelocity-reviewer

Copy link
Copy Markdown

📊 Code Quality Score: 7/100

29 × 0.25 = 7.25, rounded to 7

Category Score Factors
🔭 Scope 5/20 Single file, single subsystem (autocomplete), localized change to one method and module-level constants
🏗️ Architecture 6/20 Replaces hardcoded 2-level loop with recursive walk; introduces boundary abstraction (constants + helper function); imports TocCategory for isinstance checks
⚙️ Implementation 8/20 Recursive tree traversal with closure mutation, regex + set boundary detection, meaningful behavior change from flat to recursive walk, isinstance guards
⚠️ Risk 7/20 Silently changes which categories appear in autocomplete search results; no feature flag; potential over-matching with 'other' keyword; unbounded recursion; no rollback mechanism
✅ Quality 2/15 Good docstring on _get_search_categories; is_category_boundary is well-factored; no tests added for new logic or regression coverage
🔒 Perf / Security 1/5 No recursion depth guard; otherwise low performance/security risk for this use case

Was this score accurate? 👍 Yes · 👎 No

Scored by GitVelocity · How are scores calculated?

`cats += [...]` inside the nested walk() rebinds `cats` as a local of
walk (augmented assignment), causing UnboundLocalError. Use list.append,
which mutates the enclosing list in place.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant