Sha256: 33923a460b1bcd61236235596364c05aec393ed4385e2b7e2c32908df10554db
Contents?: true
Size: 762 Bytes
Versions: 1
Compression:
Stored size: 762 Bytes
Contents
require "reading_kanji_in_kana/version" require "natto" module ReadingKanjiInKana class Kanji attr_accessor :opt def initialize(option=nil) @opt = option.dup unless option == nil end def to_yomi(kanji=nil) if kanji == nil p 'ReadingKanjiInKana::Kanji::kanji_to_yomi error: the input string is null. please input `kanji` string.' return nil end text = kanji.dup if opt == nil nm = Natto::MeCab.new else nm = Natto::MeCab.new(opt) end str_ary = [] nm.parse(text) do |n| str = n.feature.split(',')[7] str_ary.push("#{str}") unless str.match(/\*/) end str_ary.uniq! yomi = str_ary.join(',') yomi end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reading_kanji_in_kana-0.0.2 | lib/reading_kanji_in_kana.rb |