|
Geo::StreetAddress::US - Perl extension for parsing US street addresses |
Geo::StreetAddress::US - Perl extension for parsing US street addresses
use Geo::StreetAddress::US;
my $hashref = Geo::StreetAddress::US->parse_location(
"1005 Gravenstein Hwy N, Sebastopol CA 95472" );
my $hashref = Geo::StreetAddress::US->parse_location(
"Hollywood & Vine, Los Angeles, CA" );
my $hashref = Geo::StreetAddress::US->parse_address(
"1600 Pennsylvania Ave, Washington, DC" );
my $hashref = Geo::StreetAddress::US->parse_intersection(
"Mission Street at Valencia Street, San Francisco, CA" );
my $normal = Geo::StreetAddress::US->normalize_address( \%spec );
# the parse_* methods call this automatically...
Geo::StreetAddress::US is a regex-based street address and street intersection parser for the United States. Its basic goal is to be as forgiving as possible when parsing user-provided address strings. Geo::StreetAddress::US knows about directional prefixes and suffixes, fractional building numbers, building units, grid-based addresses (such as those used in parts of Utah), 5 and 9 digit ZIP codes, and all of the official USPS abbreviations for street types and state names.
Most Geo::StreetAddress::US methods return a reference to a hash containing
address or intersection information as one of their arguments. This
``address specifier'' hash may contain any of the following fields for a
given address. If a given field is not present in the address, the
corresponding key will be set to undef in the hash.
Geo::StreetAddress::US contains a number of global variables which it uses to recognize different bits of US street addresses. Although you will probably not need them, they are documented here for completeness's sake.
parse_intersection() or parse_address() as needed.
parse_location()
instead.
parse_location() instead.
Typically, you won't need to use this method, as the parse_*() methods
call it for you.
N.B., normalize_address() crops 9-digit ZIP codes to 5 digits. This is for
the benefit of Geo::Coder::US and may not be what you want. E-mail me if this
is a problem and I'll see what I can do to fix it.
Geo::StreetAddress::US might not correctly parse house numbers that contain hyphens, such as those used in parts of Queens, New York. Also, some addresses in rural Michigan and Illinois may contain letter prefixes to the building number that may cause problems. Fixing these edge cases is on the to-do list, to be sure. Patches welcome!
This software was originally part of Geo::Coder::US (q.v.) but was split apart into an independent module for your convenience. Therefore it has some behaviors which were designed for Geo::Coder::US, but which may not be right for your purposes. If this turns out to be the case, please let me know.
Geo::StreetAddress::US does NOT perform USPS-certified address normalization.
This software was originally part of Geo::Coder::US(3pm).
Lingua::EN::AddressParse(3pm) and Geo::PostalAddress(3pm) both do something very similar to Geo::StreetAddress::US, but are either too strict/limited in their address parsing, or not really specific enough in how they break down addresses (for my purposes). If you want USPS-style address standardization, try Scrape::USPS::ZipLookup(3pm). Be aware, however, that it scrapes a form on the USPS website in a way that may not be officially permitted and might break at any time. If this module does not do what you want, you might give the othersa try. All three modules are available from the CPAN.
You can see Geo::StreetAddress::US in action at http://geocoder.us/.
Many thanks to Dave Rolsky for submitting a very useful patch to fix fractional house numbers, dotted directionals, and other kinds of edge cases, e.g. South St. He even submitted additional tests!
Schuyler D. Erle <schuyler@geocoder.us>
Copyright (C) 2005 by Schuyler D. Erle.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
|
Geo::StreetAddress::US - Perl extension for parsing US street addresses |