How to build a search filter that validates even partially incorrect values?

Viewed 15

I've been using a SearchView in order to filter items in a RecyclerView, however I'm only validating strings containing the value of the string I filter with. What I want is to be able to validate strings even if there are some missclicks and 1/2 letters are incorrect (for example if I wrote "Hellp World" instead of "Hello World" I still wanna have the "Hello World" string to be valid).

I've been searching how to do that for a while, and the only thing I found was using a phonetic match for the strings, and then filter using that, but I couldn't find how to implement it in Kotlin, I only saw it used in PHP, and I don't even think it really does what I want.

I've had a hard time putting my need into words so I hope this is clear.

My current filter is taking a list of strings and filtering based on if the search value is contained in these strings, like so:

val filteredList = ArrayList<ShowModel>()
for(str in stringsList) {
    if(str.lowercase().contains(filterPattern)) {
        filteredList.add(str)
    }
}

How should I go about building a less picking search filter ?

0 Answers
Related