Check if two NSStrings are similar

前端 未结 3 1197
别跟我提以往
别跟我提以往 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.

    0 讨论(0)
  • 2020-12-07 03:50

    The Soundex algorithm is useful in cases like this.

    I found a sample implementation on github.

    0 讨论(0)
  • 2020-12-07 03:57

    You may find this post about auto update/complete useful:

    I've tested that UITextViews work well while adhering to the UITextViewDelegate protocol in your UIViewController class and will produce a result similar to what you'll find in the Messages app. I haven't checked if UITextField and UITextFieldDelegate do as well.

    Autocomplete/Autocorrect

    0 讨论(0)
提交回复
热议问题