How to check a partial similarity of two strings in C# -


is there function in c# check % of similarity of 2 strings?

for example have:

var string1="hello how doing";  var string2= " hi, how you"; 

and

function(string1, string2)  

will return similarity ratio because words "how", "are", "you" present in line.

or better, return me 60% of similarity because "how", "are", "you" 3/5 of string1.

does function exist in c# that?

a common measure similarity of strings so-called levenshtein distance or edit distance. in approach, defined set of edit operation defined. levenshtein distance minimum number of edit steps necessary obtain second string first. closely related damerau-levenshtein distance, uses different set of edit operations.

algorithmically, levenshtein distance can calculated using dynamic programming, can considered efficient. however, note approach not take single words account , cannot directly express similarity in percent.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -