class SuriLang::Translator
Constants
- DICTIONARY
Public Class Methods
translate(text)
click to toggle source
# File lib/suri_lang/translator.rb, line 51 def self.translate(text) nm = Natto::MeCab.new('-F%m,%f[0]') features = nm.enum_parse(text).select{|n| !n.is_eos?}.map{|n| n.feature} features.map{|feature| to_suri_word(feature)}.join end
wakati(text)
click to toggle source
# File lib/suri_lang/translator.rb, line 46 def self.wakati(text) nm = Natto::MeCab.new('-Owakati') nm.enum_parse(text).select{|n| !n.is_eos?}.map(&:surface) end
Private Class Methods
to_suri_word(feature)
click to toggle source
# File lib/suri_lang/translator.rb, line 60 def self.to_suri_word(feature) DICTIONARY[feature.to_sym] || feature.split(',')[0] end