<commit_before># encoding: UTF-8
require File.dirname(__FILE__) + "/../../spec_helper"
require File.dirname(__FILE__) + "/binary_vector_behavior"

describe Vectors::SparseBinary do
  
  before do
    @vector_class = Vectors::SparseBinary
  end
  
  it_should_behave_like "a binary vector"
end<commit_msg>An extra check that sparse binary vectors compute distances correctly<commit_after># encoding: UTF-8
require File.dirname(__FILE__) + "/../../spec_helper"
require File.dirname(__FILE__) + "/binary_vector_behavior"

describe Vectors::SparseBinary do
  
  before do
    @vector_class = Vectors::SparseBinary
  end
  
  it_should_behave_like "a binary vector"
  
  context "getting an extra workout" do
    
    before do
      @token_index_hash = {}
      1000.times { |i| @token_index_hash[i] = i }
      @vector_a = @vector_class.new(@token_index_hash)
      vector_a_items = mock("vector a items")
      vector_a_items.stub!(:tokens).and_return([5,10,15,20,25,30,35,40,45,50,55,60,65,70,75])
      @vector_a.convert_document(vector_a_items) # 15 total
      @vector_b = @vector_class.new(@token_index_hash)
      vector_b_items = mock("vector b items")
      vector_b_items.stub!(:tokens).and_return([23,45])
      @vector_b.convert_document(vector_b_items)
    end
  
    it "should determine the correct distance" do
      @vector_a.distance(@vector_b).should == 15
    end
    
  end
end
{'fraction_non_alphanumeric': 0.11541218637992831, 'fraction_numerical': 0.03082437275985663, 'mean_word_length': 3.9679715302491103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5817447', 'n_tokens_mistral': 499, 'n_tokens_neox': 469, 'n_words': 95}