in reply to Suggestions requested: module to standardize postal address components?
I think some way of canonicalization is nice. But the meat of canonicalization is the data of replacements to make and the list of exceptions to these. I'm not aware of any set of rules, be they US-centric or not, and I'm also not aware of any (database) schema to manage addresses at all.
Maybe looking at FOAF might provide such a schema. Maybe you can also structure your canonicalization rules in a general way as pairs (key,replacement) and have a generic driver that looks at each key and does the replacement:
sub canonicalize { my ($rules, $element) = @_; for my $rule (@$rules) { my ($key,$action) = @$rule; if (exists $element->{ $key }) { if (ref $action eq 'CODE') { $action->( $element->{ $key } ); } else { warn "Unknown rule type '$action' for element '$key'"; }; }; }; }; my $en_us = [ [ 'address' => sub { $_[0] =~ s/\bAvenue\b/Ave/ } ], [ 'address' => sub { $_[0] =~ s/\bNorthwest$/NW/ } ], ... ]; canonicalize($en_us, \%address);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Suggestions requested: module to standardize postal address components?
by atcroft (Abbot) on Jun 30, 2010 at 08:28 UTC |