Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Suggestions requested: module to standardize postal address components?

by atcroft (Monsignor)
on Jun 30, 2010 at 08:28 UTC ( #847283=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^2: Suggestions requested: module to standardize postal address components?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://847283]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-09-03 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls