tradsim 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,22 +1,7 @@
1
- Copyright (c) 2012 erinata
1
+ Copyright (C) 2012 Tom Lam
2
2
 
3
- MIT License
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
6
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tradsim
2
2
 
3
- A Ruby gem for translation between Traditional Chinese and Simplified Chinese. The gem includes a mapping dictionary so it doesn't get the translation from a web service. It can translate Traditional Chinese, Simplified Chinese or a mixed string into Traditional Chinese or Simplified Chinese. Also, you can let the gem to determine whether the supplied string is in Traditional Chinese or not.
3
+ A Ruby Gem for translation between Traditional Chinese and Simplified Chinese. The Gem includes a mapping dictionary so it doesn't get the translation from a web service. It can translate Traditional Chinese, Simplified Chinese or a mixed string into either Traditional Chinese or Simplified Chinese. Also, you can let the Gem determine whether the supplied string is in Traditional Chinese or not.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,7 +12,7 @@ To use tradsim,
12
12
 
13
13
  require 'tradsim'
14
14
 
15
- To translate Traditional Chinese text to Simplified Chinese
15
+ To translate Traditional Chinese text to Simplified Chinese,
16
16
 
17
17
  Tradsim::to_sim("轉街過巷 就如滑過浪潮 聽天說地 仍然剩我心跳")
18
18
 
@@ -20,7 +20,7 @@ You will get
20
20
 
21
21
  "转街过巷 就如滑过浪潮 听天说地 仍然剩我心跳"
22
22
 
23
- Similarly, to translate Simplified Chinese text to Traditional Chinese
23
+ Similarly, to translate Simplified Chinese text to Traditional Chinese,
24
24
 
25
25
  Tradsim::to_trad("转街过巷 就如滑过浪潮 听天说地 仍然剩我心跳")
26
26
 
@@ -28,7 +28,9 @@ You will get
28
28
 
29
29
  "轉街過巷 就如滑過浪潮 聽天說地 仍然剩我心跳"
30
30
 
31
- Both `to_sim` and `to_trad` works as expected even if the text supplied contain both Traditional and Simplified Chinese Characters. Therefore
31
+ ---
32
+
33
+ Both `to_sim` and `to_trad` works as expected even if the text supplied contain both Traditional and Simplified Chinese Characters. Therefore,
32
34
 
33
35
  Tradsim::to_sim("轉街過巷 就如滑過浪潮 听天说地 仍然剩我心跳")
34
36
 
@@ -36,6 +38,8 @@ will yield
36
38
 
37
39
  "转街过巷 就如滑过浪潮 听天说地 仍然剩我心跳"
38
40
 
41
+ ---
42
+
39
43
  If you are sure about the current text is Traditional Chinese or not, but just want to toggle between them,
40
44
 
41
45
  Tradsim::toggle("轉街過巷 就如滑過浪潮 聽天說地 仍然剩我心跳")
@@ -44,25 +48,14 @@ will yield
44
48
 
45
49
  "转街过巷 就如滑过浪潮 听天说地 仍然剩我心跳"
46
50
 
47
- But `toggle` will translate the string back to Traditional Chinese if you supply a Simplified one.
51
+ And `Tradsim::toggle` will translate the string back to Traditional Chinese if you supply a Simplified one.
52
+
53
+ ---
48
54
 
49
- Finally, `guess` will give you a rough guess on whether the text is Traditional Chinese or not. Possible value from `guess` are `:traditional` , `:simplified` , and `:unknown`. For example,
55
+ Finally, the method `Tradsim::guess` will give you a rough guess on whether the text is Traditional Chinese or not. Possible value from `Tradsim::guess` are `:traditional` , `:simplified` , and `:unknown`. For example,
50
56
 
51
57
  Tradsim::guess("轉街過巷 就如滑過浪潮 聽天說地 仍然剩我心跳")
52
58
 
53
59
  will yield
54
60
 
55
61
  :traditional
56
-
57
-
58
-
59
- ## License
60
-
61
-
62
- Copyright (C) 2012 Tom Lam
63
-
64
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
65
-
66
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
67
-
68
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,3 +1,3 @@
1
1
  module Tradsim
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/tradsim.rb CHANGED
@@ -13,9 +13,7 @@ module Tradsim
13
13
  end
14
14
 
15
15
  def self.guess(text)
16
- traditional = 0
17
- simplified = 0
18
- unknown = 0
16
+ traditional = simplified = unknown = 0
19
17
  text.split(//).each do |char|
20
18
  big5_char_index = big5.index(char)
21
19
  gbk_char_index = gbk.index(char)
data/spec/tradsim_spec.rb CHANGED
@@ -34,4 +34,25 @@ describe "tradsim" do
34
34
  it "should translate correctly on a Traditional Chinese String based on guess" do
35
35
  Tradsim::toggle("转街过巷 就如滑过浪潮 听天说地 仍然剩我心跳").should == "轉街過巷 就如滑過浪潮 聽天說地 仍然剩我心跳"
36
36
  end
37
+
38
+ it "should yield the original string if the spplied string is an English string" do
39
+ Tradsim::to_trad("Though i'm acting cool, when i'm feeling blue, Just to show you that i'm true with you, while i never want it too.").should == "Though i'm acting cool, when i'm feeling blue, Just to show you that i'm true with you, while i never want it too."
40
+ en
41
+
42
+ it "should translate to Traditional Chinese correctly when the string is mixed with Chinese and English" do
43
+ Tradsim::to_trad("转街过巷 Though i'm acting cool 就如滑过浪潮 when i'm feeling blue 听天说地 仍然剩我心跳").should == "轉街過巷 Though i'm acting cool 就如滑過浪潮 when i'm feeling blue 聽天說地 仍然剩我心跳"
44
+ end
45
+
46
+ it "should translate to Simiplified Chinese correctly when the string is mixed with Chinese and English" do
47
+ Tradsim::to_sim("轉街過巷 Though i'm acting cool 就如滑過浪潮 when i'm feeling blue 聽天說地 仍然剩我心跳").should == "转街过巷 Though i'm acting cool 就如滑过浪潮 when i'm feeling blue 听天说地 仍然剩我心跳"
48
+ end
49
+
50
+ it "should translate to Traditional Chinese correctly when the string is mixed with Chinese and English" do
51
+ Tradsim::to_trad("a转a街a过a巷a a就a如a滑a过a浪a潮a a听a天a说a地a a仍a然a剩a我a心a跳a").should == "a轉a街a過a巷a a就a如a滑a過a浪a潮a a聽a天a說a地a a仍a然a剩a我a心a跳a"
52
+ end
53
+
54
+ it "should translate to Simiplified Chinese correctly when the string is mixed with Chinese and English" do
55
+ Tradsim::to_sim("a轉a街a過a巷a a就a如a滑a過a浪a潮a a聽a天a說a地a a仍a然a剩a我a心a跳a").should == "a转a街a过a巷a a就a如a滑a过a浪a潮a a听a天a说a地a a仍a然a剩a我a心a跳a"
56
+ end
57
+
37
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tradsim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &25808652 !ruby/object:Gem::Requirement
16
+ requirement: &26693388 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *25808652
24
+ version_requirements: *26693388
25
25
  description: A Ruby gem for translation between Traditional Chinese and Simplified
26
26
  Chinese.
27
27
  email: