Reputation: 3594
Is there a simple way in C# to compare two strings and find out the percentage of similarity between the two? Say you have a string "I like Bing" and "I like Google" it would compare the words "I" "Like" "Bing" with the words "I" "Like" "Google" then would say that 2/3 of it was the same, and would return .66
Upvotes: 2
Views: 1158
Reputation: 67195
A couple of approaches you might check out are Levenshtein Distance and a Soundex Algorithm.
Upvotes: 2
Reputation: 218837
The Damerau–Levenshtein distance is probably the most common implementation I've seen. Should be simple enough to implement in C# given the samples on the Wikipedia page.
Upvotes: 5