lib/namor/namor.rb in namor-0.3.1 vs lib/namor/namor.rb in namor-0.4.0
- old
+ new
@@ -15,16 +15,16 @@
# * remove anything inside parenthesis
# * remove punctuation
# * squeeze whitespace & trim spaces from ends
def scrub(name, opts = {})
suppression_list = @config[:suppress] || []
- suppression_re = Regexp.new('\b?' + (suppression_list + (opts[:suppress]||[])).compact.map(&:upcase).join('|') + '\b?')
+ suppression_re = Regexp.new('(\s|^)' + (suppression_list + (opts[:suppress]||[])).compact.map(&:upcase).join('|') + '(\s|\.|$)')
name && name.upcase.gsub(/^[ZX]{2,}/, '').gsub(suppression_re, '').gsub(/\b(JR|SR|II|III|IV)\b/i, '').gsub(/\([^\(]*\)/, '').gsub(/\./, ' ').gsub(/[_'\&]/, '').gsub(/,\s*$/, '').gsub(/ +/, ' ').strip
end
- def fullscrub(name)
- final_cleaning(scrub(name))
+ def fullscrub(name, opts = {})
+ final_cleaning(scrub(name, opts))
end
def demaiden(lastname)
return [nil,nil] unless lastname && !lastname.empty?
if lastname =~ /\-/