romkan 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ 2002-02-12 Satoru Takabayashi <satoru@namazu.org>
2
+
3
+ * Ruby/Romkan: Version 0.4 released.
4
+
5
+ * romkan.rb (HEPBURNTAB): Add "$B$8$'(B je"
6
+
7
+ 2001-07-11 Satoru Takabayashi <satoru@namazu.org>
8
+
9
+ * Ruby/Romkan: Version 0.3 released.
10
+
11
+ * romkan.rb (to_kunrei): New method.
12
+
13
+ 2001-07-04 Satoru Takabayashi <satoru@namazu.org>
14
+
15
+ * romkan.rb (vowel?): New method.
16
+
17
+ 2001-07-03 Satoru Takabayashi <satoru@namazu.org>
18
+
19
+ * Ruby/Romkan: Version 0.2 released.
20
+
21
+ * romkan.rb (consonant?): New method.
22
+
23
+ * romkan.rb (expand_moras?): New method.
24
+
25
+ 2001-05-01 Satoru Takabayashi <satoru@namazu.org>
26
+
27
+ * Ruby/Romkan: Version 0.1 released.
28
+
@@ -0,0 +1,79 @@
1
+ =begin
2
+ index:Ej
3
+
4
+ = Ruby/Romkan: a Romaji <-> Kana conversion library for Ruby
5
+
6
+ Last Modified: 2002-02-12
7
+
8
+ --
9
+
10
+ Ruby/Romkan is a Romaji <-> Kana conversion library for
11
+ Ruby. It can convert a Japanese Romaji string to a Japanese
12
+ Kana string or vice versa.
13
+
14
+ Tha latest version of Ruby/Romkan is available at
15
+ ((<URL:http://namazu.org/~satoru/ruby-romkan/>))
16
+ .
17
+
18
+ == API
19
+
20
+ --- String#to_kana
21
+ Convert a Kunrei or Hepburn Romaji string into a Kana string.
22
+
23
+ --- String#to_roma
24
+ Conver a Hiragana string into a Hepburn Romaji string.
25
+
26
+ --- String#to_hepburn
27
+ Convert a Kunrei Romaji string into a Hepburn Romaji string.
28
+
29
+ --- String#to_kunrei
30
+ Convert a Hepburn Romaji string into a Kunrei Romaji string.
31
+
32
+ --- String#to_kana!
33
+ Destructive version of String#to_kana.
34
+
35
+ --- String#to_roma!
36
+ Destructive version of String#to_roma.
37
+
38
+ --- String#to_hepburn!
39
+ Destructive version of String#to_hepburn.
40
+
41
+ --- String#to_kunrei!
42
+ Destructive version of String#to_kunrei.
43
+
44
+ --- String#consonant?
45
+ Return true if self is a consonant.
46
+
47
+ --- String#vowel?
48
+ Return true if self is a vowel.
49
+
50
+ --- String#expand_consonant
51
+ Expand the trailing consonant into consonants.
52
+ e.g. "z".expand_consonant => ["za", "ze", "zi", "zo", "zu"]
53
+
54
+ == Example
55
+
56
+ % irb
57
+ irb(main):001:0> $KCODE="e"
58
+ "e"
59
+ irb(main):002:0> require 'romkan'
60
+ true
61
+ irb(main):003:0> "syatyou".to_kana
62
+ "しゃちょう"
63
+ irb(main):004:0> "しゃちょう".to_roma
64
+ "shachou"
65
+ irb(main):005:0> "syatyou".to_hepburn
66
+ "shachou"
67
+
68
+ == Download
69
+
70
+ Ruby/Romkan is a free software with ABSOLUTELY NO WARRANTY under the terms of
71
+ the Ruby's licence.
72
+
73
+ * ((<URL:http://namazu.org/~satoru/ruby-romkan/ruby-romkan-0.4.tar.gz>))
74
+ * ((<URL:http://cvs.namazu.org/ruby-romkan/>))
75
+
76
+ --
77
+
78
+ satoru@namazu.org
79
+ =end
@@ -0,0 +1,76 @@
1
+ =begin
2
+ index:eJ
3
+
4
+ = Ruby/Romkan: ローマ字とひらがなを相互に変換する Ruby用のライブラリ
5
+
6
+ 最終更新日: 2002-02-12
7
+
8
+ --
9
+
10
+ Ruby/Romkan はローマ字とひらがなを相互に変換する Ruby 用のライブラリです。ロー
11
+ マ字の文字列ををひらがなの文字列に変換、およびその反対を行うことができます。
12
+
13
+ 最新版は ((<URL:http://namazu.org/~satoru/ruby-romkan/>))
14
+ から入手可能です。
15
+
16
+ == API
17
+
18
+ --- String#to_kana
19
+ 訓令式またはヘボン式のローマ字列をひらがなの文字列に変換する
20
+
21
+ --- String#to_roma
22
+ ひらがなの文字列をヘボン式のローマ字列に変換する
23
+
24
+ --- String#to_hepburn
25
+ 訓令式のローマ字列をヘボン式のローマ字列に変換する
26
+
27
+ --- String#to_kunrei
28
+ ヘボン式のローマ字列を訓令式のローマ字列に変換する
29
+
30
+ --- String#to_kana!
31
+ 破壊的な String#to_kana.
32
+
33
+ --- String#to_roma!
34
+ 破壊的な String#to_roma.
35
+
36
+ --- String#to_hepburn!
37
+ 破壊的な String#to_hepburn.
38
+
39
+ --- String#to_kunrei!
40
+ 破壊的な String#to_kunrei.
41
+
42
+ --- String#consonant?
43
+ self が子音なら true を返す
44
+
45
+ --- String#vowel?
46
+ self が母音なら true を返す
47
+
48
+ --- String#expand_consonant
49
+ self の末尾の子音を展開する
50
+ e.g. "z".expand_consonant => ["za", "ze", "zi", "zo", "zu"]
51
+ === 使用例
52
+
53
+ % irb
54
+ irb(main):001:0> $KCODE="e"
55
+ "e"
56
+ irb(main):002:0> require 'romkan'
57
+ true
58
+ irb(main):003:0> "syatyou".to_kana
59
+ "しゃちょう"
60
+ irb(main):004:0> "しゃちょう".to_roma
61
+ "shachou"
62
+ irb(main):005:0> "syatyou".to_hepburn
63
+ "shachou"
64
+
65
+ === ダウンロード
66
+
67
+ Ruby のライセンスに従ったフリーソフトウェアとして公開します。
68
+ 完全に無保証です。
69
+
70
+ * ((<URL:http://namazu.org/~satoru/ruby-romkan/ruby-romkan-0.4.tar.gz>))
71
+ * ((<URL:http://cvs.namazu.org/ruby-romkan/>))
72
+
73
+ --
74
+
75
+ satoru@namazu.org
76
+ =end
@@ -0,0 +1,306 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Ruby/Romkan - a Romaji <-> Kana conversion library for Ruby.
4
+ #
5
+ # Copyright (C) 2001 Satoru Takabayashi <satoru@namazu.org>
6
+ # All rights reserved.
7
+ # This is free software with ABSOLUTELY NO WARRANTY.
8
+ #
9
+ # You can redistribute it and/or modify it under the terms of
10
+ # the Ruby's licence.
11
+ $LOAD_PATH << File.dirname(File.expand_path(__FILE__))
12
+ require 'romkan/version'
13
+ class Array
14
+ def pairs(s=2)
15
+ 0.step(self.size-1,s){
16
+ |x| yield self.slice(x,s)
17
+ }
18
+ end
19
+ end
20
+
21
+ class String
22
+ # This table is imported from KAKASI <http://kakasi.namazu.org/> and modified.
23
+ KUNREITAB = "\
24
+ ぁ xa あ a ぃ xi い i ぅ xu
25
+ う u う゛ vu う゛ぁ va う゛ぃ vi う゛ぇ ve
26
+ う゛ぉ vo ぇ xe え e ぉ xo お o
27
+
28
+ か ka が ga き ki きゃ kya きゅ kyu
29
+ きょ kyo ぎ gi ぎゃ gya ぎゅ gyu ぎょ gyo
30
+ く ku ぐ gu け ke げ ge こ ko
31
+ ご go
32
+
33
+ さ sa ざ za し si しゃ sya しゅ syu
34
+ しょ syo じ zi じゃ zya じゅ zyu じょ zyo
35
+ す su ず zu せ se ぜ ze そ so
36
+ ぞ zo
37
+
38
+ た ta だ da ち ti ちゃ tya ちゅ tyu
39
+ ちょ tyo ぢ di ぢゃ dya ぢゅ dyu ぢょ dyo
40
+
41
+ っ xtu
42
+ っう゛ vvu っう゛ぁ vva っう゛ぃ vvi
43
+ っう゛ぇ vve っう゛ぉ vvo
44
+ っか kka っが gga っき kki っきゃ kkya
45
+ っきゅ kkyu っきょ kkyo っぎ ggi っぎゃ ggya
46
+ っぎゅ ggyu っぎょ ggyo っく kku っぐ ggu
47
+ っけ kke っげ gge っこ kko っご ggo っさ ssa
48
+ っざ zza っし ssi っしゃ ssya
49
+ っしゅ ssyu っしょ ssho
50
+ っじ zzi っじゃ zzya っじゅ zzyu っじょ zzyo
51
+ っす ssu っず zzu っせ sse っぜ zze っそ sso
52
+ っぞ zzo った tta っだ dda っち tti
53
+ っちゃ ttya っちゅ ttyu っちょ ttyo っぢ ddi
54
+ っぢゃ ddya っぢゅ ddyu っぢょ ddyo っつ ttu
55
+ っづ ddu って tte っで dde っと tto っど ddo
56
+ っは hha っば bba っぱ ppa っひ hhi
57
+ っひゃ hhya っひゅ hhyu っひょ hhyo っび bbi
58
+ っびゃ bbya っびゅ bbyu っびょ bbyo っぴ ppi
59
+ っぴゃ ppya っぴゅ ppyu っぴょ ppyo っふ hhu
60
+ っふぁ ffa っふぃ ffi っふぇ ffe っふぉ ffo
61
+ っぶ bbu っぷ ppu っへ hhe っべ bbe っぺ ppe
62
+ っほ hho っぼ bbo っぽ ppo っや yya っゆ yyu
63
+ っよ yyo っら rra っり rri っりゃ rrya
64
+ っりゅ rryu っりょ rryo っる rru っれ rre
65
+ っろ rro
66
+
67
+ つ tu づ du て te で de と to
68
+ ど do
69
+
70
+ な na に ni にゃ nya にゅ nyu にょ nyo
71
+ ぬ nu ね ne の no
72
+
73
+ は ha ば ba ぱ pa ひ hi ひゃ hya
74
+ ひゅ hyu ひょ hyo び bi びゃ bya びゅ byu
75
+ びょ byo ぴ pi ぴゃ pya ぴゅ pyu ぴょ pyo
76
+ ふ hu ふぁ fa ふぃ fi ふぇ fe ふぉ fo
77
+ ぶ bu ぷ pu へ he べ be ぺ pe
78
+ ほ ho ぼ bo ぽ po
79
+
80
+ ま ma み mi みゃ mya みゅ myu みょ myo
81
+ む mu め me も mo
82
+
83
+ ゃ xya や ya ゅ xyu ゆ yu ょ xyo
84
+ よ yo
85
+
86
+ ら ra り ri りゃ rya りゅ ryu りょ ryo
87
+ る ru れ re ろ ro
88
+
89
+ ゎ xwa わ wa ゐ wi ゑ we
90
+ を wo ん n
91
+
92
+ ん n'
93
+ でぃ dyi
94
+ ー -
95
+ ちぇ tye
96
+ っちぇ ttye
97
+ じぇ zye
98
+ "
99
+
100
+ HEPBURNTAB = "\
101
+ ぁ xa あ a ぃ xi い i ぅ xu
102
+ う u う゛ vu う゛ぁ va う゛ぃ vi う゛ぇ ve
103
+ う゛ぉ vo ぇ xe え e ぉ xo お o
104
+
105
+
106
+ か ka が ga き ki きゃ kya きゅ kyu
107
+ きょ kyo ぎ gi ぎゃ gya ぎゅ gyu ぎょ gyo
108
+ く ku ぐ gu け ke げ ge こ ko
109
+ ご go
110
+
111
+ さ sa ざ za し shi しゃ sha しゅ shu
112
+ しょ sho じ ji じゃ ja じゅ ju じょ jo
113
+ す su ず zu せ se ぜ ze そ so
114
+ ぞ zo
115
+
116
+ た ta だ da ち chi ちゃ cha ちゅ chu
117
+ ちょ cho ぢ di ぢゃ dya ぢゅ dyu ぢょ dyo
118
+
119
+ っ xtsu
120
+ っう゛ vvu っう゛ぁ vva っう゛ぃ vvi
121
+ っう゛ぇ vve っう゛ぉ vvo
122
+ っか kka っが gga っき kki っきゃ kkya
123
+ っきゅ kkyu っきょ kkyo っぎ ggi っぎゃ ggya
124
+ っぎゅ ggyu っぎょ ggyo っく kku っぐ ggu
125
+ っけ kke っげ gge っこ kko っご ggo っさ ssa
126
+ っざ zza っし sshi っしゃ ssha
127
+ っしゅ sshu っしょ ssho
128
+ っじ jji っじゃ jja っじゅ jju っじょ jjo
129
+ っす ssu っず zzu っせ sse っぜ zze っそ sso
130
+ っぞ zzo った tta っだ dda っち cchi
131
+ っちゃ ccha っちゅ cchu っちょ ccho っぢ ddi
132
+ っぢゃ ddya っぢゅ ddyu っぢょ ddyo っつ ttsu
133
+ っづ ddu って tte っで dde っと tto っど ddo
134
+ っは hha っば bba っぱ ppa っひ hhi
135
+ っひゃ hhya っひゅ hhyu っひょ hhyo っび bbi
136
+ っびゃ bbya っびゅ bbyu っびょ bbyo っぴ ppi
137
+ っぴゃ ppya っぴゅ ppyu っぴょ ppyo っふ ffu
138
+ っふぁ ffa っふぃ ffi っふぇ ffe っふぉ ffo
139
+ っぶ bbu っぷ ppu っへ hhe っべ bbe っぺ ppe
140
+ っほ hho っぼ bbo っぽ ppo っや yya っゆ yyu
141
+ っよ yyo っら rra っり rri っりゃ rrya
142
+ っりゅ rryu っりょ rryo っる rru っれ rre
143
+ っろ rro
144
+
145
+ つ tsu づ du て te で de と to
146
+ ど do
147
+
148
+ な na に ni にゃ nya にゅ nyu にょ nyo
149
+ ぬ nu ね ne の no
150
+
151
+ は ha ば ba ぱ pa ひ hi ひゃ hya
152
+ ひゅ hyu ひょ hyo び bi びゃ bya びゅ byu
153
+ びょ byo ぴ pi ぴゃ pya ぴゅ pyu ぴょ pyo
154
+ ふ fu ふぁ fa ふぃ fi ふぇ fe ふぉ fo
155
+ ぶ bu ぷ pu へ he べ be ぺ pe
156
+ ほ ho ぼ bo ぽ po
157
+
158
+ ま ma み mi みゃ mya みゅ myu みょ myo
159
+ む mu め me も mo
160
+
161
+ ゃ xya や ya ゅ xyu ゆ yu ょ xyo
162
+ よ yo
163
+
164
+ ら ra り ri りゃ rya りゅ ryu りょ ryo
165
+ る ru れ re ろ ro
166
+
167
+ ゎ xwa わ wa ゐ wi ゑ we
168
+ を wo ん n
169
+
170
+ ん n'
171
+ でぃ dyi
172
+ ー -
173
+ ちぇ che
174
+ っちぇ cche
175
+ じぇ je
176
+ "
177
+
178
+ KANROM = (kanaroma = Hash.new
179
+ (KUNREITAB + HEPBURNTAB).split(/\s+/).pairs {|x|
180
+ kana, roma = x
181
+ kanaroma[kana] = roma
182
+ }
183
+ kanaroma)
184
+
185
+ ROMKAN = (romakana = Hash.new
186
+ (KUNREITAB + HEPBURNTAB).split(/\s+/).pairs {|x|
187
+ kana, roma = x
188
+ romakana[roma] = kana
189
+ }
190
+ romakana)
191
+
192
+ # Sort in long order so that a longer Romaji sequence precedes.
193
+ ROMPAT = ROMKAN.keys.sort {|a, b| b.length <=> a.length}.join "|"
194
+
195
+ KANPAT = KANROM.keys.sort {|a, b|
196
+ b.length <=> a.length ||
197
+ KANROM[a].length <=> KANROM[b].length
198
+ }.join "|"
199
+
200
+ KUNREI = (i = 0; KUNREITAB. split(/\s+/).select {i += 1; i % 2 == 0})
201
+ HEPBURN = (i = 0; HEPBURNTAB.split(/\s+/).select {i += 1; i % 2 == 0})
202
+
203
+ KUNPAT = KUNREI.sort {|a, b| b.length <=> a.length }.join "|"
204
+ HEPPAT = HEPBURN.sort {|a, b| b.length <=> a.length }.join "|"
205
+
206
+ TO_HEPBURN = (romrom = Hash.new
207
+ KUNREI.each_with_index {|x, ix|
208
+ romrom[KUNREI[ix]] = HEPBURN[ix]}
209
+ romrom)
210
+
211
+ TO_KUNREI = (romrom = Hash.new
212
+ HEPBURN.each_with_index {|x, ix|
213
+ romrom[HEPBURN[ix]] = KUNREI[ix]}
214
+ romrom)
215
+
216
+ # FIXME: ad hod solution
217
+ # tanni => tan'i
218
+ # kannji => kanji
219
+ # hannnou => han'nou
220
+ # hannnya => han'nya
221
+ def normalize_double_n
222
+ self.gsub(/nn/, "n'").gsub(/n\'(?=[^aiueoyn]|$)/, "n")
223
+ end
224
+
225
+ def normalize_double_n!
226
+ self.gsub!(/nn/, "n'")
227
+ self.gsub!(/n\'(?=[^aiueoyn]|$)/, "n")
228
+ self
229
+ end
230
+
231
+ # Romaji -> Kana
232
+ # It can handle both Hepburn and Kunrei sequences.
233
+ def to_kana
234
+ tmp = self.normalize_double_n
235
+ tmp.gsub(/(#{ROMPAT})/) { ROMKAN[$1] }
236
+ end
237
+
238
+ # Kana -> Romaji.
239
+ # Return Hepburn sequences.
240
+ def to_roma
241
+ tmp = self.gsub(/(#{KANPAT})/) { KANROM[$1] }
242
+ tmp.gsub(/n'(?=[^aeiuoyn]|$)/, "n")
243
+ end
244
+
245
+ # Romaji -> Romaji
246
+ # Normalize into Hepburn sequences.
247
+ # e.g. kannzi -> kanji, tiezo -> chiezo
248
+ def to_hepburn
249
+ tmp = self.normalize_double_n
250
+ tmp.gsub(/\G((?:#{HEPPAT})*?)(#{KUNPAT})/) { $1 + TO_HEPBURN[$2]}
251
+ end
252
+
253
+ # Romaji -> Romaji
254
+ # Normalize into Kunrei sequences.
255
+ # e.g. kanji -> kanzi, chiezo -> tiezo
256
+ def to_kunrei
257
+ tmp = self.normalize_double_n
258
+ tmp.gsub(/\G((?:#{KUNPAT})*?)(#{HEPPAT})/) { $1 + TO_KUNREI[$2]}
259
+ end
260
+
261
+ def to_kana!
262
+ self.normalize_double_n!
263
+ self.gsub!(/(#{ROMPAT})/) { ROMKAN[$1] }
264
+ self
265
+ end
266
+
267
+ def to_roma!
268
+ self.gsub!(/(#{KANPAT})/) { KANROM[$1] }
269
+ self.gsub!(/n'(?=[^aeiuoyn]|$)/, "n")
270
+ self
271
+ end
272
+
273
+ def to_hepburn!
274
+ self.normalize_double_n!
275
+ self.gsub!(/\G((?:#{HEPPAT})*?)(#{KUNPAT})/) { $1 + TO_HEPBURN[$2]}
276
+ self
277
+ end
278
+
279
+ def to_kunrei!
280
+ tmp = self.normalize_double_n!
281
+ tmp.gsub!(/\G((?:#{KUNPAT})*?)(#{HEPPAT})/) { $1 + TO_KUNREI[$2]}
282
+ end
283
+
284
+ def consonant?
285
+ if /^[ckgszjtdhfpbmyrwxn]$/.match(self)
286
+ true
287
+ else
288
+ false
289
+ end
290
+ end
291
+
292
+ def vowel?
293
+ if /^[aeiou]$/.match(self)
294
+ true
295
+ else
296
+ false
297
+ end
298
+ end
299
+
300
+ # `z' => (za ze zi zo zu)
301
+ def expand_consonant
302
+ ROMKAN.keys.select do |x|
303
+ /^#{self}.$/ =~ x
304
+ end
305
+ end
306
+ end
@@ -0,0 +1,8 @@
1
+ module Romkan
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 4
5
+ TINY = 0
6
+ STRING = [MAJOR, MINOR, TINY].compact.join('.')
7
+ end
8
+ end
@@ -0,0 +1,145 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'romkan'
3
+ require 'test/unit'
4
+
5
+ class RomkanTest < Test::Unit::TestCase
6
+ def test_kanji
7
+ assert_equal "かんじ" , "kanji".to_kana
8
+ end
9
+
10
+ def test_kanzi
11
+ assert_equal "かんじ" , "kanzi".to_kana
12
+ end
13
+
14
+ def test_kannji
15
+ assert_equal "かんじ" , "kannji".to_kana
16
+ end
17
+
18
+ def test_chie
19
+ assert_equal "ちえ" , "chie".to_kana
20
+ end
21
+
22
+ def test_tie
23
+ assert_equal "ちえ" , "tie".to_kana
24
+ end
25
+
26
+ def test_kyouju
27
+ assert_equal "きょうじゅ" , "kyouju".to_kana
28
+ end
29
+
30
+ def test_syuukyou
31
+ assert_equal "しゅうきょう" , "syuukyou".to_kana
32
+ end
33
+
34
+ def test_shuukyou
35
+ assert_equal "しゅうきょう" , "shuukyou".to_kana
36
+ end
37
+
38
+ def test_saichuu
39
+ assert_equal "さいちゅう" , "saichuu".to_kana
40
+ end
41
+
42
+ def test_saityuu
43
+ assert_equal "さいちゅう" , "saityuu".to_kana
44
+ end
45
+
46
+ def test_cheri
47
+ assert_equal "ちぇりー" , "cheri-".to_kana
48
+ end
49
+
50
+ def test_tyeri
51
+ assert_equal "ちぇりー" , "tyeri-".to_kana
52
+ end
53
+
54
+ def test_shinrai
55
+ assert_equal "しんらい" , "shinrai".to_kana
56
+ end
57
+
58
+ def test_sinrai
59
+ assert_equal "しんらい" , "sinrai".to_kana
60
+ end
61
+
62
+ def test_hannnou
63
+ assert_equal "はんのう" , "hannnou".to_kana
64
+ end
65
+
66
+ def test_hannou
67
+ assert_equal "はんのう" , "han'nou".to_kana
68
+ end
69
+
70
+ def test_je
71
+ assert_equal "じぇ" , "je".to_kana
72
+ end
73
+
74
+ def test_ejento
75
+ assert_equal "えーじぇんと" , "e-jento".to_kana
76
+ end
77
+
78
+ def test_kannzi
79
+ assert_equal "kanji" , "kannzi".to_hepburn
80
+ end
81
+
82
+ def test_tie
83
+ assert_equal "chie" , "tie".to_hepburn
84
+ end
85
+
86
+ def test_kanji
87
+ assert_equal "kanzi" , "kanji".to_kunrei
88
+ end
89
+
90
+ def test_chie
91
+ assert_equal "tie" , "chie".to_kunrei
92
+ end
93
+
94
+ def test_かんじ
95
+ assert_equal "kanji" , "かんじ".to_roma
96
+ end
97
+
98
+ def test_ちゃう
99
+ assert_equal "chau" , "ちゃう".to_roma
100
+ end
101
+
102
+ def test_はんのう
103
+ assert_equal "han'nou" , "はんのう".to_roma
104
+ end
105
+
106
+ def test_consonant_a?
107
+ assert_equal false, "a".consonant?
108
+ end
109
+
110
+ def test_consonant_k?
111
+ assert_equal true, "k".consonant?
112
+ end
113
+
114
+ def test_consonant_k
115
+ assert_equal ["ka", "ke", "ki", "ko", "ku"], "k".expand_consonant.sort
116
+ end
117
+
118
+ def test_consonant_s
119
+ assert_equal ["sa", "se", "si", "so", "su"], "s".expand_consonant.sort
120
+ end
121
+
122
+ def test_consonant_t
123
+ assert_equal ["ta", "te", "ti", "to", "tu"], "t".expand_consonant.sort
124
+ end
125
+
126
+ def test_consonant_ky
127
+ assert_equal ["kya", "kyo", "kyu"], "ky".expand_consonant.sort
128
+ end
129
+
130
+ def test_consonant_kk
131
+ assert_equal ["kka", "kke", "kki", "kko", "kku"], "kk".expand_consonant.sort
132
+ end
133
+
134
+ def test_consonant_sh
135
+ assert_equal ["sha", "shi", "sho", "shu"], "sh".expand_consonant.sort
136
+ end
137
+
138
+ def test_consonant_sy
139
+ assert_equal ["sya", "syo", "syu"], "sy".expand_consonant.sort
140
+ end
141
+
142
+ def test_consonant_ch
143
+ assert_equal ["cha", "che", "chi", "cho", "chu"], "ch".expand_consonant.sort
144
+ end
145
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: romkan
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.4.0
6
+ platform: ruby
7
+ authors:
8
+ - Satoru Takabayashi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-17 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: |
18
+ Ruby/Romkan is a Romaji <-> Kana conversion library for
19
+ Ruby. It can convert a Japanese Romaji string to a Japanese
20
+ Kana string or vice versa.
21
+
22
+ Tha latest version of Ruby/Romkan is available at
23
+ ((<URL:http://namazu.org/~satoru/ruby-romkan/>))
24
+
25
+ email:
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - doc/romkan.ja.rd
34
+ - doc/romkan.en.rd
35
+ - lib/romkan.rb
36
+ - lib/romkan/version.rb
37
+ - test/romakn_test.rb
38
+ - ChangeLog
39
+ has_rdoc: true
40
+ homepage: http://0xcc.net/ruby-romkan/
41
+ licenses:
42
+ - Ruby's
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.6.0
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: a Romaji <-> Kana conversion library for Ruby.
67
+ test_files: []
68
+