fuzz_ball 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- match->n_matches++;
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
@@ -2,5 +2,7 @@ require 'fuzz_ball/smith_waterman'
2
2
  require 'fuzz_ball/duple_index'
3
3
 
4
4
  module FuzzBall
5
+ VERSION = "0.9.1"
6
+
5
7
  autoload :Searcher, 'fuzz_ball/searcher'
6
8
  end
@@ -8,7 +8,7 @@ module FuzzBall
8
8
  @files = files
9
9
  @files_array = files.collect {|f| str2arr(f)}
10
10
 
11
- index_duples!
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
- 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
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
- matches_by_score = duple_index.match(needle)
68
- max_score = matches_by_score.keys.max
69
- indices = matches_by_score[max_score]
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
- files_array.values_at(*indices)
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.0
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-05 00:00:00.000000000 -07:00
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'')