Class: MongoidSearch::LinguaStemmer
- Inherits:
-
Object
- Object
- MongoidSearch::LinguaStemmer
- Defined in:
- lib/mongoid_search/stemmers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(word) ⇒ Object
-
#initialize(*args, &block) ⇒ LinguaStemmer
constructor
A new instance of LinguaStemmer.
Constructor Details
#initialize(*args, &block) ⇒ LinguaStemmer
Returns a new instance of LinguaStemmer.
26 27 28 29 30 |
# File 'lib/mongoid_search/stemmers.rb', line 26 def initialize(*args, &block) @stemmer = ::Lingua::Stemmer.new(*args, &block) rescue Lingua::StemmerError => e raise unless e..include?("not available") end |
Class Method Details
.available? ⇒ Boolean
22 23 24 |
# File 'lib/mongoid_search/stemmers.rb', line 22 def self.available? defined?(::Lingua::Stemmer) end |
Instance Method Details
#call(word) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/mongoid_search/stemmers.rb', line 32 def call(word) if @stemmer @stemmer.stem(word) else word end end |