Class: Stopwords::Snowball::WordSieve
- Inherits:
-
Object
- Object
- Stopwords::Snowball::WordSieve
- Defined in:
- lib/stopwords/snowball/wordsieve.rb
Instance Method Summary collapse
- #filter(args = {}) ⇒ Object
-
#initialize(custom_list = []) ⇒ WordSieve
constructor
A new instance of WordSieve.
- #stopword?(args = {}) ⇒ Boolean
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').to_sym filters[lang] = 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
11 12 13 |
# File 'lib/stopwords/snowball/wordsieve.rb', line 11 def stopword? args={} args[:lang] ? @filters[args[:lang]].stopword?(args[:word] ) : false end |