Skip to content

[RU][UK] Show the synonyms under their meaning - #2815

Merged
BoboTiG merged 1 commit into
reader-dict:mainfrom
monosans:ru-synonyms-under-meanings
Nov 5, 2026
Merged

BoboTiG merged 1 commit into
reader-dict:mainfrom
monosans:ru-synonyms-under-meanings

Conversation

@monosans

@monosans monosans commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

In the RU and UK Wiktionaries, the "Синонимы"/"Синоніми" section has one line per meaning, in the same order, with an empty line (or "-") for a meaning without synonyms. wikidict renders it as a separate numbered list and drops the empty lines and repeated synonyms, so the numbers stop matching the meanings. On the 20261101 dumps this happens in about 7,000 RU lists and 177 UK ones. For example:

  • "коса": "триммер, газонокосилка" was number 1, next to the hairstyle, instead of meaning 4 ("то же, что триммер");
  • "бита": "отвёртка-вставка" was number 1, next to the bat, instead of meaning 2;
  • "страница": "лист" was number 2 instead of 3.

Now utils.attach_synonyms() puts each synonym line under its meaning as a sub-definition, and drops the section:

4. то же, что триммер
   a. син.: триммер, газонокосилка?

Details:

  • Sub-definitions are rendered one by one, so a broken synonym (some pages transclude a template that doesn't exist) drops only itself and keeps its meaning.
  • The list stays as it is when it can't be matched with the meanings: more synonyms than meanings, a synonym for an empty meaning, lines that aren't # items, or unbalanced brackets. That's about 620 RU entries.
  • When a homonym has no meaning of its own, its synonyms are dropped. About 240 RU pages are only a form of another word plus a few synonyms, like "перекроенный" ({{прич.|перекроить}}). The synonyms made them words of their own, so their forms ("перекроенных") showed a lone synonyms list instead of leading to "перекроить".
  • The function takes the section titles and the label as parameters, so another Wiktionary with the same layout can use it. BG writes one list for the whole word, so it doesn't apply there.

I built the whole RU dictionary with this change and compared it with a build without synonyms: no word, form or definition is missing, and about 127,800 entries now show synonyms under their meanings.

Doctests cover each case, and the RU and UK tests now expect the synonyms under their meanings. The RU/UK/BG tests, doctests, ruff and mypy pass locally.

@BoboTiG

BoboTiG commented Nov 5, 2026

Copy link
Copy Markdown
Member

Instead of appending, we could add use a sublist so that converters will display properly a subitem for the main definitions, WDYT?

And I am also thinking if that would be cool to generalize the process to all locales 🤔

@monosans
monosans force-pushed the ru-synonyms-under-meanings branch from 5e2144f to a423892 Compare November 5, 2026 16:46
@monosans monosans changed the title [RU] Show the synonyms under their meaning [RU][UK] Show the synonyms under their meaning Nov 5, 2026
@monosans

monosans commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Good idea, done: each synonym line is now a sub-definition of its meaning (## ''син.:'' …), so every converter shows it like any other sub-item. That also removed the marker and the change in render.py: sub-definitions are already rendered one by one, so a broken synonym still drops only itself.

For other locales, I moved the code to utils.attach_synonyms(), with the section titles and the label as parameters, and enabled it for UK too. It has the same layout, and 177 of its lists were misnumbered. It only fits Wiktionaries that write one synonyms line per meaning, in the same order. BG writes a single list for the whole word, so it doesn't apply there. Some others put the meaning number in front of each synonym, like [1] in DE or (1.1) in PL. Those would need a different matching, so I'd rather look at them in separate PRs, if you want them.

I rebuilt the whole RU dictionary with this version and compared it with a build without synonyms: no word, form or definition is missing.

@BoboTiG
BoboTiG merged commit 3eb3632 into reader-dict:main Nov 5, 2026
1 check passed
@monosans
monosans deleted the ru-synonyms-under-meanings branch November 6, 2026 20:26
@BoboTiG

BoboTiG commented Nov 9, 2026

Copy link
Copy Markdown
Member

For other locales, (...). Those would need a different matching, so I'd rather look at them in separate PRs, if you want them.

If you are still willing to handle other locales, I'm 100% OK :)

@monosans

monosans commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Sure, here are the first two:

I looked at the other locales too. PT mostly writes one list for the whole word, and only a few thousand lines use "De '''1''':", so I left it out for now. PL also numbers its synonyms with (1.1), but its definitions are read with a pattern that doesn't render sub-items, so it would first need a change in how PL definitions are read. FR, EL, LT, DA, JA, MG and most others write a single bulleted list per word, with nothing to match. The SV, TR, KO and ES Wiktionaries already write the synonyms next to each meaning.

@BoboTiG

BoboTiG commented Nov 9, 2026

Copy link
Copy Markdown
Member

Awesome! For the future, if you would like to tackle other locales (when applicable) do not hesitate :)

@BoboTiG

BoboTiG commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

I saw this might also be possible for Japanese, example with https://ja.wiktionary.org/wiki/%E3%81%B5%E3%81%86%E3%82%93 ; it does not seem to be always this obvious, but it could improve the overall dictionary anyway.

Another use case: https://ja.wiktionary.org/wiki/%E5%B9%B4%E7%94%9F

@monosans

Copy link
Copy Markdown
Contributor Author

good catch, JA is in #2839. it handles the "語義1" references in the three layouts I found (inline, a 語義1 line above the bullets, and (語義1、語義2) at the end). lists without numbers stay as they are, which is about half of them

@BoboTiG

BoboTiG commented Nov 15, 2026

Copy link
Copy Markdown
Member

Note: NL could benefit of such an improvement, even if it is not as widely used as in other locales, example: https://nl.wiktionary.org/wiki/daardoor

@monosans

Copy link
Copy Markdown
Contributor Author

good catch, did NL in #2842. on daardoor the [1] synonyms now show under the first meaning, and it works on about 6.7k NL pages

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