Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle streets where the name overlaps the street-type map #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/street_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ class << self
# note that expressions like [^,]+ may scan more than you expect
self.street_regexp = /
(?:
# special case for addresses like 14168 W River Rd and 3301 N Park
# Blvd, where the street name matches one of the street types
(?:
(?<prefix> #{direct_regexp})\W+
(?<street> [^\d]+)\W+
(?<street_type> #{street_type_regexp})\b
)
|
# special case for addresses like 100 South Street
(?:(?<street> #{direct_regexp})\W+
(?<street_type> #{street_type_regexp})\b
Expand Down
30 changes: 30 additions & 0 deletions test/street_address_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ class StreetAddressUsTest < MiniTest::Test
:street_type => 'Rd',
:state => 'CO'
},
"14168 W RIVER RD \nCOLUMBIA STATION, OH 44028-9430" => { # overlapping street type and road name
:city => 'Columbia Station',
:postal_code => '44028',
:postal_code_ext => '9430',
:number => '14168',
:street => 'River',
:street_type => 'Rd',
:state => 'OH',
:prefix => 'W'
},
"555 E LAKE AVE \nBELLEFONTAINE, OH 43311-2509" => {
:city => 'Bellefontaine',
:postal_code => '43311',
:postal_code_ext => '2509',
:number => '555',
:street => 'Lake',
:street_type => 'Ave',
:state => 'OH',
:prefix => 'E'
},
"19600 N PARK BLVD \nSHAKER HEIGHTS, OH 44122-1825" => {
:city => 'Shaker Heights',
:postal_code => '44122',
:postal_code_ext => '1825',
:number => '19600',
:street => 'Park',
:street_type => 'Blvd',
:state => 'OH',
:prefix => 'N'
},
"1234 COUNTY HWY 60E, Town, CO 12345" => {
:city => 'Town',
:postal_code => '12345',
Expand Down