Anki add-on: Pinyin on top of Hanzi

For the source code, the GitHub link . In a nutshell, this addon turns into The way the addon achieves this is really quite simple. At its core is the recent addition of ruby characters to HTML. Here is a part of above example's ruby HTML: <ruby>老师<rt>lǎo shī</rt></ruby> . Because it's pure HTML we can directly add the ruby to one of the note's fields. Make sure to add a field beforehand to your note, as the addon can (currently) only work with existing fields. The addon works whether you already have matching Pinyin. It helps to have matching Pinyin, but the addon is smart enough to generate (usually correct) Pinyin on its own. The interface was designed for ease of use. After installation, to start the Pinyin generation, go to Tools → Chinese tools → Pinyin helper . Then choose the deck, note type, and field with the Hanzi characters. If you already have a field with matching Pinyin, select the first option. The addon will match Hanzi and Pinyin together to the best of its ability. You can preview the output by selecting any one of the Hanzi on the left (from your own cards) and see the matched Hanzi and Pinyin on the right. Make sure to select a field for where the ruby output should go. Here is an example of the addon generating Pinyin when there is no pre-existing Pinyin to match with the Hanzi. The addon goes beyond assigning Pinyin to individual Hanzi, which is error-prone — there are many Hanzi with multiple Pinyin readings. It instead first splits the Hanzi sentence (in which there are usually no spaces) into words, then looks up each word in an internal dictionary. While it may make the occasional mistake it is remarkably adept at assigning the right Pinyin. There is also the option of generating a table of definitions from the internal dictionary: The addon restricts the dictionary entries to match the Pinyin readings, which it finds in the note if you specified a Pinyin field, or generates on its own if you haven't. The dictionary entries are also entirely in HTML, and come with CSS selectors for the word, Pinyin, and definitions columns. Remember to specify another field in the note where the table of definitions will go. This addon would not have been possible without two third-party Python modules. I've used jieba for segmenting Hanzi into words, and zhon for correctly splitting joined-up Pinyin as well as the free Chinese dictionary CEDICT . Everything is bundled in the addon, which explains its large download size. Notes Although ruby generation works for all Pinyin options, when Pinyin is generated where there is none currently existing, the Pinyin will not be saved to the note, despite the option Pinyin output . I have some pretty bare-bones CSS for the definitions table, which I'll publish soon. I include spacing between Hanzi in the ruby .If you want to preserve the spacing of the original Hanzi, I'll add that as another option in the addon window.

GitHub repository: ericahn/anki-chinese
Repository description: An Anki addon that adds ruby pinyin to Chinese sentences, and optionally definitions for each Chinese word
Languages: Python, OpenEdge ABL, Shell