aistra0528 / Hail

Disable / Hide / Suspend / Uninstall Android apps without root.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

switch of fuzzy search

rahaaatul opened this issue · comments

It's showing irrelevant apps in the search:

Screenrecording_20240608_142315.mp4

You can see what I'm searching doesn't match with other apps, but they're still being shown.

They use Levenshtein distance to implement fuzzy search.
If the Levenshtein distance between the two strings is less than the length of the original string and the original string contains each character of the input string in sequence, it will be shown.

https://github.com/aistra0528/Hail/blob/master/app/src/main/kotlin/com/aistra/hail/utils/FuzzySearch.kt#L9

    /**
     * 两个字符串差异小于原始字符串长度 且 原始字符串依次包含输入字符串的每个字符 则显示在搜索结果中
     * @param raw 需要匹配的原始字符串
     * @param query 输入的字符串
     */
    fun search(raw: String?, query: String?): Boolean {
        if (query.isNullOrEmpty()) return true
        if (raw.isNullOrEmpty()) return false
        if (raw.contains(query, true)) return true
        val rawUpp = raw.uppercase()
        val queryUpp = query.uppercase()
        val diff = levenshteinDistance.apply(rawUpp, queryUpp)
        return diff < rawUpp.length && containsInOrder(rawUpp, queryUpp)
    }

I think it is better to make a preference of the fuzzy search for users to decide what they want.

They use Levenshtein distance to implement fuzzy search. If the Levenshtein distance between the two strings is less than the length of the original string and the original string contains each character of the input string in sequence, it will be shown.

https://github.com/aistra0528/Hail/blob/master/app/src/main/kotlin/com/aistra/hail/utils/FuzzySearch.kt#L9

    /**
     * 两个字符串差异小于原始字符串长度 且 原始字符串依次包含输入字符串的每个字符 则显示在搜索结果中
     * @param raw 需要匹配的原始字符串
     * @param query 输入的字符串
     */
    fun search(raw: String?, query: String?): Boolean {
        if (query.isNullOrEmpty()) return true
        if (raw.isNullOrEmpty()) return false
        if (raw.contains(query, true)) return true
        val rawUpp = raw.uppercase()
        val queryUpp = query.uppercase()
        val diff = levenshteinDistance.apply(rawUpp, queryUpp)
        return diff < rawUpp.length && containsInOrder(rawUpp, queryUpp)
    }

I think it is better to make a preference of the fuzzy search for users to decide what they want.

The code is a bit over my head, but I'm on board. Let's skip the fuzzy search as default, but maybe we can have a 'just-in-case' switch for the future if needed.

You can change your title to ask for a switch about fuzzy search.

You can change your title to ask for a switch about fuzzy search.

Don't you think 🐛 Search is not working correctly will catch his attention better?

He'd be like what?! what?! but I fixed it yesterday! 🤣