igo 0.1.4.4 → 0.1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/igo/version.rb +1 -1
  3. data/lib/igo/zh.rb +13 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3bb523eb2fb2de5a99f48c655e4b100cbd37cb21a4052c69ae7f5035415ba72
4
- data.tar.gz: 5abec0cf2b57f2994a16b0e158ac5d5a36951c50c2bbeec176134aed529c984b
3
+ metadata.gz: 162dbf25843e4abc7c37ffe7f1008a0797b39ffcfa580935153e1587c20ea45f
4
+ data.tar.gz: 1238620c484fbb0b7b836b54dcebaf7941d11671a25c8ffccdaa1c73a55b9f5c
5
5
  SHA512:
6
- metadata.gz: 731af0cf150373bc8af9dc2a6577102d3ac6bffac7f90d4960da8b5af2fbb7f1f8f4b70c1093accc2327561cf1939655a286fdb16e717be5705f1b012e73ea74
7
- data.tar.gz: 6e11f5dbc4ef39ded02b50e26e16cb836a7724f6b514987b086650edbbdbdf0032ee4a8cd5e802783f67d5c51f589806f58b32505c8cf5c73804b7b843b1824f
6
+ metadata.gz: ce147e5d825261918505ad7384dfa19e69d11f1c5e5ff3bd400d824348e48e060cb494b0dc8a7fbbedb17f9974c2c6ea4cde32daf3696fb7f7f8ed63227abb85
7
+ data.tar.gz: cc11cafda234eacf008f78000baab86bc79fd3a3248477f346fec89f17d32291e458a4b1811ec17c95b2a2bd0c689caf7f123372978d346f8f06e3d3b7f21929
data/lib/igo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Igo
4
- VERSION = "0.1.4.4"
4
+ VERSION = "0.1.4.6"
5
5
  end
data/lib/igo/zh.rb CHANGED
@@ -67,7 +67,16 @@ module Igo
67
67
  # @returns pinyin_numeraltone: String
68
68
  def pinyin str, s: false, ommit: " "
69
69
  # tone 1, 2, 3, 4, 5
70
- res = str.split(/(?=[^A-Z\d])|(?<=[^A-Z\d])/i).map{|ch| ch.ord > 0x4e00 ? (py = PinYin.of_string(ch, :ascii)[0]; py =~ /\d/ ? py : (py+"5")) : ch }.flatten.select{_1 != s and _1 != ommit}
70
+ hanzi_ords = [13312..19903, 19968..40959, 63744..64255, 131072..173791, 173824..177983, 194560..195103]
71
+
72
+ res = str.split(/(?=[^A-Z\d])|(?<=[^A-Z\d])/i).map do |ch|
73
+ if hanzi_ords.map{|range| range.include? ch.ord}.any?
74
+ py = PinYin.sentence(ch, :ascii)
75
+ py =~ /\d/ ? py : (py+"5")
76
+ else ch
77
+ end
78
+ end.flatten.select{_1 != s and _1 != ommit}
79
+
71
80
  sep = s.is_a?(String) ? s : " "
72
81
  s ? res.join(sep) : res
73
82
 
@@ -85,7 +94,9 @@ module Igo
85
94
  end
86
95
  when /thulac/
87
96
  require_relative 'thulac'
88
- Thulac.cut(str, text: s)
97
+ res = Thulac.cut(str).map(&:first)
98
+ sep = s.is_a?(String) ? s : " "
99
+ s ? res.join(sep) : res
89
100
  end
90
101
  end
91
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.4
4
+ version: 0.1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - saisui