http://www.perlmonks.org?node_id=847283


in reply to Re: Suggestions requested: module to standardize postal address components?
in thread Suggestions requested: module to standardize postal address components?

I really appreciate the feedback, Corion. Thank you.

Actually, the US Postal Service has a list of standard abbreviations for use with postal addressing, at least in the US. What I did was to create a set of regexes for those, so as they set now they just consist of the regexes and the common abbreviations they refer to, in a form I could generate the tests from. I haven't put them into a more usable form yet, due in part to a lack of to-its.

(Right now, it is a set of hashes with the key being the abbreviation, with one subkey being the regex, another being the common abbreviations it was to later test (including some not listed but that seemed plausible as well). An example would be the following snippet:
my %state_or_province_designator = ( AL => { regex => qr/AL(?:A(?:\.|BAMA)?)?\.?/i, test_case => [qw( ALA ALA. ALABAMA )], }, AK => { regex => qr/A(?:K|LAS(?:KA?)?)\.?/i, test_case => [qw( ALASKA )], }, AS => { regex => qr/A(?:\.?|M(?:\.|ER(?:\.|ICAN)?)?)\s*S(?:AM(?:\.|OA) +?)?|A\.\s*S\./i, test_case => [], }, ... ); # AS test case generation push @{ $state_or_province_designator{AS}{test_case} }, generate_from_array_2( [ [qw( A A. AM AM. AMER AMER. AMERICAN )], [qw( S S. SAM SAM. SAMOA )] ] );
where the standard abbreviation would also be used in the tests when generated later.)

I'll take a look at the FOAF project link you indicated, to see if there seems to be anything there that might be of use, as well as look over your recommendations when I have neurons firing a little more in tune.