Sha256: 6e1023fe8fbf4a08dbe5f41bda6f0bcf19a125dc40067b5e3c3f497324cc72db
Contents?: true
Size: 1.62 KB
Versions: 21
Compression:
Stored size: 1.62 KB
Contents
# encoding: utf-8 # require 'spec_helper' describe 'similarity' do it 'does Soundex' do index = Picky::Index.new :phonetic do indexing removes_characters: /[^a-z\s]/i category :text, similarity: Picky::Similarity::Soundex.new(1) end index.replace_from id: 1, text: "Peter" try = Picky::Search.new index # No ~, no similarity. # try.search("text:petor").ids.should == [] # Finds soundex-similar text. # try.search("text:petor~").ids.should == [1] # Finds the identity. # try.search("text:peter~").ids.should == [1] end it 'does Metaphone' do index = Picky::Index.new :phonetic do indexing removes_characters: /[^a-z\s]/i category :text, similarity: Picky::Similarity::Metaphone.new(1) end index.replace_from id: 1, text: "Peter" try = Picky::Search.new index # No ~, no similarity. # try.search("text:pdr").ids.should == [] # Finds soundex-similar text. # try.search("text:pdr~").ids.should == [1] # Finds the identity. # try.search("text:peter~").ids.should == [1] end it 'does DoubleMetaphone' do index = Picky::Index.new :phonetic do indexing removes_characters: /[^a-z\s]/i category :text, similarity: Picky::Similarity::DoubleMetaphone.new(1) end index.replace_from id: 1, text: "Peter" try = Picky::Search.new index # No ~, no similarity. # try.search("text:pdr").ids.should == [] # Finds soundex-similar text. # try.search("text:pdr~").ids.should == [1] # Finds the identity. # try.search("text:peter~").ids.should == [1] end end
Version data entries
21 entries across 21 versions & 1 rubygems