【发布时间】:2021-07-11 14:39:58
【问题描述】:
我的列表中有这样的数据:
Microsoft Ltd
Microsoft
Google Inc
Amazon Ltd.
Amazon Ltd.
DropBox Corporation Ltd.
DropBox Corporation
我当前的解决方案能够检测到完全匹配的重复项。因此,它当前会输出:
Amazon Ltd.
Amazon Ltd.
我想添加一些可能性,以便这些也可以在输出列表中:
Microsoft Ltd
Microsoft
Amazon Ltd.
Amazon Ltd.
DropBox Corporation Ltd.
DropBox Corporation
这是我当前的代码:
var dups = companyList.AsEnumerable()
.Where(g => !string.IsNullOrWhiteSpace(g.Name))
.GroupBy(dr => dr.Name.Trim())
.Where(gr => gr.Count() > 1)
.SelectMany(g => g)
.OrderBy(c => c.Name)
.ToList();
我会非常感谢任何善意的建议,这将导致实现这种检查的解决方案?我个人认为这里没有任何可能的逻辑解决方案?也许只是某种基于分数的Levenshtein Distance 计算和检测?如果无论如何都不可能,至少获得这些是有益的(通过多个单词匹配,例如两个):
DropBox Corporation Ltd.
DropBox Corporation
【问题讨论】:
-
@TimSchmelter 理想情况下,订单无关紧要。因此,它也将涵盖订单混乱的情况。所以
DropBox Corporation Ltd.和Corporation DropBox也会被检测到。 -
是否也应该匹配“Google”?
-
@AlexanderPetrov 为简单起见,Google 案例可以简化。我已经编辑了我的问题