Sha256: b776e8d314d6e174adeadc958f9c53d21c991bb63aaf16459046f520b801bdb0

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

# coding: UTF-8
module Fluent
  class KuromojiOutput < Output
    Fluent::Plugin.register_output('kuromoji', self)

    config_param :target_key, :string
    config_param :add_tag_prefix, :string
    config_param :dictionary_path, :string

    def initialize
      super
      require 'kuromoji'
    end

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-kuromoji-0.0.1 lib/fluent/plugin/out_kuromoji.rb