开发者

Compare two strings C#?

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


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.


A couple of approaches you might check out are Levenshtein Distance and a Soundex Algorithm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜