Class: XapianDb::Repositories::Stemmer
- Inherits:
-
Object
- Object
- XapianDb::Repositories::Stemmer
- Defined in:
- lib/xapian_db/repositories/stemmer.rb
Overview
The stemmer is a repository that manages stemmers for the supported languges
Class Method Summary collapse
-
.stemmer_for(iso_cd) ⇒ Xapian::Stem
Get or build the stemmer for a language.
Class Method Details
.stemmer_for(iso_cd) ⇒ Xapian::Stem
Get or build the stemmer for a language
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xapian_db/repositories/stemmer.rb', line 16 def stemmer_for(iso_cd) @stemmers ||= {} return nil if iso_cd.nil? key = iso_cd.to_sym # Do we already have a stemmer for this language? return @stemmers[key] unless @stemmers[key].nil? # Do we support this language? unless (LANGUAGE_MAP.keys + [:none]).include?(key) raise ArgumentError.new "Language #{iso_cd} is not supported by XapianDb (remember to use the language iso codes)" end # Let's build the stemmer @stemmers[key] = Xapian::Stem.new(key.to_s) end |