I am trying to do some string matching using the Levenshtein algorithm for closest words on businesses. (In python but language won't make a huge difference)
An example query would be
search = 'bna' lat & lon are close by the result I am looking for.
There is a pub right by the latitude and longitude called BNA Brewing Co. by searching BNA my hopes would be that that shows up first (as bna == bna)
I have tried two different way
m = min([editdistance.eval(search, place_split) for place_split in place.name.split(' ')
if place_split not in string.punctuation])
returns without ranking based on geographical distance, only levenshtein distance
- Coffee & Books In Town Center
- Talk 'n' Coffee
- Raggedy Ann & Andy's
and with taking into account geographical distance, secondary to levenshtein
- Shapers Hair Salon & Spa
- Amora Day Spa
- Pure Esthetics and Micro-Pigmentation
And
m = editdistance.eval(search, place.name)
The first one returns without ranking based on geographical distance, only levenshtein distance
- KFC
- MOO
- A&W
and with taking into account geographical distance, secondary to levenshtein
- A&W
- A&W
- KFC
So you can see that neither way are returning anything close to BNA Brewing Co. What kind of logic do I have to use to get it to return something when the search terms exactly matches one of the place names in my database?