Class: XapianFu::StemFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian_fu/xapian_doc.rb

Class Method Summary collapse

Class Method Details

.stemmer_for(stemmer) ⇒ Object

Return a Xapian::Stem object for the given option. Accepts any string that the Xapian::Stem class accepts (Either the English name for the language or the two letter ISO639 code).

If given false or nil, will return a “none” stemmer.

It will also accept and return an existing Xapian::Stem object.


321
322
323
324
325
326
327
328
329
# File 'lib/xapian_fu/xapian_doc.rb', line 321

def self.stemmer_for(stemmer)
  if stemmer.is_a? Xapian::Stem
    stemmer
  elsif stemmer.is_a?(String) or stemmer.is_a?(Symbol)
    Xapian::Stem.new(stemmer.to_s)
  else
    Xapian::Stem.new("none")
  end
end