【发布时间】:2011-05-04 10:34:22
【问题描述】:
我需要实现一些这样的:
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# 编写的函数存根:
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 方法中实现逻辑。 有任何想法吗?或许为此目的有现成的解决方案?
【问题讨论】:
-
您可以计算Levenshtein distance,使用单词作为符号而不是字符,其中单词根据它们的 Levenshtein 距离被认为是相等的。 Levenshtein 距离上有many SO topics。
标签: c# fuzzy-search fuzzy-logic