Skip to content

[JA] Show the synonyms under their meaning when they give its number - #2839

Merged
BoboTiG merged 1 commit into
reader-dict:mainfrom
monosans:feat/ja-synonyms
Nov 12, 2026
Merged

BoboTiG merged 1 commit into
reader-dict:mainfrom
monosans:feat/ja-synonyms

Conversation

@monosans

Copy link
Copy Markdown
Contributor

Following your note on #2815 about ふうん and 年生.

Many JA synonym lists give the number of the meaning they belong to, but they were rendered as a separate list. Three layouts are common:

  • inline: *語義1:[[ふむ]]、[[なるほど]], *(語義1)[[退職]], * {{sense|語義1}} ...
  • a 語義1 line (or ;語義1, (語義1), 語義1:) above the bullets that belong to it
  • at the end: *[[気楽]](語義1、語義2)

attach_synonyms() in the JA module reads these and puts the synonyms of each meaning under it as one sub-definition, after its examples:

1. 何かを理解しようとしていること…
   a. 類義語: ふむ、なるほど
2. やや冷淡な反応…
   a. 類義語: あっそ

The meanings are the # items of the section the synonyms belong to. A list stays as it is when one of its lines has no number, or a number the meanings don't have, so a list without numbers is not touched.

Testing

  • JA dump 20261101, parsed with python -m wikidict ja --parse, Python 3.13.18 in python:3.13-slim on Windows 11.
  • I ran parse_word() on all 8,247 pages that contain "語義", with main and with this branch. 458 pages now have their synonyms under their meanings, none loses a meaning, and pages with a separate synonyms list go from 888 to 450 (the rest have no numbers).
  • tests/test_ja.py and the JA doctests pass (the new function has doctests for each layout and for the lists left alone), and ruff and mypy are clean.

The synonyms of a JA entry often give the number of their meaning: "*語義1:[[ふむ]]",
a "語義1" line above a list, or "*[[気楽]](語義1、語義2)". Those are now put
under their meaning as a sub-definition, and the list stays as it is when a line
can't be matched.
@BoboTiG
BoboTiG merged commit 98e1252 into reader-dict:main Nov 12, 2026
1 check passed
@BoboTiG

BoboTiG commented Nov 12, 2026

Copy link
Copy Markdown
Member

Awesome!

@monosans
monosans deleted the feat/ja-synonyms branch November 12, 2026 19:45
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.

2 participants