Parsing a street address

protek

"Takai desu ne." -"Jinsei da."
Joined
Feb 17, 2008
Posts
4,001
Country
Finland
Region
Oulu, Pohjois-Pohjanmaa
I'm working on an algorithm that can parse the street name and building/house number from an address and omit anything else like block and apartment number. The reason for this is that the geolocation in WP8 can't handle blocks and apartment number.

I've made a rudimentary parser that uses pre-determined delimiters to split a street address to an array of words. I can also determine, when a word is a number so that I can quit parsing.

The problem of course is that it works with addresses, where street name is before the number. Vice versa it is more complex. I can determine, if the first word is a number and keep on parsing in that case but it only works with simple adresses that don't have blocks or apartment numbers.

Block is usually a single letter, so in principle it's easy to pick out. And if there is a number after a single letter, that can also be picked out. Question is, am I covering all possible variations with these? For example, can the UK addresses be more complex than what I've described?

Thanks in advance!
 
UK addresses can have house names instead of or as well as house numbers.
 
House name is probably not a problem. I'm more interested of the syntax of an UK address. Is the block and apartment number right after house number or is it just block and apartment is after street name or how?
 
When you write an address in UK it's normally:

Flat 1, 20 The Street
Locality(optional)
Town
County
Post Code

But it's different in Scotland for example they write:

4/4 (which means flat 4, 4th floor)
20 the Street
Locality(optional)
Town
County
Post Code

(In UK we call an Apartment a Flat)

Of course if you live in a house it's:

20 The Street
Locality(optional)
Town
County
Post Code

Or

'House Name'
The Street
Locality(optional)
Town
County
Post Code
 
Last edited:
as i work for royal mail, this thread is too close to work for me :p
 
Thanks, Steve! :)
Looks like I have the work laid out for me. :coffee:
 
Back
Top Bottom