Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Allow search for numbers #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fuzzily/trigram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def scored_trigrams
def normalize
ActiveSupport::Multibyte::Chars.new(self).
mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/,'').downcase.to_s.
gsub(/[^a-z]/,' ').
gsub(/[^a-z\d]/,' ').
gsub(/\s+/,'*').
gsub(/^/,'**').
gsub(/$/,'*')
Expand Down
6 changes: 5 additions & 1 deletion spec/fuzzily/trigram_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def result(string)
described_class.new(string).trigrams
end

it 'splits strings into trigrams' do
result('Paris').should == %w(**p *pa par ari ris is*)
end
Expand All @@ -22,4 +22,8 @@ def result(string)
# The final ess, sse, se* would be dupes.
result('Besse-en-Chandesse').should == %w(**b *be bes ess sse se* e*e *en en* n*c *ch cha han and nde des)
end

it 'retain numbers' do
result('678 street').should == %w(**6 *67 678 78* 8*s *st str tre ree eet et*)
end
end