Skip to content

Commit

Permalink
Adding ruby methods for interpreting index results
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchu committed Sep 23, 2011
1 parent 882ec97 commit e83fa56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/fuzz_ball.rb
@@ -1,5 +1,6 @@
require File.join(File.dirname(__FILE__), '../ext/smith_waterman/smith_waterman')
require File.join(File.dirname(__FILE__), '../ext/duple_index/duple_index')
require File.join(File.dirname(__FILE__), 'fuzz_ball/duple_index')

module FuzzBall
autoload :Searcher, 'fuzz_ball/searcher'
Expand Down
22 changes: 21 additions & 1 deletion spec/lib/duple_index_spec.rb
Expand Up @@ -17,11 +17,31 @@
before(:each) do
@index.add(0, [1, 2, 3]);
@index.add(1, [0, 1, 2]);
@index.add(2, [3, 4, 3, 4, 3, 4])
end

it "should tell you where a given duple is found" do
@index.query(1, 2).should == [[1, 1], [0, 0]]
end
end

describe "#match" do
before(:each) do
@index.add(0, [1, 2, 3, 4])
@index.add(1, [1, 2, 3])
@index.add(2, [1, 2, 4])
@index.add(3, [4, 5])
end

it "should not attempt to match with one or fewer duples in the candidate" do
@index.match([1]).should == {}
end

it "should return strings that match candidate by score" do
@index.match([1, 2, 3]).should == { 0 => 2, 1 => 2, 2 => 1 }
end

it "should return strings by score" do
@index.match([1, 2, 3], :by_score => true).should == {2 => [1, 0], 1 => [2]}
end
end
end

0 comments on commit e83fa56

Please sign in to comment.