Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Normalizers
- module CompanyNormalizer
- class NameNormalizer
- SUFFIXES = [
- ', Inc.',
- ', Inc',
- 'Inc.',
- 'Inc',
- ', INC',
- ', INC.',
- 'INC',
- 'INC.',
- ', LLC',
- 'Limited',
- 'LIMITED',
- 'GmbH',
- 'b.v.',
- 'B.V.',
- 'GmbH & Co. KG',
- ', LTD',
- 'LTD',
- 'Limited',
- 'Pvt. Ltd.',
- 'GmbH.',
- 'sp. z o.o.',
- 'Sp. Z.o.o.',
- 'Sp.Z.o.o.',
- 'SA',
- 's.c.',
- 'S.A.',
- 'Co',
- 'Co.',
- 'AS',
- 'AB',
- '®',
- 'doo',
- 'plc',
- 's.j.',
- 'sp.j.',
- 'AG',
- 'Oy'
- ]
- def normalize(company_name)
- SUFFIXES.each do |suffix|
- suffix_regex = Regexp.new(normalize_suffix(suffix))
- company_name = company_name.gsub(suffix_regex, '')
- end
- company_name
- end
- def normalize_suffix(suffix)
- new_suffix = suffix
- if suffix[0] != ',' && suffix != '®'
- new_suffix = ' ' + suffix + '$'
- end
- new_suffix
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement