lib/suri_lang/translator.rb in suri_lang-0.1.0 vs lib/suri_lang/translator.rb in suri_lang-0.1.1

- old
+ new

@@ -11,19 +11,19 @@ 'ください,動詞': 'くだサイ', } def self.wakati(text) nm = Natto::MeCab.new('-Owakati') - nm.enum_parse(text).select{|n| n.is_nor?}.map(&:surface) + nm.enum_parse(text).select{|n| !n.is_eos?}.map(&:surface) end def self.katakana(word, word_class) DICTIONARY["#{word},#{word_class}".to_sym] || word end def self.translate(text) nm = Natto::MeCab.new('-F%m,%f[0]') - features = nm.enum_parse(text).select{|n| n.is_nor?}.map{|n| n.feature.split(',')} + features = nm.enum_parse(text).select{|n| !n.is_eos?}.map{|n| n.feature.split(',')} words = features.map{|feature| katakana(feature[0], feature[1])} words.join end end end