python - 电子邮件地址和姓名之间的单词相似度

标签 python nlp nltk

我的问题与简单的单词相似度有点不同。问题是是否有任何算法可用于计算邮件地址和名称之间的相似度。

    for example:
    mail Abd_tml_1132@gmail.com
    Name Abdullah temel
    levenstein,hamming distance  11
    jaro distance  0.52

但很可能,这个邮件地址属于这个名字。

最佳答案

没有直接包,但这可以解决你的问题:

将电子邮件 ID 放入列表

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")

关于python - 电子邮件地址和姓名之间的单词相似度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55647041/

相关文章:

python - Pyramid - 为文件上传表单编写单元测试

python - statsmodels.api.tsa.get_forcast 的参数是什么?

python - 使用 python 在大文件中搜索字符串的更快方法

python - 如何在 nltk 中使用 stanford NLP 的 "Universal dependencies, enhanced"解析器?

python - NLTK Python 类型错误 : 'module' object is not callable

python - 在单元测试中执行 I/O 是一种不好的做法吗

python - 在继承类中执行父方法

google-cloud-platform - 如何使用 Google NLP 在单个注释中提取多个标签文本项

machine-learning - 如何将NLP问题转换为知识图谱三元组?

python - 从Python中的句子中提取子句