Skip to content

Commit

Permalink
mezis#48 Fuzzily::String#normalize should not strip numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Maysora committed Dec 29, 2015
1 parent e373a70 commit de922de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit de922de

Please sign in to comment.