rifle 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +2 -1
  2. data/lib/rifle.rb +9 -6
  3. data/lib/rifle/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -31,7 +31,7 @@ urn and a payload
31
31
  # Payloads
32
32
 
33
33
  Payloads are expected to be hashes, identified by a company-wide unique id (a urn). These are indexed and can
34
- be searched by metaphone. That is, the search term need not be exact.
34
+ be searched by metaphone if fuzzy_matching is enabled. That is, the search term need not be exact.
35
35
 
36
36
  E.g, given the following payload
37
37
 
@@ -54,6 +54,7 @@ You can supply a rifle_config.rb initializer with the following options. Default
54
54
  Rifle.settings.resque_queue # = :rifle
55
55
  Rifle.settings.redis # = Redis.current (used both by the client in "inline mode" and the server in "standalone mode")
56
56
  Rifle.settings.use_rest_server # = nil
57
+ Rifle.settings.fuzzy_matching # = false
57
58
 
58
59
  # Server deployment modes
59
60
 
@@ -64,6 +64,7 @@ module Rifle
64
64
  urns = nil
65
65
  metaphones.each do |metaphone|
66
66
  new_urns = get_urns_for_metaphone(metaphone)
67
+ p metaphone
67
68
  urns = urns.nil? ? Set.new(new_urns) : urns.intersection(new_urns)
68
69
  end
69
70
  urns ||= Set.new
@@ -103,15 +104,17 @@ module Rifle
103
104
 
104
105
  def get_words_array_from_text(text)
105
106
  return [] if !text.is_a?(String)
106
- words = text.downcase.split(/[^a-zA-Z0-9]/).select { |w| w.length >= Rifle.settings.min_word_length }
107
- return words
107
+ text.downcase.split(/[^a-zA-Z0-9]/).select { |w| w.length >= Rifle.settings.min_word_length }
108
108
  end
109
109
 
110
110
  def get_metaphones_from_word_set(words)
111
- # Get just text words (no numbers)
112
- words.keep_if { |w|
113
- w.to_f == 0
114
- }
111
+ # Add extra search terms. EG, other phone number layouts
112
+ words = Set.new(words.map { |w|
113
+ # Here we have to strip all the front zeros and replace with 44.
114
+ # Weirdly, the +can be ignored, it is not included in Redis keys.
115
+ w.start_with?('0') ? "44#{w[1..-1]}" : w
116
+ })
117
+
115
118
  # Removed ignored words
116
119
  words.subtract Rifle.settings.ignored_words
117
120
  # Get the parts
@@ -1,3 +1,3 @@
1
1
  module Rifle
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rifle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: