#chinese #pinyin #translation #charator

pinyin-translator

Chinese charator translate as pinyin

6 releases

0.2.3 Jun 30, 2023
0.2.2 Sep 30, 2022
0.2.1 May 8, 2022
0.2.0 Apr 28, 2022
0.1.1 Apr 27, 2022

#142 in Internationalization (i18n)

30 downloads per month

MIT license

1.5MB
48K SLoC

pinyin-translator Build Status

将中文翻译为拼音。内嵌字词库,支持多音词。

示例

fn main() {
    let content = "わたしわ阿飞, and my English name is Rex Lee. 网名是独孤影! ^_^。下面是一段多音分词歧义测试,这个人无伤无臭味。".to_string();
    let pt = pinyin_translator::PinyinTranslator::new();
    let result = pt.translate(content.clone());
    println!("{}", result);

    let vec = pt.translate_as_slice(content.clone());
    println!("{:?}", vec);
}

输出

わたしわāfēi, and my English name is Rex Lee. wǎngmíngshìdúgūyǐng! ^_^。xiàmiànshìyīduànduōyīnfēncíqíyìcèshì,zhègèrénwúshāngwúchòuwèi。
["わ", "た", "し", "わ", "ā", "fēi", ",", " ", "a", "n", "d", " ", "m", "y", " ", "E", "n", "g", "l", "i", "s", "h", " ", "n", "a", "m", "e", " ", "i", "s", " ", "R", "e", "x", " ", "L", "e", "e", ".", " ", "wǎng", "míng", "shì", "dú", "gū", "yǐng", "!", " ", "^", "_", "^", "。", "xià", "miàn", "shì", "yī", "d"duō", "yīn", "fēn", "cí", "qí", "yì", "cè", "shì", ",", "zhè", "gè", "rén", "wú", "shāng", "wú", "chòu", "wèi", "。"]

License

MIT License

No runtime deps