Class: Fluent::KuromojiOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_kuromoji.rb

Instance Method Summary collapse

Constructor Details

#initializeKuromojiOutput

Returns a new instance of KuromojiOutput.



10
11
12
13
# File 'lib/fluent/plugin/out_kuromoji.rb', line 10

def initialize
  super
  require 'kuromoji'
end

Instance Method Details

#configure(conf) ⇒ Object



15
16
17
18
# File 'lib/fluent/plugin/out_kuromoji.rb', line 15

def configure(conf)
  super
  @core = Kuromoji::Core.new(@dictionary_path)
end

#emit(tag, es, chain) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/fluent/plugin/out_kuromoji.rb', line 20

def emit(tag, es, chain)
  es.each do |time, record|
    tokens = @core.tokenize_with_hash(record[@target_key])
    tokens.each do |token|
      Fluent::Engine.emit(@add_tag_prefix + '.' + tag, time, token)
    end
  end
  chain.next
end