xdrop/fuzzywuzzy

Thanks for the Library, Here's How I Used It!

rayliverified opened this issue · 2 comments

Great Library and great work @xdrop ! Thank you so much for creating something that works for Android and sharing it! This library does something I have no idea how to do and would take me countless hours to create :D

Initially, I could not figure out a way to use the library. I have a SQLite database full of text values that I want to search. Unfortunately, neither SQL nor this library has an interface to do fuzzy search without a Full Table Search. Thankfully, I found a great workaround that uses my current dependencies.

This library works great with FlexibleAdapter (https://github.com/davideas/FlexibleAdapter). FlexibleAdapter has a builtin Async filtering mechanism that is extremely fast. Using the code below, I am able to filter my entire listview smoothly and with animations!

    @Override
    public boolean filter(String constraint) {
        Integer fuzzyRatio = FuzzySearch.partialRatio(title.toLowerCase(), constraint.toLowerCase());
        Log.d("Fuzzy Search Ratio", String.valueOf(fuzzyRatio));
        if (fuzzyRatio >= 70 || title.toLowerCase().trim().contains(constraint))
            return true;
        return false;
    }

I find that 70 is a really good value when using partial ratio.
Thanks to this library, I can provide an experience rivaling Google and Facebook! 🥇

xdrop commented

Thank you for your words @searchy2!

I'm glad you find it useful and it has worked well for your project. 😃 If you have any suggestions/issues with it I'd be happy to address them.

I'll drop you a link to the published app if you don't mind ;)