开发者

Python CJKLIB: no pinyin tones

I'm working with CJKLIB, using the getReadingForCharacter, to convert Chinese characters into pinyin. However, is there some way

readings = cjk.getReadingForCharacter(c, 'Pinyin')

The problem is th开发者_高级运维at it returns pinyin with the tones on them, which I do not want. For example, I want "Beijing", not "Běijīng" - with all the tone marks.

Anyone know how I can get an output without the tones? Thanks!


The solution simply is:

>>> cjk.getReadingForCharacter(u'北', 'Pinyin', toneMarkType='none')
[u'bei']

You can read more about possible options here: http://cjklib.org/0.3/library/cjklib.reading.operator.PinyinOperator.html#cjklib.reading.operator.PinyinOperator


Maybe using a simpler lib fit your task better and faster, cjklib don't provide an API to convert chinese to pinyin without tone.

such python lib is as follows:

  • hanzi2pinyin

  • xpinyin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜