Normalize component search tokens for better matching#2424
Conversation
🎩 PreviewA preview build has been created at: |
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
- splitIdentifierText: anchor first capital group to a single char to remove O(n²) regex backtracking on long uppercase runs (behavior-preserving) - stemToken: guard -is/-us endings so status/analysis/axis aren't over-stemmed Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🤖 Code review — Normalize component search tokens for better matchingSolid normalization layer: Two things worth weighing:
Nit: the hand-rolled stemmer is intentionally approximate and produces some odd stems ( |

Description
Improves the component search index by normalizing indexed and query text beyond simple lowercasing. Specifically:
snake_case,kebab-case, andcamelCasecomponent names are split into individual words before indexing, so a query like"train model"matches a component namedtrain-modelortrain_model, and"load csv file"matchesloadCSVFile.stemTokenfunction reduces common English inflections (plurals via-s/-ies, gerunds via-ing, past tense via-ed, sibilant plurals) to their base forms. Both the original token and its stem are stored in the index, so queries like"training","datasets", or"batch"match components described with"train","dataset", or"batches".normalizeSearchTextpipeline is applied to query text before scoring, ensuring query tokens and indexed tokens are in the same form.Related Issue and Pull requests
Type of Change
Checklist
Screenshots (if applicable)
Test Instructions
componentSearchIndex.test.ts) to verify the new normalization cases pass:training,datasets,batch) matching indexed descriptions.Additional Comments
The stemmer is intentionally minimal — it handles the most common English suffixes without introducing a full NLP dependency. Both the raw token and its stem are stored so that exact matches are never lost.