improvement: Prioritize correct URL during forming suggestions a bit more

This commit is contained in:
Artem Chepurnyi 2024-12-14 18:34:46 +02:00
parent 6538c1d13e
commit 0d2eb37cd9
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E

View File

@ -271,7 +271,7 @@ class GetSuggestionsImpl(
} }
avgScore /= avgSize.coerceAtLeast(1) avgScore /= avgSize.coerceAtLeast(1)
val threshold = val threshold =
if (maxScore >= 10f) maxScore.div(3f).coerceAtLeast(10f) else avgScore / 1.5f if (maxScore >= 10f) maxScore.div(2.25f).coerceAtLeast(10f) else avgScore / 1.5f
Log.e("SuggestionsTest", "threshold $threshold") Log.e("SuggestionsTest", "threshold $threshold")
c c
.filter { (score, _) -> score >= threshold && score > scoreThreshold } .filter { (score, _) -> score >= threshold && score > scoreThreshold }
@ -356,7 +356,7 @@ private fun GetSuggestionsImpl.AutofillTargetAndroid.findByApp(
uri.match != DSecret.Uri.MatchType.Never uri.match != DSecret.Uri.MatchType.Never
} }
.let { directMatch -> .let { directMatch ->
if (directMatch) 30f else 0f if (directMatch) 35f else 0f
} }
val scoreByName = appNameTokens?.let { val scoreByName = appNameTokens?.let {
findAlike( findAlike(
@ -395,13 +395,13 @@ private suspend fun GetSuggestionsImpl.AutofillTargetWeb.findByWebDomain(
@Suppress("MoveVariableDeclarationIntoWhen") @Suppress("MoveVariableDeclarationIntoWhen")
val matchType = uri.match ?: defaultMatchDetection val matchType = uri.match ?: defaultMatchDetection
when (matchType) { when (matchType) {
DSecret.Uri.MatchType.Domain -> 10f DSecret.Uri.MatchType.Domain -> 15f
DSecret.Uri.MatchType.Host -> 20f DSecret.Uri.MatchType.Host -> 20f
DSecret.Uri.MatchType.StartsWith -> 25f DSecret.Uri.MatchType.StartsWith -> 25f
DSecret.Uri.MatchType.Exact -> 25f DSecret.Uri.MatchType.Exact -> 25f
DSecret.Uri.MatchType.RegularExpression -> 30f DSecret.Uri.MatchType.RegularExpression -> 27f
DSecret.Uri.MatchType.Never -> 0f DSecret.Uri.MatchType.Never -> 0f
} } * 1.6f
} else { } else {
0f 0f
} }
@ -415,7 +415,7 @@ private suspend fun GetSuggestionsImpl.AutofillTargetWeb.findByWebDomain(
request = webHost, request = webHost,
) )
if (match) { if (match) {
20f 30f
} else { } else {
0f 0f
} }
@ -427,5 +427,5 @@ private suspend fun GetSuggestionsImpl.AutofillTargetWeb.findByWebDomain(
tokens, tokens,
webUrlTokens, webUrlTokens,
) )
scoreByHost * 2f + scoreByUri + scoreByRpId scoreByHost * 1.8f + scoreByUri + scoreByRpId
} }