zhongwen_tools 0.3.4 → 0.3.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f965dd1341aa973557bb865e052c65c58df0835
4
- data.tar.gz: 92e39709e8048bc311dd016003cb3387fb282215
3
+ metadata.gz: 922f41394b5974c16b42521d9a203ac31876272e
4
+ data.tar.gz: 8390da15a9a05b60703c661ec117b77da2a52edb
5
5
  SHA512:
6
- metadata.gz: ccc8db745b1ad32c4e2f4a6c95e18a7100893befe1feac7007c35bd6719d46eba1c27c5a148a81d6819da94fed8252c7c9ab0fa3d5a931076613c7be8aefb069
7
- data.tar.gz: 5d59d0e55a488eaa01ab87eec4a778fcd456f360cad8309a254f6b6de8536570c84719deb5b0c30c55c4e3fa597598377ae091edc3d73b4dbdda3f55c0f283f9
6
+ metadata.gz: a4b14a2962e68f69dfa4fbeb20731ed1c067f0110eefd7711c09f4bce2f4450a71fbad9912eb68154415ea106a263c4b79a173f68c142da66bffae52f6e9cb5a
7
+ data.tar.gz: c5d4b6cfe2d3be093b6852d89fecfbf6b995818f6f134341b920372cbb8c9d93d604fff9df2c2cfd49694238ec6ba991304b38960c7c1d29ab275072f61a9e17
@@ -80,11 +80,12 @@ module ZhongwenTools
80
80
  def _to_romanization str, to, from
81
81
  convert_to = _set_type to
82
82
  convert_from = _set_type from
83
- tokens = str.split(' ').uniq
83
+ tokens = str.split(/[ \-]/).uniq
84
84
  replacements = tokens.collect do |t|
85
85
  # non_romanization = t.match(/[1-5](.*)/)[-1]
86
86
  search = t.gsub(/[1-5].*/,'')
87
87
  begin
88
+ capitalized = t.downcase != t
88
89
  if from.nil? || convert_from.nil?
89
90
  replace = ROMANANIZATIONS_TABLE.find{|x| x.values.include? t.downcase.gsub(/[1-5].*/,'')}[convert_to.to_sym]
90
91
  else
@@ -93,6 +94,8 @@ module ZhongwenTools
93
94
  rescue => e#rescue when the converter meets something it doesn't recognize
94
95
  replace = search
95
96
  end
97
+
98
+ replace = replace.capitalize if capitalized
96
99
  str = str.gsub(search, replace)
97
100
  end
98
101
  str
@@ -112,7 +115,7 @@ module ZhongwenTools
112
115
  #need to convert pinyin to pyn
113
116
  raise NotImplementedError, 'method not implemented'
114
117
  end
115
- _to_romanization str, to, from
118
+ _to_romanization(str, to, from).gsub('-','')
116
119
  else
117
120
  if from == :pyn
118
121
  _to_romanization str, to, from
@@ -1,3 +1,3 @@
1
1
  module ZhongwenTools
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -31,15 +31,15 @@ class TestRomanization < Minitest::Test
31
31
  assert_equal 'ㄋㄧ3 ㄏㄠ3', @str.to_bopomofo
32
32
  assert_equal 'ㄋㄧ3 ㄏㄠ3', @str.to_zhuyin
33
33
  assert_equal 'ㄇㄠ2 ㄗㄜ2 ㄉㄨㄥ1', @mzd.to_zhuyin_fuhao
34
- #skip
35
- #assert_equal 'ㄇㄠ2 ㄗㄜ2ㄉㄨㄥ1', @mzd2.to_zhuyin_fuhao
34
+ assert_equal 'ㄑㄧㄥ3 ㄏㄨㄟ2ㄉㄚ2 ㄨㄛ3 ㄉㄜ5 ㄨㄣ4ㄊㄧ2 .', @sent.to_zhuyin
35
+ assert_equal 'ㄇㄠ2 ㄗㄜ2ㄉㄨㄥ1', @mzd2.to_zhuyin_fuhao
36
36
  end
37
37
 
38
38
  def test_wade_giles
39
39
  assert_equal 'kuo1', 'guo1'.to_wg
40
40
  assert_equal 'chung1 kuo2', 'zhong1 guo2'.to_wg
41
- #assert_equal 'Mao2 Tse2 tung1', @mzd.to_wg
42
- #assert_equal 'Mao2 Tse2 tung1', @mzd.to_wade_giles
41
+ assert_equal 'Mao2 Tse2 tung1', @mzd.to_wg
42
+ assert_equal 'Mao2 Tse2-tung1', @mzd2.to_wade_giles
43
43
  end
44
44
 
45
45
  #def test_mspy2
@@ -71,5 +71,6 @@ class TestRomanization < Minitest::Test
71
71
  @mzd = 'Mao2 Ze2 dong1'
72
72
  @mzd2 = 'Mao2 Ze2-dong1'
73
73
  @py = 'nǐ hǎo'
74
+ @sent = 'Qing3 hui2-da2 wo3 de5 wen4-ti2 .'
74
75
  end
75
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zhongwen_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Daniels