Method: EightCorner::StringMapper#initialize

Defined in:
lib/eight_corner/string_mapper.rb

#initialize(options = {}) ⇒ StringMapper

Returns a new instance of StringMapper.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/eight_corner/string_mapper.rb', line 7

def initialize(options={})
  defaults = {
    group_count: 7,
    min_group_size: 3
  }
  Base.validate_options!(options, defaults)
  options = defaults.merge(options)

  @group_count = options[:group_count]
  @group_max_idx = @group_count - 1
  @min_group_size = options[:min_group_size]

  @frequencies = {"E"=>0.103202, "A"=>0.095238, "R"=>0.092638, "N"=>0.087925, "O"=>0.075898, "S"=>0.065659, "L"=>0.064196, "I"=>0.046481, "T"=>0.040793, "H"=>0.03868, "C"=>0.038193, "D"=>0.03413, "M"=>0.033317, "B"=>0.023891, "G"=>0.023566, "Y"=>0.022103, "U"=>0.021615, "W"=>0.019178, "K"=>0.016252, "P"=>0.015602, "F"=>0.011539, "V"=>0.010889, "Z"=>0.010076, "J"=>0.003738, " "=>0.00195, "X"=>0.00195, "Q"=>0.000975}
end