Code Monkey home page Code Monkey logo

chinese_pinyin's Introduction

chinese_pinyin's People

Contributors

benlieb avatar cuihq avatar flyerhzm avatar fsword avatar hongliang-goudou avatar huacnlee avatar lanzhiheng avatar pmq20 avatar saberma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chinese_pinyin's Issues

pinyin-utf8.dat 里面的 5 是什么意思

tone_index 1 2 3 4 分别是 4 个声,5 是什么?而且有 91 个有 5.

如果 tone_index 是 5 的话,下面代码就会出错

tone_index = pinyin[-1].to_i
pinyin = pinyin[0...-1]
%w(a o e i u v).each { |v|
  break if pinyin.tr! v, TONE_MARK[v.to_sym][tone_index]
}

代码来自 (https://github.com/flyerhzm/chinese_pinyin/blob/master/lib/chinese_pinyin.rb#L86-L90)

因为每个 TONE_MARK[v.to_sym] 都只有 5 个元素,因此会取到 nil,再进行 tr! 就会报错。

有些字的第一个拼音的 tone 不是 5,所以不会出问题。但也有不少字的第一个拼音的 tone 是 5,

awk '$2~/5/{print $1,$2}' data/pinyin-utf8.dat
㟷 da5
了 le5
们 men5
們 men5
吗 ma5
吧 ba5
吶 ne5
呗 bei5
哟 yo5

这些字转成拼音都会报错.

Pinyin.t('呗', tonemarks: true)

# : in `tr!': no implicit conversion of nil into String (TypeError)

README.md有错。。。

Polyphone Issue

use Words.dat to override default behavior.

by default

Pinyin.t('广州') => "yan zhou"

add file Words.dat

广州|guang3 zhou1

set ENV['WORDS_FILE'] for Words.dat

ENV['WORDS_FILE'] = "Words.dat path"
Pinyin.t('广州') => "guang zhou"

第一行示例code,广州怎么会得出“yan zhou”

嗯 returns no result

Description

嗯 returns no result
嗯 is HSK6 word.
In Japanese Wiktionary, the pinyin is described as en1.
https://ja.wiktionary.org/wiki/嗯

Environment

OS: macOS Mojave ver10.14.6
ruby: ruby 2.6.3p62
chinese_pinyin (1.0.1)

Test Code

require 'chinese_pinyin'

puts Pinyin.t('嗯', tonemarks: true)

# =>
(no result)

拼音有错误

您这个版本的拼音有很多多余的,比如参字,怎么来了个den音?等等,比其他的多了很多音。

保留符号

下面这个例子是现在的转换方式:

irb
irb(main):001:0> require 'chinese_pinyin'
=> true
irb(main):002:0> Pinyin.t('/(斜线)')
=> "  xie xian"

可以看出,斜线(/)和括号(())都被“吃掉”了。有没有办法可以保留符号呢?

Tone Marks

Is it possible to also add in the tone marks?

eg.

Pinyin.t('**', tonemarks: true) => "zhōng guó"

Node.js Support

It would be awesome to add node.js support for the ruby library.

License file

Hello,

Could you please include a license file in this project so that we know in what conditions we can use your library? (an MIT-license would be great)

如果遇到中文标点就体内停止转换了。

搜汉字转拼音时,从Ruby China的一个回复中,找到了这个。但是,在测试中发现一个问题。如下:

我的测试代码如下:

Pinyin.t("测试一下,Think diff", splitter: '-')

希望的结果应该如下:

"ce-shi-yi-xia-Think-diff"

但是,得到的结果确实这样的:

"ce-shi-yi-xia-,Think diff"

请看一下,这是否是个问题?

新增拼音显示特性

新增特性

  1. 拼音缩写,用于快速检索
  2. 首字母,用于分组显示
  3. 自定义效果

期望效果

Pinyin.t('北京', initial: true) # BJ
Pinyin.t('北京', letter: true) # B
Pinyin.t('北京') do |letters|
  ...
end

替代方案

Pinyin.t('北京').split.map { |w| w.first.upcase }.join # BJ
Pinyin.t('北京').first.upcase # B

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.