class PinyinToKana
Constants
- VERSION
Public Class Methods
mapping()
click to toggle source
# File lib/pinyin_to_kana.rb, line 8 def self.mapping @mapping ||= begin path = File.join(__dir__, 'pinyin_to_kana', 'mapping.tsv') text = File.read(path) text.split("\n").map{|line| line.split("\t")}.to_h end end
pinyin_to_kana(pinyin)
click to toggle source
# File lib/pinyin_to_kana.rb, line 4 def self.pinyin_to_kana(pinyin) pinyin.downcase.split(' ').map { |c| mapping[c] || c }.join('') end