Class: Stopwords::Snowball::WordSieve

Inherits:
Object
  • Object
show all
Defined in:
lib/stopwords/snowball/wordsieve.rb

Instance Method Summary collapse

Constructor Details

#initialize(custom_list = []) ⇒ WordSieve

Returns a new instance of WordSieve.



4
5
6
7
8
9
# File 'lib/stopwords/snowball/wordsieve.rb', line 4

def initialize(custom_list = [])
  @filters = Dir["#{File.dirname(__FILE__)}/locales/*.csv"].each_with_object({}) do |file, filters|
    lang = File.basename(file, '.csv')
    filters[lang.to_sym] = Stopwords::Snowball::Filter.new lang, custom_list
  end
end

Instance Method Details

#filter(args = {}) ⇒ Object



15
16
17
# File 'lib/stopwords/snowball/wordsieve.rb', line 15

def filter(args = {})
  args[:lang] ? @filters[args[:lang]].filter(args[:words]) : args[:words]
end

#stopword?(args = {}) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/stopwords/snowball/wordsieve.rb', line 11

def stopword?(args = {})
  args[:lang] ? @filters[args[:lang]].stopword?(args[:word]) : false
end