I'm working on an iOS app. I have a Core Data database with a lot of company names.
我正在开发一款iOS应用。我有一个核心数据数据库,有很多公司名称。
When the user insert a company name that does not exist, I would like to show "similar" company names. For example, if the user entered "Aple", I would like to show "Did you mean Apple?".
当用户插入不存在的公司名称时,我想显示“类似”的公司名称。例如,如果用户输入“Aple”,我想显示“你的意思是苹果吗?”。
I know that the technique of finding strings that match a pattern approximately (rather than exactly) is called approximate string matching or, colloquially, fuzzy string searching.
我知道找到大致(而不是精确)匹配模式的字符串的技术称为近似字符串匹配,或者通俗地说,模糊字符串搜索。
In theory, there are many algorithms, more or less valid: the Levenshtein distance computing algorithm and so on.
理论上,有许多算法,或多或少有效:Levenshtein距离计算算法等。
But in practice, is there someone who has already implemented something similar that can be used easily with core data?
但实际上,是否有人已经实现了类似的东西,可以轻松使用核心数据?
2 个解决方案
#1
1
I found a solution. Use this NSString's category available on GitHub: NSString-DamerauLevenshtein.
我找到了解决方案。使用GitHub上提供的NSString类别:NSString-DamerauLevenshtein。
#2
0
Try looking at Soundex, I believe that is part of the core featureset for SQLite, if that is your underlying data store.
尝试查看Soundex,我相信这是SQLite的核心功能集的一部分,如果这是您的底层数据存储。
#1
1
I found a solution. Use this NSString's category available on GitHub: NSString-DamerauLevenshtein.
我找到了解决方案。使用GitHub上提供的NSString类别:NSString-DamerauLevenshtein。
#2
0
Try looking at Soundex, I believe that is part of the core featureset for SQLite, if that is your underlying data store.
尝试查看Soundex,我相信这是SQLite的核心功能集的一部分,如果这是您的底层数据存储。