Module: Lingua

Defined in:
lib/lingua/stemmer.rb

Defined Under Namespace

Classes: Stemmer

Class Method Summary collapse

Class Method Details

.stemmer(o, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lingua/stemmer.rb', line 8

def self.stemmer(o, options={})
  stemmer = Stemmer.new(options)

  words = Array(o).map { |e| e.to_s }

  results = []
  words.each do |word|
    result = stemmer.stem(word)
    if block_given?
      yield result
    else
      results << result
    end
  end

  return stemmer if block_given?
  results.length == 1 ? results[0] : results
end