Detect differences between two strings

前端 未结 5 994
天命终不由人
天命终不由人 2020-12-05 06:40

I have 2 strings

string a = \"foo bar\";
string b = \"bar foo\";

and I want to detect the changes from a to b. <

5条回答
  •  孤街浪徒
    2020-12-05 07:23

    If you want to have a precise comparison between two strings, you must read and understand Levenshtein Distance. by using this algorithm you can precisely calculate rate of similarity between two string and also you can backtrack the algorithm to get the chain of changing on the second string. this algorithm is a important metric for Natural Language Processing also.

    there are some other benefits and it's need time to learn.

    in this link there is a C# version of Levenshtein Distance :

    https://www.dotnetperls.com/levenshtein

提交回复
热议问题