module Mongoid::FTS::Stemming

Public Instance Methods

for(*args, &block)
Alias for: stem
stem(*args, &block) click to toggle source
# File lib/mongoid-fts/stemming.rb, line 6
def stem(*args, &block)
  words = args.join(' ').strip.split(/\s+/)
  list = []

  words.each do |word|
    stem = word.stem.downcase
    next if Stopwords.stopword?(word)
    next if Stopwords.stopword?(stem)
    block ? block.call(stem) : list.push(stem)
  end

  block ? nil : list
end
Also aliased as: for