Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/saitonized.rb

Constant Summary collapse

KAKU_PARTICLE =
%W[      より から  ].freeze
SETSUZOKU_PARTICLE =
%W[   ても でも けれど けれども ながら  のに ので から など    たり だり なり つつ ものの ところで].freeze
FUKU_PARTICLE =
%W[  こそ さえ でも ばかり など  だって しか まで だけ ほど きり ぎり くらい ぐらい なり やら だの なんて ずつ とか すら].freeze
SHUU_PARTICLE =
%W[     とも なあ   ねえ こと   かしら もの ものか].freeze

Instance Method Summary collapse

Instance Method Details

#saitonizedObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/saitonized.rb', line 15

def saitonized
  natto_mecab = Natto::MeCab.new
  res = ''
  natto_mecab.parse(self) do |nm|
    res += case nm.feature
    when /格助詞/ then KAKU_PARTICLE.sample
    when /接続助詞/ then SETSUZOKU_PARTICLE.sample
    when /副助詞/ then FUKU_PARTICLE.sample
    when /終助詞/ then SHUU_PARTICLE.sample
    else nm.surface
    end
  end
  res
end