测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最后发布 | 2017年5月 |
Swift Swift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由Kirollos Risk维护。
BitapSearch提供了一个简单的方法来实现模糊搜索。
let bitap = BitapSearch()
let result = bitap.search("od mn war", in: "Old Man's War")
print(result?.score) // 0.44444444444444442
print(result?.ranges) // [CountableRange(0..<0), CountableRange(2..<6), CountableRange(9..<12)]
let bitap = BitapSearch()
let books = ["The Silmarillion", "The Lock Artist", "The Lost Symbol"]
// Improve performance by creating the pattern once
let pattern = bitap.createPattern(from: "Te silm")
books.forEach {
let result = bitap.search(pattern, in: $0)
print(result?.score)
print(result?.ranges)
}
要运行示例项目,首先克隆仓库,然后在Example目录中运行 pod install
。
BitapSearch可以通过CocoaPods使用。为了安装它,只需将以下行添加到您的Podfile
pod "BitapSearch"
Kirollos Risk, [email protected]
BitapSearch可以在MIT许可下使用。有关更多信息,请参阅LICENSE文件。