lib/fuzzy_match/wrapper.rb in fuzzy_match-1.2.1 vs lib/fuzzy_match/wrapper.rb in fuzzy_match-1.2.2
- old
+ new
@@ -11,11 +11,11 @@
@record = record
@literal = literal
end
def inspect
- "#<Wrapper render=#{render} variants=#{variants.length}>"
+ "#<FuzzyMatch::Wrapper render=#{render.inspect} variants=#{variants.length}>"
end
def read
fuzzy_match.read unless literal
end
@@ -45,11 +45,13 @@
@render
end
alias :to_str :render
- # "Foo's Bar" should be treated as [ "Foo's", "Bar" ], so we don't use traditional regexp word boundaries (\b)
- WORD_BOUNDARY = %r{\s+}
+ # "Foo's" is one word
+ # "North-west" is just one word
+ # "Bolivia," is just Bolivia
+ WORD_BOUNDARY = %r{\W*(?:\s+|$)}
def words
@words ||= render.downcase.split(WORD_BOUNDARY)
end
def similarity(other)