class XapianDb::Repositories::Stopper
The stopper is a repository that manages stoppers for the supported languges @author Gernot Kogler
Public Class Methods
Source
# File lib/xapian_db/repositories/stopper.rb 16 def stopper_for(iso_cd) 17 @stoppers ||= {} 18 return nil if iso_cd.nil? 19 key = iso_cd.to_sym 20 21 # Do we already have a stopper for this language? 22 return @stoppers[key] unless @stoppers[key].nil? 23 24 # build the stopper 25 stopper = Xapian::SimpleStopper.new 26 stopwords_file = File.join(File.dirname(__FILE__), '../stopwords', "#{iso_cd}.txt") 27 28 return nil unless File.exist? stopwords_file 29 30 open(stopwords_file, "r") do |file| 31 file.each do |word| 32 stopper.add word.chomp 33 end 34 end 35 @stoppers[key] = stopper 36 end
Get or build the stopper for a language @param [Symbol, String] iso_cd The iso code for the language (:en, :de …) @return [Xapian::SimpleStopper] The Stopper
for this lanugage