伊夫利特 (Ifrit)

https://github.com/ukushu/Ifrit.git
git@github.com:ukushu/Ifrit.git

什么是伊夫利特 (Ifrit)?

伊夫利特 (Ifrit) 是一个用纯 Swift 编写的模糊搜索库。

什么是模糊搜索?

模糊搜索算法旨在为给定的搜索查询找到近似匹配项。

假设你有一个产品列表,并且用户正在寻找“Czy Swetr”。精确匹配将返回任何内容,但模糊搜索会找到“Cozy Sweater”。

如果需要精确匹配 - 需要使用标准函数 .filter { } 而不是这个库。

模糊搜索演示

Ifrit demo

伊夫利特 (Ifrit) 的优点/缺点

Advanteges:
+ Super lightweight
+ No dependencies
+ OS supported: MacOS(>=v10_15), iOS(>=v13), visionOS, watchOS, twOS, Linux
+ Asynchronous search ( async/await + callbacks both )
+ Text highlight support (AttributedString)
+ Covered with automated tests
+ MIT Licensed
+ Ability to link Ifrit as Static and Dynamic package - choose what is better in your case

Disadvantages:
- Wasn't tested in production
- Swift 5.9 and higher, older version of Swift does not supported.

该存储库基于 KRisk 的存档存储库 Fuse-Swift: https://github.com/krisk/fuse-swift

Swift Package Index 信息: https://swiftpackageindex.cn/ukushu/Ifrit

区别:伊夫利特 (Ifrit) VS Fuze-Swift?

+ Fuze-Swift support Pods and Packages :)
- Ifrit supports only Packages :(

- Fuze-Swift is dead :(
+ Ifrit is a Fuse-Swift reborn from hell and ALIVE as ever :)

- Fuze-Swift supports async functins with callbacks, but does not support async/await
+ Ifrit supports callbacks and async/await both:)

- Fuze-Swift have async/multithreading issues. Crashes is possible :(
+ Ifrit is a Fuze-Swift with fixed multithreading issues - no crashes :)

- Fuze-Swift async functions returns incorrect results (wrong indexes) :((((
+ Ifrit's async functins returns correct indexes and covered with tests :)

- Fuze-Swift written for xcode 11 and have a lot of warnings at now :(
+ Ifrit code is updated to swift's latest standards and there are no build warnings :)

- Fuze-Swift always search for "average score" inside of objects array value :(
+ Ifrit have sorting strategy for search by array property in object. 
+          Choose between "average score" and "minimal score". :) Default is "minimal"

+ Ifrit - extended coverage with automated tests in general :)
+ Ifrit have additional search system using Levenstain distance algorythm :)
+ Ifrit have ability to search by several templates
+ Ifrit have a little bit changed syntax to be more flexible.
+ Ifrit's sync search faster than Fuse's on 2% (standard settings) using M1 processor.
+         Async search have tha same speed (standard settings).

贡献

伊夫利特 (Ifrit) 欢迎以 GitHub issue 和 pull-request 的形式进行贡献。

安装

  1. XCode -> 菜单栏 -> Add Package Dependencies -> https://github.com/ukushu/Ifrit.git

  2. import Ifrit 添加到你的源文件中。

文档 / 说明 / 示例项目

伊夫利特 (Ifrit) 仓库没有示例项目。使用下面的说明

如何使用伊夫利特 (Ifrit) 的 Fuse

如何使用伊夫利特 (Ifrit) 的 Levenstain

如何在 UI 中显示搜索结果