a = 'Abd_tml_1132@gmail.com'
rest = a.split('@', 1)[0] # Removing @
result = ''.join([i for i in rest if not i.isdigit()]) ## Removing digits as no names contains digits in them
list_of_email_words =result.split('_') # making a list of all the words. The separator can be changed from _ or . w.r.t to email id
list_of_email_words = list(filter(None, list_of_email_words )) # remove any blank values
为列表命名:
b = 'Abdullah temel'
list_of_name_words =b.split(' ')
对两个列表应用模糊匹配:
score =[]
for i in range(len(list_of_email_words)):
for j in range(len(list_of_name_words)):
d = fuzz.partial_ratio(list_of_email_words[i],list_of_name_words[j])
score.append(d)
现在您只需要检查score的任何元素是否大于您可以定义的阈值。例如:
threshold = 70
if any(x>threshold for x in score):
print ("matched")
没有直接套餐,但这可以解决您的问题:
将电子邮件id放入列表
为列表命名:
对两个列表应用模糊匹配:
现在您只需要检查
score
的任何元素是否大于您可以定义的阈值。例如:fuzzyfuzzy可以帮助您找到所需的解决方案。首先使用regex从字符串中删除'@'和域名。你将有2个字符串如下-
输出-
相关问题 更多 >
编程相关推荐