开发者

Compare two strings C#?

开发者 https://www.devze.com 2023-02-18 04:57 出处:网络
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开发者_高级运维

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

精彩评论

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