diff options
| author | 2023-05-28 21:06:37 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:06:04 -0700 | |
| commit | bfb4e3bcaa0b11d824bc2b273a158e28b9cd608c (patch) | |
| tree | 06314ec372ac6b8c154e35bcc9736b5ea0966b85 /src | |
| parent | android: Stop building x86 packages in APKs (diff) | |
| download | yuzu-bfb4e3bcaa0b11d824bc2b273a158e28b9cd608c.tar.gz yuzu-bfb4e3bcaa0b11d824bc2b273a158e28b9cd608c.tar.xz yuzu-bfb4e3bcaa0b11d824bc2b273a158e28b9cd608c.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt | 3 |
1 files changed, 2 insertions, 1 deletions
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 | |||
| 19 | import androidx.fragment.app.activityViewModels | 19 | import androidx.fragment.app.activityViewModels |
| 20 | import androidx.preference.PreferenceManager | 20 | import androidx.preference.PreferenceManager |
| 21 | import info.debatty.java.stringsimilarity.Jaccard | 21 | import info.debatty.java.stringsimilarity.Jaccard |
| 22 | import info.debatty.java.stringsimilarity.JaroWinkler | ||
| 22 | import org.yuzu.yuzu_emu.R | 23 | import org.yuzu.yuzu_emu.R |
| 23 | import org.yuzu.yuzu_emu.YuzuApplication | 24 | import org.yuzu.yuzu_emu.YuzuApplication |
| 24 | import org.yuzu.yuzu_emu.adapters.GameAdapter | 25 | import org.yuzu.yuzu_emu.adapters.GameAdapter |
| @@ -150,7 +151,7 @@ class SearchFragment : Fragment() { | |||
| 150 | } | 151 | } |
| 151 | 152 | ||
| 152 | val searchTerm = binding.searchText.text.toString().lowercase(Locale.getDefault()) | 153 | val searchTerm = binding.searchText.text.toString().lowercase(Locale.getDefault()) |
| 153 | val searchAlgorithm = Jaccard(2) | 154 | val searchAlgorithm = if (searchTerm.length > 1) Jaccard(2) else JaroWinkler() |
| 154 | val sortedList: List<Game> = filteredList.mapNotNull { game -> | 155 | val sortedList: List<Game> = filteredList.mapNotNull { game -> |
| 155 | val title = game.title.lowercase(Locale.getDefault()) | 156 | val title = game.title.lowercase(Locale.getDefault()) |
| 156 | val score = searchAlgorithm.similarity(searchTerm, title) | 157 | val score = searchAlgorithm.similarity(searchTerm, title) |