Module: Onena::Util

Defined in:
lib/onena/util.rb

Class Method Summary collapse

Class Method Details

.matches(tock_list: nil, float_list: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/onena/util.rb', line 5

def self.matches(tock_list: nil, float_list: nil)
  white = Text::WhiteSimilarity.new
  # Remove exact matches
  tock = tock_list - float_list
  float = float_list - tock_list
  matches = tock.map do |tock_item|
    float.map do |float_item|
      {
        :float => float_item,
        :tock => tock_item,
        :distance => Text::Levenshtein.distance(float_item, tock_item),
        :similarity => white.similarity(float_item, tock_item)
      }
    end
  end
  matches.flatten.compact
end