我匹配的值略有不同,在这种情况下如何找到最接近的匹配
在这个示例中,一切都有非常密切的关系,但我的脚本如何找到匹配
例如我写的脚本
a = ["12,th 3rd street","6th avenue 3r cross","6th street pan,CA","345 hoston road CA","345 hoston road CA"]
b = ["12,th 3rd st","6th av 3rd crs","6th street pan CA WY","345 hoston road, CA","345 hoston road,CA"]
for s in a:
for v in b:
if s == v:
python s
如果您看到这两个数组只有一些工作人员会有所不同
a = ["12,th 3rd street","6th avenue 3r cross","6th street pan,CA","345 hoston road CA","345 hoston road CA"]
b = ["12,th 3rd st","6th av 3rd crs","6th street pan CA WY","345 hoston road, CA","345 hoston road,CA"]
答案 0 :(得分:0)
我希望您需要一些预定义的字词来匹配this or that
。
for eg., {cross:{cr,crs}, avenue:{av,avn}}
你可以直接匹配一些连续的字符串
for i in a:
for j in b:
if i in j or j in i:
print (i,j)
这给了,
12,th 3rd street
12,th 3rd st
匹配其他情况使用字典使用键选择任何值,反之亦然。