比较两个NSStrings的相似性 [英] Compare similarity of two NSStrings
问题描述
我想比较两个 NSString
。如果用户键入Stonehhengge,应该得到一个border on answer=几乎等于,因为正确的答案是:Stonhenge。
I would like to compare two NSString
s. If the user types "Stonehhengge", should get a "border on answer"="almost equals", because the right answer is: "Stonhenge".
一个字符串等于另一个字符串的百分比。如果Stonhenge是9个字母,并且键入的文本包含Stonhenge的8个字母,但不等于Stonhenge,例如:Stonehange不等于Stonhenge,但它接近 -
I would like a percentage of how much one string equals another. If "Stonhenge" is 9 letters, and the typed text contain 8 letters from "Stonhenge", but it's not equal to "Stonhenge", for example: "Stonehange" is not equal to "Stonhenge", but it's near - I'd like to know how near a match the strings are.
我只知道 isEqual:
。如果你输入巨石阵,你会匹配,并得到正确的符号。
I only know isEqual:
. If you type "Stonehenge", you match and will get the right symbol. If text field's text is not equal, you do not get a match and get the wrong symbol.
推荐答案
EDIT
您想要的是计算 Levenshtein距离。
您可能想查看此问题计算两个NSStrings之间的差异数
这篇关于比较两个NSStrings的相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!