pinyin_to_kana 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 12fc8bceac87a540871cac09d6fb3d4bada1f7cc7d0781131a43c16ac3afc52e
4
+ data.tar.gz: 1d6e6d4979a2f356cca9dac54a798281cf04c6b80b4004edbc1fdeffb44b46e7
5
+ SHA512:
6
+ metadata.gz: '0803b4e626bc3a961eb8da75168a0b114143a499f49635d567f5a6c0c60c9960b398c3a0e9f0d7deeba239720854804d6343d638f81408a6bd6975d433d5500f'
7
+ data.tar.gz: 13fb22128a0c8589d601c8b4f83266f5aa6a69e4c802e3a44d4bb1246f29c27f52c23340ef540d94bbb2e42a1845e67dbd04a3cffc3156ae41afc317f9a50c5e
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pinyin_to_kana.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pinyin_to_kana (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.14.0)
10
+ rake (10.5.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 2.0)
17
+ minitest (~> 5.0)
18
+ pinyin_to_kana!
19
+ rake (~> 10.0)
20
+
21
+ BUNDLED WITH
22
+ 2.0.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Kazato Sugimoto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # PinyinToKana
2
+
3
+ Translate Chinese pinyin to Japanese kana.
4
+
5
+ Mapping from pinyin to kana is based on the guideline [中国語音節表記ガイドライン 平凡社版](http://cn.heibonsha.co.jp/)
6
+
7
+ ```ruby
8
+ PinyinToKana.pinyin_to_kana('xi jin ping')
9
+ #=> 'シージンピン'
10
+ ```
11
+
12
+ You can translate chinese hanzi to kana with [chinese_pinyin](https://github.com/flyerhzm/chinese_pinyin) gem:
13
+
14
+ ```ruby
15
+ Pinyin.t('習近平')
16
+ #=> "xi jin ping"
17
+
18
+ PinyinToKana.pinyin_to_kana(Pinyin.t('習近平'))
19
+ #=> 'シージンピン'
20
+ ```
21
+
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```ruby
28
+ gem 'pinyin_to_kana'
29
+ ```
30
+
31
+ And then execute:
32
+
33
+ $ bundle
34
+
35
+ Or install it yourself as:
36
+
37
+ $ gem install pinyin_to_kana
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pinyin_to_kana"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ require "pinyin_to_kana/version"
2
+
3
+ class PinyinToKana
4
+ def self.pinyin_to_kana(pinyin)
5
+ pinyin.downcase.split(' ').map { |c| mapping[c] || c }.join('')
6
+ end
7
+
8
+ def self.mapping
9
+ @mapping ||= begin
10
+ path = File.join(__dir__, 'pinyin_to_kana', 'mapping.tsv')
11
+ text = File.read(path)
12
+ text.split("\n").map{|line| line.split("\t")}.to_h
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,408 @@
1
+ a アー
2
+ ai アイ
3
+ an アン
4
+ ang アン
5
+ ao アオ
6
+ ba バー
7
+ bai バイ
8
+ ban バン
9
+ bang バン
10
+ bao バオ
11
+ bei ベイ
12
+ ben ベン
13
+ beng ボン
14
+ bi ビー
15
+ bian ビエン
16
+ biao ビアオ
17
+ bie ビエ
18
+ bin ビン
19
+ bing ビン
20
+ bo ボー
21
+ bu ブー
22
+ ca ツァー
23
+ cai ツァイ
24
+ can ツァン
25
+ cang ツァン
26
+ cao ツァオ
27
+ ce ツォー
28
+ cen ツェン
29
+ ceng ツォン
30
+ cha チャー
31
+ chai チャイ
32
+ chan チャン
33
+ chang チャン
34
+ chao チャオ
35
+ che チョー
36
+ chen チェン
37
+ cheng チョン
38
+ chi チー
39
+ chong チョン
40
+ chou チョウ
41
+ chu チュー
42
+ chua チュワ
43
+ chuai チュワイ
44
+ chuan チュワン
45
+ chuang チュアン
46
+ chui チュイ
47
+ chun チュン
48
+ chuo チュオ
49
+ ci ツー
50
+ cong ツォン
51
+ cou ツォウ
52
+ cu ツー
53
+ cuan ツワン
54
+ cui ツイ
55
+ cun ツン
56
+ cuo ツオ
57
+ da ダー
58
+ dai ダイ
59
+ dan ダン
60
+ dang ダン
61
+ dao ダオ
62
+ de ドー
63
+ dei デイ
64
+ den デン
65
+ deng ドン
66
+ di ディー
67
+ dian ディエン
68
+ diao ディアオ
69
+ die ディエ
70
+ ding ディン
71
+ diu ディウ
72
+ dong ドン
73
+ dou ドウ
74
+ du ドゥー
75
+ duan ドワン
76
+ dui ドゥイ
77
+ dun ドゥン
78
+ duo ドゥオ
79
+ e オー
80
+ ei エイ
81
+ en エン
82
+ eng オン
83
+ er アル
84
+ fa ファー
85
+ fan ファン
86
+ fang ファン
87
+ fei フェイ
88
+ fen フェン
89
+ feng フォン
90
+ fo フォー
91
+ fou フォウ
92
+ fu フー
93
+ ga ガー
94
+ gai ガイ
95
+ gan ガン
96
+ gang ガン
97
+ gao ガオ
98
+ ge ゴー
99
+ gei ゲイ
100
+ gen ゲン
101
+ geng ゴン
102
+ gong ゴン
103
+ gou ゴウ
104
+ gu グー
105
+ gua グワ
106
+ guai グワイ
107
+ guan グワン
108
+ guang グアン
109
+ gui グイ
110
+ gun グン
111
+ guo グオ
112
+ ha ハー
113
+ hai ハイ
114
+ han ハン
115
+ hang ハン
116
+ hao ハオ
117
+ he ホー
118
+ hei ヘイ
119
+ hen ヘン
120
+ heng ホン
121
+ hong ホン
122
+ hou ホウ
123
+ hu フー
124
+ hua ホワ
125
+ huai ホワイ
126
+ huan ホワン
127
+ huang ホアン
128
+ hui フイ
129
+ hun フン
130
+ huo フオ
131
+ ji ジー
132
+ jia ジア
133
+ jian ジエン
134
+ jiang ジアン
135
+ jiao ジアオ
136
+ jie ジエ
137
+ jin ジン
138
+ jing ジン
139
+ jiong ジオン
140
+ jiu ジウ
141
+ ju ジュー
142
+ juan ジュエン
143
+ jue ジュエ
144
+ jun ジュン
145
+ ka カー
146
+ kai カイ
147
+ kan カン
148
+ kang カン
149
+ kao カオ
150
+ ke コー
151
+ kei ケイ
152
+ ken ケン
153
+ keng コン
154
+ kong コン
155
+ kou コウ
156
+ ku クー
157
+ kua クワ
158
+ kuai クワイ
159
+ kuan クワン
160
+ kuang クアン
161
+ kui クイ
162
+ kun クン
163
+ kuo クオ
164
+ la ラー
165
+ lai ライ
166
+ lan ラン
167
+ lang ラン
168
+ lao ラオ
169
+ le ロー
170
+ lei レイ
171
+ leng ロン
172
+ li リー
173
+ lia リア
174
+ lian リエン
175
+ liang リアン
176
+ liao リアオ
177
+ lie リエ
178
+ lin リン
179
+ ling リン
180
+ liu リウ
181
+ lo ロー
182
+ long ロン
183
+ lou ロウ
184
+ lu ルー
185
+ lü リュー
186
+ luan ルワン
187
+ lüe リュエ
188
+ lun ルン
189
+ luo ルオ
190
+ ma マー
191
+ mai マイ
192
+ man マン
193
+ mang マン
194
+ mao マオ
195
+ me マ
196
+ mei メイ
197
+ men メン
198
+ meng モン
199
+ mi ミー
200
+ mian ミエン
201
+ miao ミアオ
202
+ mie ミエ
203
+ min ミン
204
+ ming ミン
205
+ miu ミウ
206
+ mo モー
207
+ mou モウ
208
+ mu ムー
209
+ na ナー
210
+ nai ナイ
211
+ nan ナン
212
+ nang ナン
213
+ nao ナオ
214
+ ne ノー
215
+ nei ネイ
216
+ nen ネン
217
+ neng ノン
218
+ ni ニー
219
+ nian ニエン
220
+ niang ニアン
221
+ niao ニアオ
222
+ nie ニエ
223
+ nin ニン
224
+ ning ニン
225
+ niu ニウ
226
+ nong ノン
227
+ nou ノウ
228
+ nu ヌー
229
+ nü ニュー
230
+ nuan ヌワン
231
+ nüe ニュエ
232
+ nuo ヌオ
233
+ o オー
234
+ ou オウ
235
+ pa パー
236
+ pai パイ
237
+ pan パン
238
+ pang パン
239
+ pao パオ
240
+ pei ペイ
241
+ pen ペン
242
+ peng ポン
243
+ pi ピー
244
+ pian ピエン
245
+ piao ピアオ
246
+ pie ピエ
247
+ pin ピン
248
+ ping ピン
249
+ po ポー
250
+ pou ポウ
251
+ pu プー
252
+ qi チー
253
+ qia チア
254
+ qian チエン
255
+ qiang チアン
256
+ qiao チアオ
257
+ qie チエ
258
+ qin チン
259
+ qing チン
260
+ qiong チオン
261
+ qiu チウ
262
+ qu チュー
263
+ quan チュエン
264
+ que チュエ
265
+ qun チュン
266
+ ran ラン
267
+ rang ラン
268
+ rao ラオ
269
+ re ロー
270
+ ren レン
271
+ reng ロン
272
+ ri リー
273
+ rong ロン
274
+ rou ロウ
275
+ ru ルー
276
+ ruan ルワン
277
+ rui ルイ
278
+ run ルン
279
+ ruo ルオ
280
+ sa サー
281
+ sai サイ
282
+ san サン
283
+ sang サン
284
+ sao サオ
285
+ se ソー
286
+ sen セン
287
+ seng ソン
288
+ sha シャー
289
+ shai シャイ
290
+ shan シャン
291
+ shang シャン
292
+ shao シャオ
293
+ she ショー
294
+ shei シェイ
295
+ shen シェン
296
+ sheng ション
297
+ shi シー
298
+ shou ショウ
299
+ shu シュー
300
+ shua シュワ
301
+ shuai シュワイ
302
+ shuan シュワン
303
+ shuang シュアン
304
+ shui シュイ
305
+ shun シュン
306
+ shuo シュオ
307
+ si スー
308
+ song ソン
309
+ sou ソウ
310
+ su スー
311
+ suan スワン
312
+ sui スイ
313
+ sun スン
314
+ suo スオ
315
+ ta ター
316
+ tai タイ
317
+ tan タン
318
+ tang タン
319
+ tao タオ
320
+ te トー
321
+ teng トン
322
+ ti ティー
323
+ tian ティエン
324
+ tiao ティアオ
325
+ tie ティエ
326
+ ting ティン
327
+ tong トン
328
+ tou トウ
329
+ tu トゥー
330
+ tuan トワン
331
+ tui トゥイ
332
+ tun トゥン
333
+ tuo トゥオ
334
+ wa ワー
335
+ wai ワイ
336
+ wan ワン
337
+ wang ワン
338
+ wei ウェイ
339
+ wen ウェン
340
+ weng ウォン
341
+ wo ウオ
342
+ wu ウー
343
+ xi シー
344
+ xia シア
345
+ xian シエン
346
+ xiang シアン
347
+ xiao シアオ
348
+ xie シエ
349
+ xin シン
350
+ xing シン
351
+ xiong シオン
352
+ xiu シウ
353
+ xu シュー
354
+ xuan シュエン
355
+ xue シュエ
356
+ xun シュン
357
+ ya ヤー
358
+ yan イエン
359
+ yang ヤン
360
+ yao ヤオ
361
+ ye イエ
362
+ yi イー
363
+ yin イン
364
+ ying イン
365
+ yo ヨー
366
+ yong ヨン
367
+ you ヨウ
368
+ yu ユー
369
+ yuan ユエン
370
+ yue ユエ
371
+ yun ユン
372
+ za ザー
373
+ zai ザイ
374
+ zan ザン
375
+ zang ザン
376
+ zao ザオ
377
+ ze ゾー
378
+ zei ゼイ
379
+ zen ゼン
380
+ zeng ゾン
381
+ zha ジャー
382
+ zhai ジャイ
383
+ zhan ジャン
384
+ zhang ジャン
385
+ zhao ジャオ
386
+ zhe ジョー
387
+ zhei ジェイ
388
+ zhen ジェン
389
+ zheng ジョン
390
+ zhi ジー
391
+ zhong ジョン
392
+ zhou ジョウ
393
+ zhu ジュー
394
+ zhua ジュワ
395
+ zhuai ジュワイ
396
+ zhuan ジュワン
397
+ zhuang ジュアン
398
+ zhui ジュイ
399
+ zhun ジュン
400
+ zhuo ジュオ
401
+ zi ズー
402
+ zong ゾン
403
+ zou ゾウ
404
+ zu ズー
405
+ zuan ズワン
406
+ zui ズイ
407
+ zun ズン
408
+ zuo ズオ
@@ -0,0 +1,3 @@
1
+ class PinyinToKana
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "pinyin_to_kana/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pinyin_to_kana"
7
+ spec.version = PinyinToKana::VERSION
8
+ spec.authors = ["Kazato Sugimoto"]
9
+ spec.email = ["uiureo@gmail.com"]
10
+
11
+ spec.summary = %q{Translate Chinese pinyin to Japanese kana}
12
+ spec.description = %q{Translate Chinese pinyin to Japanese kana}
13
+ spec.license = "MIT"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pinyin_to_kana
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kazato Sugimoto
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Translate Chinese pinyin to Japanese kana
56
+ email:
57
+ - uiureo@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/pinyin_to_kana.rb
72
+ - lib/pinyin_to_kana/mapping.tsv
73
+ - lib/pinyin_to_kana/version.rb
74
+ - pinyin_to_kana.gemspec
75
+ homepage:
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.7.6
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Translate Chinese pinyin to Japanese kana
99
+ test_files: []