0

So basically I have thousands of street listings that I would like to organize. The street listings are currently stored in one string variable like this:

123 Street dr
123 N Street dr
123 N Street drive
123 Street Drive
123-N Street drive
123 North Street drive

As you can tell, its pretty random. I would really like to have them stored in an object called Location with the following definitions.

int streetNumber;
string direction;
string streetName;
string typeOfStreet;

I am doing this in C# if it matters, I believe its more of a logic question. Is there an easy method of doing this? It doesn't have to be completely perfect, I would like to just get around a 90% success rate and I will just mark off the ones that I have "organized."

Thanks Ahead

Leyth G
  • 953
  • 1
  • 11
  • 30
  • No, there isn't an easy method of doing this. A regular expression approach will probably be cumbersome and will most likely fail. There are too many possibilities. For example, "128 Highway 37 South". Or "123 Main Street" and "123 North Main" being the same address. Or an address like you see in some parts of the country (Salt Lake City area, for example) "37 North, 12 West Parkland Ave." You might look around for a service ([Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/), for example) that will do it for you. – Jim Mischel Oct 02 '13 at 22:16
  • I am getting some success from using regular expressions. I am satisfied if I can at least organize some of the addresses. It would be a good start to fixing the rest. I have just been weeding out the most common ones like "streetNumber streetName streetType" which would be something like 123 street st. I just have to be strict with the regex expression so it does not include the word "North" as a street name or something similar. Thank you and sorry for the duplicate post, I did search before posting, not sure how I missed that other post. – Leyth G Oct 03 '13 at 12:48

2 Answers2

1

Regular expression is the best solution. http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx

And to test the regular expression, there is regex tester in Visual Studio Add ins or even regex online tester. There is also Regex cheat sheet online for fast source to learn.

Yohanes Nurcahyo
  • 495
  • 7
  • 19
0

I don't really think there is a way around doing this manually, unless you can know every single possible way it would be currently stored. i.e. you can easily split a string around a space to get individual items but for your 5th option you wouldn't be able to do this, so you would have to manually handle if it has a -. But then you may run into issues if the street name includes a - etc.

It would be easier if you could modify the currently stored items into a more specific format (even if it is just comma seperated items or space seperated etc...) then you would be able to easily manipulate it using the simple String functions and Arrays.

Nunners
  • 3,027
  • 11
  • 17