rifle 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/rifle.rb +9 -6
- data/lib/rifle/version.rb +1 -1
- 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
|
|
data/lib/rifle.rb
CHANGED
@@ -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
|
-
|
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
|
-
#
|
112
|
-
words.
|
113
|
-
|
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
|
data/lib/rifle/version.rb
CHANGED