分享 发现一个不错的汉字转拼音 Gem

zhuoqun · September 16, 2012 · Last by Martin91 replied at May 04, 2013 · 9174 hits

因为要做类似微博的 @ 提醒功能,当用户名是汉字的时候希望可以通过全拼或每个字的拼音首字母进行匹配,然后就发现了这个 Gem:

https://github.com/janx/ruby-pinyin

经过测试,还是挺好用的。

php 时做过类似的东西,还有繁体和简体的对应

也可以通过 jruby 调用 pinyin4j,这个支持多音字还有语调。

#3 楼 @pongyo 这个 Gem 也支持语调。

实用!同时发现社区里一位大神@flyerhzm在 github 上的一个项目ChinesePinyin,亮点是另外提供了覆盖多音字拼音的功能。

You need to Sign in before reply, if you don't have an account, please Sign up first.