feat(web): enrich word responses with members, hypernym path, and similar/also links [SIGN-676] - #4
Conversation
…ilar/also links
The dictionary word page wants to render per-sense synonyms, a hypernym
breadcrumb, and see-also links without fetching each synset's full
relationship graph. Each included synset in a word response now carries:
- members: all lemmas of the synset (synonyms)
- hypernyms: first hypernym path, root -> immediate parent, as {id, lemma}
- related: {similar, also} -> [{id, lemma}] (omitted when empty)
Additive only — existing consumers are unaffected. [SIGN-676]
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe ChangesSynset enrichment
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant WebEndpoint
participant make_word
participant Synset
WebEndpoint->>make_word: build word response for form
make_word->>Synset: read members and hypernym paths
Synset-->>make_word: return enrichment data
make_word->>Synset: read similar and also relations
Synset-->>make_word: return related synset links
make_word-->>WebEndpoint: return included enriched synset
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
…ookup
Simplification pass on the enrichment:
- hypernyms/see_also are flat lemma lists — the {id, lemma} objects and
relation-name keys were payload the dictionary never read
- one hypernym path computed lazily via relation_paths (hypernym_paths()
enumerates every path; polysemous nouns have dozens)
- first-lemma lookup is 3 queries instead of lemmas()' 1+2n
- path truncated server-side to the 4 nearest ancestors — the breadcrumb
renders exactly that, and taxonomy roots stop repeating in every cached
response
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 24482f5. Configure here.
| if (lemma := _first_lemma(rss)) | ||
| )) | ||
| if see_also: | ||
| attrs['see_also'] = see_also |
There was a problem hiding this comment.
Enrichment omits synset link IDs
Medium Severity
hypernyms and see_also emit bare lemma strings, but this PR’s contract specifies [{id, lemma}] objects (and a related map keyed by similar/also) so the word page can link to the exact synset. Lemma-only values are ambiguous for polysemous words, so breadcrumb and see-also links cannot target the intended sense.
Reviewed by Cursor Bugbot for commit 24482f5. Configure here.


Why
The Rylo dictionary word page (rylo-apps SIGN-676 follow-up to SIGN-615) wants to render per-sense synonyms, a hypernym breadcrumb (e.g. information → example → sample → random sample), and see-also links. Today that data requires a follow-up request per synset (the "Show relationships" modal's N+1 pattern); the word page needs it inline.
What
Each included synset in a word response (
/lexicons/{lex}/words?form=Xand/words) now carries three extra attributes:members— all lemmas of the synset (synonyms, always present)hypernyms— first hypernym path ordered root → immediate parent, as[{id, lemma}](omitted when the synset has no hypernyms)related—{similar?, also?}→[{id, lemma}], one representative lemma per related synset (omitted when empty)Additive only; existing consumers are unaffected. Responses stay cacheable — no new query params.
Checks
hatch fmt --linter --check✅hatch run mypy:check✅hatch build✅hatch test✅ (143 passed, incl. newtest_words_included_synset_enrichment)🤖 Generated with Claude Code
Note
Medium Risk
Additive JSON only, but full word responses do more synset relation and lemma work per request, which can affect latency on list endpoints that paginate through
make_word.Overview
Word lookup responses (
/lexicons/{lex}/words,/words, and single-word routes using fullmake_word) now attach extra fields on each included synset so clients can render synonyms, hypernym breadcrumbs, and “see also” without per-synset follow-ups.On those included synsets,
make_wordaddsmembers(all lemmas viass.lemmas()),hypernyms(up to four lemmas from the firsthypernym/instance_hypernympath, ordered root → immediate parent, omitted when empty), andsee_also(deduped first lemmas fromsimilar/alsorelations). A_first_lemmahelper limits extra lookups for hypernym and related labels.Release v1.5.0 is documented in
CHANGELOG.md;test_words_included_synset_enrichmentlocks in member lists, hypernym ordering, and absence ofsee_alsowhen the fixture has no similar/also links.Reviewed by Cursor Bugbot for commit 24482f5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Tests