From bfb4e3bcaa0b11d824bc2b273a158e28b9cd608c Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sun, 28 May 2023 21:06:37 -0400 Subject: android: Improve searches with one character The Jaccard algorithm is great for searches with 2 or more characters but nothing is returned for searches with one character. To get around this, just search with JaroWinkler for single character searches. --- .../app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt index eb4f513d1..ebc0f164a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt @@ -19,6 +19,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.preference.PreferenceManager import info.debatty.java.stringsimilarity.Jaccard +import info.debatty.java.stringsimilarity.JaroWinkler import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.YuzuApplication import org.yuzu.yuzu_emu.adapters.GameAdapter @@ -150,7 +151,7 @@ class SearchFragment : Fragment() { } val searchTerm = binding.searchText.text.toString().lowercase(Locale.getDefault()) - val searchAlgorithm = Jaccard(2) + val searchAlgorithm = if (searchTerm.length > 1) Jaccard(2) else JaroWinkler() val sortedList: List = filteredList.mapNotNull { game -> val title = game.title.lowercase(Locale.getDefault()) val score = searchAlgorithm.similarity(searchTerm, title) -- cgit v1.2.3