Using C#, how can I replace similar words?

后端 未结 5 2057
孤城傲影
孤城傲影 2021-02-04 17:26

Assuming these two strings:

string s1=\"control\";
string s2=\"conrol\"; (or \"ocntrol\", \"onrtol\", \"lcontro\" etc.)

How can I programatical

5条回答
  •  逝去的感伤
    2021-02-04 18:11

    You could try to check the Levenshtein distance between your two words and if the distance is beyond a threshold, replace the word.

    The hard part is defining the threshold, in your examples a threshold of 2 could work.

    (Implementation of Levenshtein distance in C#)

提交回复
热议问题