Function match_pinyin_with_hanzi::match_pinyin_with_hanzi
source · pub fn match_pinyin_with_hanzi(
pinyin_str: &str,
hanzi_str: &str
) -> Result<(), String>
Expand description
use match_pinyin_with_hanzi::match_pinyin_with_hanzi;
match_pinyin_with_hanzi("māmā qí mǎ, mǎ màn, māma mà mǎ.", "妈妈骑马,马慢,妈妈骂马。").unwrap();
// Erhua is also supported.
// This sample sentence is taken from Wiktionary: https://en.wiktionary.org/w/index.php?title=%E4%B8%80%E9%BB%9E%E5%85%92&oldid=60782800
match_pinyin_with_hanzi("Jiù wèi zhème yīdiǎnr shìr shēngqì, zhídàng de ma?", "就為這麼一點兒事兒生氣,值當的嗎?").unwrap();
Panics
Panics when
- hanzi runs out
Errors
Returns Err
when
- hanzi’s pinyin candidate does not match with the given pinyin