ChinesePinyin

码农软件 · 软件分类 · 拼音转换工具包 · 2019-08-04 14:42:37

软件介绍

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"

本文地址:https://codercto.com/soft/d/11631.html

程序员修炼之道

程序员修炼之道

Andrew Hunt、David Thomas / 马维达 / 电子工业出版社 / 2005-1 / 48.00元

《程序员修炼之道》由一系列的独立的部分组成,涵盖的主题从个人责任、职业发展,直到用于使代码保持灵活、并且易于改编和复用的各种架构技术。利用许多富有娱乐性的奇闻轶事、有思想性的例子以及有趣的类比,全面阐释了软件开发的许多不同方面的最佳实践和重大陷阱。无论你是初学者,是有经验的程序员,还是软件项目经理,本书都适合你阅读。一起来看看 《程序员修炼之道》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具