Check if two NSStrings are similar

前端 未结 3 1205
别跟我提以往
别跟我提以往 2020-12-07 03:12

I present a tricky question that I am not sure how to approach. So, I have formulated a plist containing dictionaries which contain two objects:

  • The Country Na
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 03:45

    You need to implement an algorithm for approximate matching of strings. One of the most popular such algorithms is Levenshtein distance, one of several Edit distance algorithms. The distance is calculated as the number of editing operations required to transform string A into string B - inserting, deleting, or changing a character counts as one edit operation. The closer are the strings, the smaller is the edit distance between them. You can calculate pairwise edit distances, and find the smallest one to identify the match.

提交回复
热议问题