Subject: | Cannot parse some US address types |
Addresses of the following form are not parsed:
123 Maple Avenue Suite No. 999 Foobar City, NM 12345
123 Maple Avenue Suite #999 Foobar City, NM 12345
123 Maple Avenue Suite#999 Foobar City, NM 12345
123 Maple Avenue Suite 999 Foobar City, NM 12345
Replace "Suite" above with "Apt." and it still does not work.
Putting a comma after the street name does not help either.
Also, the following form does not work:
123 Maple Avenue PO Box 9876 Foobar City, NM 12345
Another form which is common:
123 Maple Ave. Foobar City, NM 12345 Attn: Mail Reading Person
c/o Somebody 123 Maple Ave. Foobar City, NM 12345
(People in the US often list a street address and a PO Box that they want delivered to. The lower address has priority.)
I was using the following code (replacing $text with address form in question):
--- cut ---
use strict;
use warnings;
use Lingua::EN::AddressParse;
require Data::Dumper;
my $addr = new Lingua::EN::AddressParse( country => 'US' );
my $text = "123 Maple Avenue Suite No. 999 Foobar City, NM 12345";
my $err = $addr->parse( $text );
{
print "Error = $err\n";
my %info = $addr->components;
print Data::Dumper->Dump([\%info]);
}