neocl / jamdict

Python 3 library for manipulating Jim Breen's JMdict, KanjiDic2, JMnedict and kanji-radical mappings
MIT License
130 stars 12 forks source link

Getting radical of a character #45

Open alt-romes opened 2 months ago

alt-romes commented 2 months ago

I would like to know whether it is possible to get the radical (not the components) of a character.

In the documentation, you mention precisely the difference between radicals and components, but only show how to get the components.

From reading the API it looks like it's not possible to get the radical only? If there is a way, please do tell.

I'd be happy to improve the documentation wrt this.

Thanks!

alt-romes commented 2 months ago

Indeed, there's a way to get the Kangxi radical of the character:

jam.lookup("蹴").chars[0].radical
> 足-foot[sc:7]
jam.lookup("蹴").chars[0].radical.radical
>  足
jam.lookup("蹴").chars[0].radical.meaning
> foot

This is great! Though, ideally, it would be reflected in the documentation. At least now it should be findable here...

alt-romes commented 2 months ago

I'll submit a patch to the documentation