fuzz_ball 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/fuzz_ball/duple_index/DupleIndex.c +8 -2
- data/lib/fuzz_ball.rb +2 -0
- data/lib/fuzz_ball/searcher.rb +12 -11
- metadata +2 -2
@@ -223,7 +223,7 @@ VALUE method_match(VALUE self, VALUE needle) {
|
|
223
223
|
* duple to match since it appears before 'ab' in the indexed string,
|
224
224
|
* whereas it appears after in the needle string.
|
225
225
|
*/
|
226
|
-
if ((match->last_matched_position < pos->pos) && (match->last_matched_ca != c_a) && (match->last_matched_cb != c_b)) {
|
226
|
+
if ((match->last_matched_position < pos->pos)) { // && (match->last_matched_ca != c_a) && (match->last_matched_cb != c_b)) {
|
227
227
|
update_match( match, pos->pos, c_a, c_b );
|
228
228
|
}
|
229
229
|
}
|
@@ -268,7 +268,13 @@ struct match *create_match(int id, int pos, int c_a, int c_b) {
|
|
268
268
|
}
|
269
269
|
|
270
270
|
void update_match(struct match* match, int pos, int c_a, int c_b) {
|
271
|
-
|
271
|
+
|
272
|
+
if (match->last_matched_position == pos-1) {
|
273
|
+
match->n_matches += 2;
|
274
|
+
} else {
|
275
|
+
match->n_matches++;
|
276
|
+
}
|
277
|
+
|
272
278
|
match->last_matched_position = pos;
|
273
279
|
match->last_matched_ca = c_a;
|
274
280
|
match->last_matched_cb = c_b;
|
data/lib/fuzz_ball.rb
CHANGED
data/lib/fuzz_ball/searcher.rb
CHANGED
@@ -8,7 +8,7 @@ module FuzzBall
|
|
8
8
|
@files = files
|
9
9
|
@files_array = files.collect {|f| str2arr(f)}
|
10
10
|
|
11
|
-
|
11
|
+
index_duples!
|
12
12
|
end
|
13
13
|
|
14
14
|
def add( str )
|
@@ -56,19 +56,20 @@ module FuzzBall
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
def index_duples!
|
60
|
+
@duple_index = DupleIndex.new
|
61
|
+
files_array.each_with_index do |str, index|
|
62
|
+
duple_index.add(index, str)
|
63
|
+
end
|
64
|
+
end
|
65
65
|
|
66
66
|
def decimate_strings!(needle)
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
matches_by_score = duple_index.match(needle)
|
68
|
+
|
69
|
+
max_keys = matches_by_score.keys.sort.last(2)
|
70
|
+
indices = matches_by_score.values_at(*max_keys).flatten
|
70
71
|
|
71
|
-
|
72
|
+
files_array.values_at(*indices)
|
72
73
|
end
|
73
74
|
|
74
75
|
def str2arr( str )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuzz_ball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-20 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: ! 'FuzzBall is a gem that finds fuzzy matches of a string (the ''needle'')
|