Module: Taxamatch::Normalizer
- Defined in:
- lib/taxamatch_rb/normalizer.rb
Class Method Summary collapse
- .normalize(string) ⇒ Object
- .normalize_author(string) ⇒ Object
- .normalize_word(word) ⇒ Object
- .normalize_year(year_string) ⇒ Object
Class Method Details
.normalize(string) ⇒ Object
6 7 8 |
# File 'lib/taxamatch_rb/normalizer.rb', line 6 def self.normalize(string) utf8_to_ascii(string.strip.upcase).gsub(/[^\x00-\x7F]/,'?') end |
.normalize_author(string) ⇒ Object
14 15 16 |
# File 'lib/taxamatch_rb/normalizer.rb', line 14 def self.(string) self.normalize(string).gsub(/[^A-Z]/, ' ').gsub(/[\s]{2,}/, ' ').strip end |
.normalize_word(word) ⇒ Object
10 11 12 |
# File 'lib/taxamatch_rb/normalizer.rb', line 10 def self.normalize_word(word) self.normalize(word).gsub(/[^A-Z0-9\-]/, '').strip end |
.normalize_year(year_string) ⇒ Object
18 19 20 21 22 |
# File 'lib/taxamatch_rb/normalizer.rb', line 18 def self.normalize_year(year_string) year_int = year_string.gsub(/[^\d]/, '').to_i year_int = nil unless year_int.between?(1757, Time.now.year + 1) year_int end |