Class: WordBloom::FilterBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/word-bloom/filter-builder.rb

Constant Summary collapse

BITFIELD_WIDTH =
2_000_000

Instance Method Summary collapse

Constructor Details

#initialize(source_path) ⇒ FilterBuilder

Returns a new instance of FilterBuilder.



5
6
7
# File 'lib/word-bloom/filter-builder.rb', line 5

def initialize(source_path)
  @filename = source_path
end

Instance Method Details

#filter_from_dictionaryObject



9
10
11
12
13
# File 'lib/word-bloom/filter-builder.rb', line 9

def filter_from_dictionary
  filter = BloominSimple.new(BITFIELD_WIDTH, &HASHER)
  File.open(@filename).each { |word| filter.add(word) }
  filter
end