import re
list =[]
for element in address1:
z = re.match("^\d+", element)
if z:
list.append(z.string)
get_best_fuzzy("SATYAGRAH;OPP. RAJ SUYA BUNGLOW", list)
我已经尝试了上面的代码,它为我的文本文件中的地址提供了近似的地址匹配。我如何才能获得与确切的休息地址匹配的确切门牌号码。我的地址格式为: 1004; Jay Shiva塔;阿扎德协会附近;印度安巴瓦迪·艾哈迈达巴德·古吉拉特邦380015
1004; Jayshiva塔;阿扎德协会附近;印度安巴瓦迪·艾哈迈达巴德·古吉拉特邦380015
101 GAMBS TOWER;四个平房;相反的好牧羊人教堂安德烈·西孟买马哈拉施特拉邦400053印度
101 / 32-B;斜面复杂VEER SAVARKAR块; SHAKARPUR;印度EASE DEL HI DELHI德里110092
答案 0 :(得分:0)
您可以尝试一下。
代码:
import re
address = ["1004; Jayshiva Tower; Near Azad Society; Ambawadi Ahmedabad Gujarat 380015 India",
"101 GAMBS TOWER; FOUR BUNGLOWS;OPPOSITE GOOD SHEPHERD CHURCH ANDHERI WEST MUMBAI Maharashtra 400053 India",
"101/32-B; SHREE GANESH COMPLEX VEER SAVARKAR BLOCK; SHAKARPUR; EASE DEL HI DELHI Delhi 110092 India"]
for i in address:
z = re.match("^([^ ;]+)", i)
print(z.group())
输出:
1004
101
101/32-B