Add the pure query core for the analysis catalog - #211
Add the pure query core for the analysis catalog#211alex-rawlings-yyc wants to merge 15 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds a pure analysis catalog query core, search folding, row construction, facets, filters, sorting, and a memoized Redux selector. It also adds tests for catalog behavior, normalization, query operations, and selector memoization. ChangesAnalysis catalog
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AnalysisState
participant selectCatalogRows
participant buildCatalogRows
AnalysisState->>selectCatalogRows: token analyses, links, language, current book
selectCatalogRows->>buildCatalogRows: catalog scope
buildCatalogRows-->>selectCatalogRows: catalog rows
selectCatalogRows-->>AnalysisState: memoized row collection
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
alex-rawlings-yyc
left a comment
There was a problem hiding this comment.
@alex-rawlings-yyc resolved 2 discussions.
Reviewable status: 0 of 7 files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).
Row derivation, search fold, and facets, memoized as selectCatalogRows. Row building and query application are separate functions so searching and sorting never rebuild rows; the search fold stays apart from normalizeSurfaceForm, since folding a diacritic into identity would silently merge distinct analyses.
Adds pos, confidence, and feature filters, treats an empty selection as inactive, and orders the confidence facet by strength. The search query is trimmed in applyCatalogQuery, not in foldForSearch, whose output separates the row fields a match must not span.
Compatibility normalization covers the shapes Unicode encodes as variants; Greek and Hebrew final letters, which it encodes as distinct letters, are mapped.
Ties fell through to payload creation order, so a draft of mostly one-usage rows was ordered by when each analysis happened to be recorded; they now fall back to form, then gloss.
The analyses and links these fixtures build gained required createdAt / updatedAt, so each now spreads FIXTURE_STAMPS. Also drops two fixture counts from the doc comments, which nothing kept in sync.
35e2980 to
7e0162a
Compare
Absence now lists as undefined after a field's values, so a field one analysis is tagged with still raises a dropdown, and a search for what an analysis lacks is possible. Also folds a pasted Windows line ending in a catalog search.
Usage counts match the suggestion pool's frequency only while a token carries at most one approved link, and a single-book draft is offered no books facet even when unused rows sit alongside the used ones.
Closes #192.
The pure derivation layer for the Analysis Catalog (#186) — no React, no store, no PAPI, no UI.
Modules
src/utils/search-fold.ts—foldForSearch(NFD → strip\p{Mn}→ NFC → lowercase), kept deliberately apart fromnormalizeSurfaceForm.src/utils/analysis-query.ts—buildCatalogRows,applyCatalogQuery,deriveFacets.src/store/analysisSlice.ts—selectCatalogRows(state, currentBook), memoized on the two token-level arrays plus the analysis language and book.Three divergences from the issue, agreed before implementing
buildCatalogRows(analysis, query)but also requires search/sort/filter to run outside the memoized build — those conflict. Shipped asbuildCatalogRows(analysis, scope)+applyCatalogQuery(rows, query).buildCatalogRowstakesPick<TextAnalysis, 'tokenAnalyses' | 'tokenAnalysisLinks'>so the selector memoizes on those arrays rather than the wholeTextAnalysis.CatalogRowcarriespos/features/confidence. The row shape in Analysis catalog: pure query core (analysis-query.ts, search fold, memoized selector) #192 has none of them, soderiveFacets(rows)could not derive the facets it is asked to.statusand lexicon refs are deliberately not facets: status is constant by construction (only approved links count as usages) and lexicon-ref presence is a boolean, not a value list.analysisLanguagesin the query.searchTextfolds every gloss value present, so a gloss in a language the project no longer declares stays findable.#192 and #186's row model should be amended before #193 starts, since #193 consumes these exports.
Not in the issue, but the data requires it
USJ verse SIDs are verbatim, so a bridged verse arrives as
"GEN 1:3-4:0"andNumber('3-4')isNaN. Usage parsing goes through the existingfirstVerseNumber; there is a test for it.Testing
31 new tests covering all 25 behaviors listed in #192. Full suite 1681 passing, 100% coverage, lint clean.
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
New Features
Tests