Sha256: e60b67d8b48c7c6533636c86410275b2f849e469790593f80969914b82370c70
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require 'indirizzo/constants' require 'indirizzo/number_helper' require 'indirizzo/helper' module Indirizzo class Street def self.expand(street) if !street.empty? && !street[0].nil? street.map! {|s|s.strip} add = street.map {|item| item.gsub(Name_Abbr.regexp) {|m| Name_Abbr[m]}} street |= add add = street.map {|item| item.gsub(Std_Abbr.regexp) {|m| Std_Abbr[m]}} street |= add street.map! {|item| NumberHelper.expand_numbers(item)} street.flatten! street.map! {|s| s.downcase} street.uniq! else street = [] end street end def self.parts(street, number) strings = [] # Get all the substrings delimited by whitespace street.each do |string| tokens = string.split(" ") strings |= (0...tokens.length).map do |i| (i...tokens.length).map {|j| tokens[i..j].join(" ")} end.flatten end strings = Helper.remove_noise_words(strings) # Try a simpler case of adding the @number in case everything is an abbr. strings += [number] if strings.all? {|s| Std_Abbr.key?(s) || Name_Abbr.key?(s)} strings.uniq end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
HornsAndHooves-indirizzo-0.1.7.1 | lib/indirizzo/street.rb |