- 授权协议: MIT
- 开发语言: Ruby
- 操作系统: 跨平台
- 软件首页: https://github.com/flyerhzm/chinese_pinyin
- 软件文档: https://github.com/flyerhzm/chinese_pinyin/blob/master/README.md
- 官方下载: https://github.com/flyerhzm/chinese_pinyin/tags
软件介绍
chinese_pinyin 是一款将汉字转化为拼音的应用。
安装
gem install chinese_pinyin
或者在Gemfile中添加:
gem 'chinese_pinyin'
用法
命令行
$ ch2py -h Usage: ch2py [opts] -c, --camelcase Camelcase of each word -i, --stdin Read from stdard input -t, --tone Show tone at end of word -m, --tonemarks Show tone at top of letter, this would cover -t option -s, --splitter <splitter> Splitter of each word, use a space by default -v, --version Show version -h, --help Show this help $ ch2py 中文 zhong wen
代码
require 'chinese_pinyin'
Pinyin.t('中国') => "zhong guo"
Pinyin.t('你好world') => "ni hao world"
Pinyin.t('中国', splitter: '-') => "zhong-guo"
Pinyin.t('中国', splitter: '') => "zhongguo"
Pinyin.t('中国', tone: true) => "zhong1 guo2"
Pinyin.t('中国', tonemarks: true) => "zhōng guó"
Pinyin.t('北京') { |letters| letters[0].upcase } => 'BJ'
Pinyin.t('北京') { |letters, i| letters[0].upcase if i == 0 } => 'B'Polyphone Issue
使用Words.dat覆盖默认行为
默认配置
Pinyin.t('广州') => "yan zhou"增加 Words.dat 文件
广州|guang3 zhou1
为 Words.dat 设置 ENV['WORDS_FILE']
ENV['WORDS_FILE'] = "Words.dat path"
Pinyin.t('广州') => "guang zhou"
Python源码剖析
陈儒 / 电子工业出版社 / 2008-6 / 69.80元
作为主流的动态语言,Python不仅简单易学、移植性好,而且拥有强大丰富的库的支持。此外,Python强大的可扩展性,让开发人员既可以非常容易地利用C/C++编写Python的扩展模块,还能将Python嵌入到C/C++程序中,为自己的系统添加动态扩展和动态编程的能力。. 为了更好地利用Python语言,无论是使用Python语言本身,还是将Python与C/C++交互使用,深刻理解Pyth......一起来看看 《Python源码剖析》 这本书的介绍吧!
