pinyin icon indicating copy to clipboard operation
pinyin copied to clipboard

Add pinyin support

Open mwufi opened this issue 3 years ago • 0 comments

What does this do?

  • Adds an include_pinyin option to the translation function, with pinyin returned in either format (numerical or diacritical)
['还', 'huán', ['to pay back', 'to return']]
['还是', 'hái shi', ['or', 'still', 'nevertheless', 'had better']]
['是', 'shì', ['variant of 是[shi4]', '(used in given names)']]
  • Minor: Adds a pronunciation dictionary, so you can pronounce_word in addition to translating it
>>> pronounce_word("还是")
"hai2 shi5"

Testing

  • Added a test for this behavior!

Why?

Got really disappointed when pinyin.get("还是") returned "huánshì"

It still does that... Although, with this updated all_phrase_translations function, you can pick out the right pronunciation..

mwufi avatar Feb 28 '21 00:02 mwufi