Skip to content

feat(web): enrich word responses with members, hypernym path, and similar/also links [SIGN-676] - #4

Merged
AmitMY merged 3 commits into
mainfrom
sign-676-enrich-word-endpoint
Jul 16, 2026
Merged

feat(web): enrich word responses with members, hypernym path, and similar/also links [SIGN-676]#4
AmitMY merged 3 commits into
mainfrom
sign-676-enrich-word-endpoint

Conversation

@AmitMY

@AmitMY AmitMY commented Jul 16, 2026

Copy link
Copy Markdown

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=X and /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. new test_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 full make_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_word adds members (all lemmas via ss.lemmas()), hypernyms (up to four lemmas from the first hypernym / instance_hypernym path, ordered root → immediate parent, omitted when empty), and see_also (deduped first lemmas from similar / also relations). A _first_lemma helper limits extra lookups for hypernym and related labels.

Release v1.5.0 is documented in CHANGELOG.md; test_words_included_synset_enrichment locks in member lists, hypernym ordering, and absence of see_also when 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

    • Word lookup responses now include richer synset information, including member lemmas, hypernym breadcrumbs, and related synsets.
    • Related “similar” and “also” synsets are provided with their identifiers and primary lemmas.
    • Synset enrichment is available through the words endpoint while preserving existing result details.
  • Tests

    • Added coverage verifying enriched synset attributes, member lists, and hypernym ordering.

…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>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The /lexicons/{lexicon}/words response now enriches included synsets with members, ordered hypernyms, and inline similar/also relations. A new web test verifies these attributes for multiple form queries.

Changes

Synset enrichment

Layer / File(s) Summary
Synset link and inline relation contract
wn/web.py
Adds compact {id, lemma} synset links and defines the similar and also relations embedded in word responses.
Word response enrichment and validation
wn/web.py, tests/web_test.py
make_word() adds members, reversed first-path hypernyms, and related synset links; tests verify the enriched response contents and ordering.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enriching web word responses with members, hypernyms, and related synset links.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sign-676-enrich-word-endpoint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

AmitMY and others added 2 commits July 16, 2026 10:07
…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>
@AmitMY
AmitMY merged commit 772fd8a into main Jul 16, 2026
13 checks passed
@AmitMY
AmitMY deleted the sign-676-enrich-word-endpoint branch July 16, 2026 07:10

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread wn/web.py
if (lemma := _first_lemma(rss))
))
if see_also:
attrs['see_also'] = see_also

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 24482f5. Configure here.

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