hangul_tools 1.0.0 → 1.1.0
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 +4 -4
- data/README.md +3 -3
- data/lib/hangul_tools.rb +2 -2
- data/lib/hangul_tools/version.rb +1 -1
- data/test/romanization_test.rb +16 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc090a64911a8c7aa16c928125b3d08dca7a6475
|
4
|
+
data.tar.gz: dcde63a1257f1d02896ba923a9acf2e468ed291c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31854ce478355a409964e653dce96fcf44b64316a19c544d155bb2c9c9508ce6247537d2768de7a373fc1ec23898008136a15d52266742f4b71934ac017e9900
|
7
|
+
data.tar.gz: a4097db06c4985f778caa027d3adbe9e76aecfab444fd893d9e5195e4dbdda0677506acd7b05f6595ad8fa1097688719321d2d0215796508f6cf5b969cac2392
|
data/README.md
CHANGED
@@ -16,10 +16,10 @@ require 'hangul_tools'
|
|
16
16
|
|
17
17
|
s = 'I told him, "안녕하십니까."'
|
18
18
|
|
19
|
-
puts
|
19
|
+
puts HangulTools.romanize(s, system: :revised)
|
20
20
|
# => I told him, "annyeonghasimnikka."
|
21
21
|
|
22
|
-
puts
|
22
|
+
puts HangulTools.romanize(s, system: :mccune_reischauer)
|
23
23
|
# => I told him, "annyŏnghashimnikka."
|
24
24
|
```
|
25
25
|
|
@@ -28,7 +28,7 @@ If you omit the system to use, it defaults to revised:
|
|
28
28
|
```ruby
|
29
29
|
s = 'I told him, "안녕하십니까."'
|
30
30
|
|
31
|
-
puts
|
31
|
+
puts HangulTools.romanize(s)
|
32
32
|
# => I told him, "annyeonghasimnikka."
|
33
33
|
```
|
34
34
|
|
data/lib/hangul_tools.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
# http://gernot-katzers-spice-pages.com/var/korean_hangul_unicode.html
|
3
3
|
|
4
4
|
module HangulTools
|
5
|
-
def self.romanize(text, system
|
5
|
+
def self.romanize(text, system: :revised, initial: :initial)
|
6
6
|
matrix = matrices[system]
|
7
7
|
vowels = VOWELS[system]
|
8
8
|
|
9
9
|
text.scan(/[\uAC00-\uD7a3]+|[^\uAC00-\uD7a3]+/).map.with_index do |string, idx|
|
10
10
|
if string =~ /[\uAC00-\uD7a3]/
|
11
|
-
romanize_with_system(string, system, idx > 0 ? :voiced :
|
11
|
+
romanize_with_system(string, system, idx > 0 ? :voiced : initial)
|
12
12
|
else
|
13
13
|
string
|
14
14
|
end
|
data/lib/hangul_tools/version.rb
CHANGED
data/test/romanization_test.rb
CHANGED
@@ -29,7 +29,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
hangul.zip(latin).each do |(given, expect)|
|
31
31
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
32
|
-
actual = HangulTools.romanize(given, :revised)
|
32
|
+
actual = HangulTools.romanize(given, system: :revised)
|
33
33
|
assert_equal expect, actual
|
34
34
|
end
|
35
35
|
end
|
@@ -41,7 +41,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
41
41
|
|
42
42
|
hangul.zip(latin).each do |(given, expect)|
|
43
43
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
44
|
-
actual = HangulTools.romanize(given, :revised)
|
44
|
+
actual = HangulTools.romanize(given, system: :revised)
|
45
45
|
assert_equal expect, actual
|
46
46
|
end
|
47
47
|
end
|
@@ -53,7 +53,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
53
53
|
|
54
54
|
hangul.zip(latin).each do |(given, expect)|
|
55
55
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
56
|
-
actual = HangulTools.romanize(given, :revised)
|
56
|
+
actual = HangulTools.romanize(given, system: :revised)
|
57
57
|
assert_equal expect, actual
|
58
58
|
end
|
59
59
|
end
|
@@ -61,14 +61,14 @@ class RomanizationTest < Test::Unit::TestCase
|
|
61
61
|
|
62
62
|
def test_revised_romanization_concatenation_of_consecutive_syllables
|
63
63
|
given = "안녕하십니까"
|
64
|
-
actual = HangulTools.romanize(given, :revised)
|
64
|
+
actual = HangulTools.romanize(given, system: :revised)
|
65
65
|
|
66
66
|
assert_equal "annyeonghasimnikka", actual
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_romanization_of_mixed_hangul_and_latin_romanizes_only_hangul
|
70
70
|
given = 'I said, "안녕하십니까," and she said "누구세요?"'
|
71
|
-
actual = HangulTools.romanize(given, :revised)
|
71
|
+
actual = HangulTools.romanize(given, system: :revised)
|
72
72
|
|
73
73
|
assert_equal 'I said, "annyeonghasimnikka," and she said "nuguseyo?"', actual
|
74
74
|
end
|
@@ -79,7 +79,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
79
79
|
|
80
80
|
hangul.zip(latin).each do |(given, expect)|
|
81
81
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
82
|
-
actual = HangulTools.romanize(given, :mccune_reischauer)
|
82
|
+
actual = HangulTools.romanize(given, system: :mccune_reischauer)
|
83
83
|
assert_equal expect, actual
|
84
84
|
end
|
85
85
|
end
|
@@ -91,7 +91,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
91
91
|
|
92
92
|
hangul.zip(latin).each do |(given, expect)|
|
93
93
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
94
|
-
actual = HangulTools.romanize(given, :mccune_reischauer)
|
94
|
+
actual = HangulTools.romanize(given, system: :mccune_reischauer)
|
95
95
|
assert_equal expect, actual
|
96
96
|
end
|
97
97
|
end
|
@@ -103,7 +103,7 @@ class RomanizationTest < Test::Unit::TestCase
|
|
103
103
|
|
104
104
|
hangul.zip(latin).each do |(given, expect)|
|
105
105
|
assert_nothing_raised "given #{given.inspect} expect #{expect.inspect}" do
|
106
|
-
actual = HangulTools.romanize(given, :mccune_reischauer)
|
106
|
+
actual = HangulTools.romanize(given, system: :mccune_reischauer)
|
107
107
|
assert_equal expect, actual
|
108
108
|
end
|
109
109
|
end
|
@@ -111,8 +111,15 @@ class RomanizationTest < Test::Unit::TestCase
|
|
111
111
|
|
112
112
|
def test_mccune_reischauer_romanization_concatenation_of_consecutive_syllables
|
113
113
|
given = "안녕하십니까"
|
114
|
-
actual = HangulTools.romanize(given, :mccune_reischauer)
|
114
|
+
actual = HangulTools.romanize(given, system: :mccune_reischauer)
|
115
115
|
|
116
116
|
assert_equal "annyŏnghashimnikka", actual
|
117
117
|
end
|
118
|
+
|
119
|
+
def test_romanize_with_initial_voiced
|
120
|
+
given = "가자"
|
121
|
+
actual = HangulTools.romanize(given, system: :mccune_reischauer, initial: :voiced)
|
122
|
+
|
123
|
+
assert_equal "gaja", actual
|
124
|
+
end
|
118
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hangul_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|