我需要实现某种这样的:
string textToSearch = "Extreme Golf: The Showdown";
string textToSearchFor = "Golf Extreme Showdown";
int fuzzyMatchScoreThreshold = 80; // One a 0 to 100 scale
bool searchSuccessful = IsFuzzyMatch(textToSearch, textToSearchFor, fuzzyMatchScoreThreshold);
if (searchSuccessful == true)
{
-- we have a match.
}
这是用 C# 编写的函数 stub :
public bool IsFuzzyMatch (string textToSearch, string textToSearchFor, int fuzzyMatchScoreThreshold)
{
bool isMatch = false;
// do fuzzy logic here and set isMatch to true if successful match.
return isMatch;
}
但我不知道如何在 IsFuzzyMatch 方法中实现逻辑。 有任何想法吗?也许为此目的有现成的解决方案?
最佳答案
我喜欢骰子系数、编辑距离、最长公共(public)子序列的组合,有时还喜欢双重变音位。前三个将为您提供一个阈值。我更喜欢以某种方式将它们结合起来。 YMMV.
我刚刚发布了一篇博文,其中每一个都有一个 C# 实现,称为 Four Functions for Finding Fuzzy String Matches in C# Extensions .
关于c# - 模糊匹配与阈值过滤器 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4086442/