【发布时间】:2020-08-22 19:43:05
【问题描述】:
我正在尝试在列表中查找类似的电子邮件。为此,
database.head()
TID PID Names
0 22330 134575 tim
1 22333 134578 tim.rand
2 22328 134571 rand.001
3 22340 134568 pankit090
4 22325 134569 timrook
emailsdb = database['Names'].values.tolist()
现在是迭代部分
list = []
for email in emailsdb :
result = process.extractBests(email, emailsdb, score_cutoff=85, limit=100)
list.append(result)
列表输出为
[[('tim', 100), ('tim.rand', 90), ('timrook', 90)],
[('tim.rand', 100), ('tim', 90)],
[('rand.001', 100)],
[('pankit090', 100),
('pankit001', 89),
('pankit002', 89),
('pankit003', 89),
('pankit004', 89),
('pankit005', 89)],
[('timrook', 100), ('tim', 90)],
[('pankit001', 100),
('pankit090', 89),
('pankit002', 89),
('pankit003', 89),
('pankit004', 89),
('pankit005', 89)],
[('pankit002', 100),
('pankit090', 89),
('pankit001', 89),
('pankit003', 89),
('pankit004', 89),
('pankit005', 89)],
但我想避免 ('tim', 100), ('tim.rand', 100), ('rand.001', 100), ('pankit090', 100), ('timrook', 100 ), ('pankit001', 100),('pankit002', 100) 因为这些显然是绝配
【问题讨论】:
-
基于 wuzzy 文档,我看不到跳过 100 个匹配项的方法。您可能只需要在提取调用后将它们从列表中删除。
-
如果我们在 for 循环中删除列表副本并删除电子邮件会怎样
-
是的 - 这也应该有效
-
list = [] 用于 emailsdb 中的电子邮件:newlookup = emailsdb.copy() newlookup.remove(email) result = process.extractBests(email, newlookup, score_cutoff=85, limit=50) 列表。追加(电子邮件)列表。追加(结果)
-
这里的结果格式为 - [email, [match1,score],[match2,score], email, [match3,score],[match4,score]]。如何提取 match1、match2、match3、match4 并将它们从 emailsdb 中删除
标签: python-3.x for-loop iteration fuzzywuzzy