Skip to content

Commit

Permalink
exclude underscore _
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Xie committed Sep 6, 2015
1 parent 6c460d8 commit 167981d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ruby-pinyin (0.4.6)
ruby-pinyin (0.4.7)
rmmseg-cpp (~> 0.2)

GEM
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-pinyin/backend/simple.rb
Expand Up @@ -20,7 +20,7 @@ def romanize(str, tone=nil, include_punctuations=false)
res << Value.new(format(readings, tone), false)
else
val = [t].pack('U*')
if val =~ /^[_0-9a-zA-Z\s]*$/ # 复原,去除特殊字符,如全角符号等。
if val =~ /^[0-9a-zA-Z\s]*$/ # 复原,去除特殊字符,如全角符号等。
if res.last && res.last.english?
res.last << Value.new(val, true)
elsif val != ' '
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-pinyin/version.rb
@@ -1,3 +1,3 @@
module PinYin
VERSION = '0.4.6'
VERSION = '0.4.7'
end
1 change: 1 addition & 0 deletions test/pinyin_test.rb
Expand Up @@ -79,6 +79,7 @@ def test_get_pinyin_sentence_with_unicode_punctuation
assert_equal 'tiān lěng le, kuài huí jiā.', PinYin.sentence('天冷了, 快回家。', :unicode)
assert_equal 'tiān lěng le, kuài huí jiā.', PinYin.sentence('天冷了,快回家。', :unicode)
assert_equal 'huáng fà chuí tiáo. qiān mò', PinYin.sentence('黄发垂髫。阡陌', :unicode)
assert_equal %w(ni hao zhong guo), PinYin.of_string('你好!@_@ 中国!')
end

def test_get_pinyin_sentence_with_ascii_tone
Expand Down

0 comments on commit 167981d

Please sign in to comment.