Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: De Duping Street Addresses Fuzzily

by Fletch (Bishop)
on Jan 31, 2005 at 22:32 UTC ( [id://426750]=note: print w/replies, xml ) Need Help??


in reply to De Duping Street Addresses Fuzzily

First of all you need to define what "fuzzily matching" means. From your sample data I'd say you want "same city/state/zip with the same street name and number", or something close to that. Once you've decided on that, you need to tokenize the address and map what you've got in the DB into a canonical form. Split on spaces and write a little parser with logic something like:

  • Look for street number first
  • Next look for a direction or abbreviation (N., North) and canonicalize it (NORTH)
  • read up anything that doesn't look like a road type (i.e. stop when you see a Street, St., Ave., . . .) and canonicalize that to uppercase
  • canonicalize the road type to the full word uppercased (St. to STREET)
  • If there's anything left like Suite \d+ handle it similarly, or just ignore (depending on what your definition of equals winds up being)
  • Create the canonical key by concatenating all these parts together separated by spaces

Once you've parsed everything into this canonical form push the real data onto a hash-of-arrays keyed by the canonical form (for large enough data sets you may want to use DB_File or the like). Then the last step is to print the canonical form and the raw data for any keys for which there's more than one entry for the given canonical form.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-20 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found