我需要实现某种这样的:与门槛过滤器C#中的模糊匹配
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距离](http://en.wikipedia.org/wiki/Levenshtein_distance),其中基于Levenshtein距离将单词视为相等。在Levenshtein距离上有[许多SO话题](http://stackoverflow.com/search?q= [c%23] + Levenshtein +距离)。 – dtb 2010-11-03 11:15:40
请参阅http://stackoverflow.com/questions/451884/similar-string-algorithm/451910#451910 – 2010-11-03 12:24:14