Class: RMMSeg::Ferret::Analyzer

Inherits:
Ferret::Analysis::Analyzer
  • Object
show all
Defined in:
lib/rmmseg/ferret.rb

Overview

The Analyzer class can be used with Ferret .

Instance Method Summary collapse

Constructor Details

#initialize(&brk) ⇒ Analyzer

Construct an Analyzer. Optional block can be used to add more TokenFilters. e.g.

analyzer = RMMSeg::Ferret::Analyzer.new { |tokenizer|
  Ferret::Analysis::LowerCaseFilter.new(tokenizer)
}


17
18
19
# File 'lib/rmmseg/ferret.rb', line 17

def initialize(&brk)
  @brk = brk
end

Instance Method Details

#token_stream(field, text) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/rmmseg/ferret.rb', line 21

def token_stream(field, text)
  t = Tokenizer.new(text)
  if @brk
    @brk.call(t)
  else
    t
  end
end