gimchi 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/config/default.yml +2 -1
- data/lib/gimchi/korean.rb +9 -14
- data/test/test_gimchi.rb +4 -0
- metadata +11 -11
data/config/default.yml
CHANGED
data/lib/gimchi/korean.rb
CHANGED
@@ -72,8 +72,8 @@ class Korean
|
|
72
72
|
def read_number str
|
73
73
|
nconfig = config['number']
|
74
74
|
|
75
|
-
str.to_s.gsub(/([+-]\s*)?[0-9,]*,*[0-9]+(\.[0-9]+(e[+-][0-9]+)?)?(\s*.)?/) {
|
76
|
-
read_number_sub(
|
75
|
+
str.to_s.gsub(/(([+-]\s*)?[0-9,]*,*[0-9]+(\.[0-9]+(e[+-][0-9]+)?)?)(\s*.)?/) {
|
76
|
+
read_number_sub($1, $5)
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
@@ -168,17 +168,17 @@ class Korean
|
|
168
168
|
end
|
169
169
|
|
170
170
|
private
|
171
|
-
def read_number_sub num, next_char
|
171
|
+
def read_number_sub num, next_char
|
172
172
|
nconfig = config['number']
|
173
173
|
|
174
174
|
num = num.gsub(',', '')
|
175
|
-
|
175
|
+
next_char = next_char.to_s
|
176
176
|
is_float = num.match(/[\.e]/) != nil
|
177
177
|
|
178
178
|
# Alternative notation for integers with proper suffix
|
179
179
|
alt = false
|
180
180
|
if is_float == false &&
|
181
|
-
nconfig['alt notation']['when suffix'].keys.include?(next_char.
|
181
|
+
nconfig['alt notation']['when suffix'].keys.include?(next_char.strip)
|
182
182
|
max = nconfig['alt notation']['when suffix'][next_char.strip]['max']
|
183
183
|
|
184
184
|
if max.nil? || num.to_i <= max
|
@@ -265,14 +265,9 @@ private
|
|
265
265
|
v %= 10
|
266
266
|
str += digits[v] if v > 0
|
267
267
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
alt_post_subs.each do | k, v |
|
272
|
-
str.gsub!(k, v)
|
273
|
-
end
|
274
|
-
str.sub!(/#{suffix}$/, '')
|
275
|
-
end
|
268
|
+
alt_post_subs.each do | k, v |
|
269
|
+
str.gsub!(k, v)
|
270
|
+
end if alt
|
276
271
|
tokens << str.sub(/ $/, '') + nconfig['units'][unit_idx]
|
277
272
|
end
|
278
273
|
end
|
@@ -280,7 +275,7 @@ private
|
|
280
275
|
end
|
281
276
|
|
282
277
|
tokens += sign unless sign.empty?
|
283
|
-
ret = tokens.reverse.join(' ') + below + next_char
|
278
|
+
ret = tokens.reverse.join(' ') + below + next_char
|
284
279
|
nconfig['post substitution'].each do | k, v |
|
285
280
|
ret.gsub!(k, v)
|
286
281
|
end
|
data/test/test_gimchi.rb
CHANGED
@@ -91,7 +91,11 @@ class TestGimchi < Test::Unit::TestCase
|
|
91
91
|
assert_equal "플러스 십점영", ko.read_number("+ 10.0")
|
92
92
|
|
93
93
|
# 나이, 시간, 개수, 명 ( -살, -시, -개, -명 )
|
94
|
+
assert_equal "나는 이십", ko.read_number("나는 20")
|
94
95
|
assert_equal "나는 스무살", ko.read_number("나는 20살")
|
96
|
+
assert_equal "나는 스물네살", ko.read_number("나는 24살")
|
97
|
+
assert_equal "스무개", ko.read_number("20개")
|
98
|
+
assert_equal "스무 명", ko.read_number("20 명")
|
95
99
|
assert_equal "이십 칠점일살", ko.read_number("27.1살")
|
96
100
|
assert_equal "너는 열세 살", ko.read_number("너는 13 살")
|
97
101
|
assert_equal "백 서른두명", ko.read_number("132명")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gimchi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-04-
|
12
|
+
date: 2011-04-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152254860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152254860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152253040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.5.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152253040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rcov
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152251640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152251640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ansi
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152249420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.2.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152249420
|
58
58
|
description: Gimchi knows how to pronounce Korean strings and how to write them in
|
59
59
|
roman alphabet.
|
60
60
|
email: junegunn.c@gmail.com
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
segments:
|
95
95
|
- 0
|
96
|
-
hash:
|
96
|
+
hash: 170191827344354628
|
97
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|