这些算法是否在 Objective-C 库中实现?
我想知道,这些算法是否在 Objective-C 库中实现用于文本搜索?
- Knutt-Morri-Pratt
- Boyer-Moore
- 有限自动机
I want to know, Are these algorithms implemented in Objective-C Libraries for text search?
- Knutt-Morri-Pratt
- Boyer-Moore
- finite automata
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 CFString.c 中 CFStringFindWithOptionsAndLocale 的源代码,看起来它只实现了简单的搜索。根据文本的大小,您实际上可能会逃脱惩罚。
无论如何,如果您的段落足够大,Boyer-Moore 和 KMP 仍然是线性时间(尽管常数因子较小),您可能需要考虑实现一个简单的基于磁盘的全文索引。我已经为客户的项目做到了这一点,它实际上并不像听起来那么难。
Looking at the source for CFStringFindWithOptionsAndLocale in CFString.c, it seems like it only implements naive search. Depending on how huge the text is, you might actually get away with this.
Regardless, if your passage is sufficiently huge, Boyer-Moore and KMP are still linear time (albeit with a smaller constant factor), you might want to look at implementing a simple disk based full text index. I've done it for a client's project and it really isn't as hard as it sounds.