Sha256: f66fc78b74111ef2cdef2053d0829278acf9185394479829ed33702cc2cc91df
Contents?: true
Size: 706 Bytes
Versions: 2
Compression:
Stored size: 706 Bytes
Contents
module MongoidSearch module Stemmers def self.available [FastStemmer, LinguaStemmer].find(&:available?) end end class FastStemmer def self.available? defined?(::Stemmer) end def initialize(*args) end def call(word) ::Stemmer.stem_word(word) end end class LinguaStemmer def self.available? defined?(::Lingua::Stemmer) end def initialize(*args, &block) @stemmer = ::Lingua::Stemmer.new(*args, &block) rescue Lingua::StemmerError => e raise unless e.message.include?("not available") end def call(word) if @stemmer @stemmer.stem(word) else word end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid_search2-0.3.0 | lib/mongoid_search/stemmers.rb |
mongoid_search2-0.3.0.rc.1 | lib/mongoid_search/stemmers.rb |