Sha256: 801a69a2aa2340d928253eb40d10165ab505539f7b3cd23b629bacebc7676582
Contents?: true
Size: 831 Bytes
Versions: 1
Compression:
Stored size: 831 Bytes
Contents
require "reading_kanji_in_kana/version" require "natto" module ReadingKanjiInKana class Kanji attr_accessor :opt def initialize(option=nil) if option == nil || option == '' else @opt = option.dup end end def to_yomi(kanji=nil) if kanji == nil || kanji == '' 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 || opt == '' 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.1 | lib/reading_kanji_in_kana.rb |