Class: MiniSearch::StemmerFilter
- Inherits:
-
Object
- Object
- MiniSearch::StemmerFilter
- Defined in:
- lib/mini_search/stemmer_filter.rb
Instance Method Summary collapse
- #execute(tokens) ⇒ Object
-
#initialize(stemmer) ⇒ StemmerFilter
constructor
A new instance of StemmerFilter.
Constructor Details
#initialize(stemmer) ⇒ StemmerFilter
Returns a new instance of StemmerFilter.
5 6 7 |
# File 'lib/mini_search/stemmer_filter.rb', line 5 def initialize(stemmer) @stemmer = stemmer end |
Instance Method Details
#execute(tokens) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/mini_search/stemmer_filter.rb', line 9 def execute(tokens) return tokens unless @stemmer new_tokens = tokens.map do |token| @stemmer.stem(token) end (new_tokens + tokens).uniq end |