Strip a trailing city, state and ZIP before parsing an address - #170
Merged
Conversation
Some registries publish a full postal address in the field others use for the street line alone: ODRC writes "1990 Harmon Avenue, Columbus, OH 43223" where DODD writes "1990 Harmon Avenue". parse_address replaces commas with spaces, so the whole tail was read as part of the street name -- "HARMON AVENUE COLUMBUS OH 43223" -- taking the street type down with it. None of those addresses could match anything. The tail must end in the state, optionally followed by a ZIP and a parenthetical note, before anything is removed. A comma alone is not enough to act on: DODD writes "1359 State Route #38, Southeast", where what follows the comma belongs to the address, and "4410,4412,4416 MORSE RD", where the commas separate house numbers. Both are left untouched, as is a street named for the state. Against the 359 DODD, CMS and ODRC facility addresses used to validate morpc/morpc-addresspoints-standardize#7, this takes matching from 324/359 (90.3%) to 330/359 (91.9%), and ODRC from 74.1% to 85.2%. The number_name and route_number tiers are unchanged, so nothing previously matched was displaced. Addresses the first of the three defects in #168; the OH-104 and C.R. 32 route forms are untouched and that issue stays open for them. Refs #168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the first and largest of the three defects in #168. The two route-form defects there are untouched and the issue stays open for them.
The defect
Some registries publish a full postal address in the field others use for the street line alone. ODRC writes
1990 Harmon Avenue, Columbus, OH 43223where DODD writes1990 Harmon Avenue.parse_addressreplaces commas with spaces, so the whole tail became part of the street name and took the street type with it:What is and is not treated as a tail
The tail must end in the state, optionally followed by a ZIP and a parenthetical note, before anything is removed. A comma alone is not enough to act on, because in this data a comma often separates something that belongs to the address:
1990 Harmon Avenue, Columbus, OH 432235900 BIS Rd SW, Lancaster, Ohio 4313016197 State Route 104, Chillicothe, OH 45601, (visitor entrance)1234 Main St, OH 43215123 Main St, Ohio City, OH 458741359 State Route #38, Southeast4410,4412,4416,4418,4424,4426 MORSE RD1990 Harmon Avenue, Columbus123 Ohio AveOhio only, which is the region this data covers.
Effect
Against the 359 DODD, CMS and ODRC facility addresses used to validate morpc/morpc-addresspoints-standardize#7:
The
number_nameandroute_numbertiers are unchanged at 8 and 4; the six new matches land inexact(277 → 281) andcomponents(35 → 37), so nothing previously matched was displaced.Tests
Four added: the headline case, the three tail variants, the four inputs that must be left alone, and a street named for the state. All 40 in
test_geocode.pypass. Thetest_utils.pyfailures noted in #169 remain, unrelated and pre-existing onmain.Two pre-existing quirks found while testing, not fixed here
Both are visible in the "kept" rows above and predate this change:
1359 State Route #38, Southeastparses tostreetname='STATE ROUTE',unitnum='38 SOUTHEAST'— the#inRoute #38is read as a unit designator rather than a route number, so the route never reachesCONST_ROUTE_PREFIX_ABBREV.4410,4412,4416,4418,4424,4426 MORSE RDparses tostreetname='4412 4416 4418 4424 4426 MORSE'.normalize_house_numberdocuments handling the multi-number case, but commas are flattened before it sees the joined form, so only the first number is taken and the rest leak into the name.Neither is in scope for #168. Happy to file them separately if they are worth fixing.
🤖 Generated with Claude Code