def normalize_street_name(street): not_a_prefix = lambda x: prefix_list.get(x, None) is None strout = street for k,v in special_chars.iteritems(): strout = strout.replace(k,v) wlist = word_strip(strout) wlist = map(lambda x: prefix_list.get(x.lower(), x), wlist) return u" ".join(wlist).lower()
def clean_search_street(street): """ This function clean search string """ not_a_prefix = lambda x: prefix_list.get(x, None) is None strout = street.lower() for k,v in special_chars.iteritems(): strout = strout.replace(k,v) wlist = word_strip(strout) wlist = filter(not_a_prefix, wlist) return u" ".join(wlist)