mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Tune search ranking
This commit is contained in:
parent
ef5dc177b2
commit
5b04cb4f42
@ -71,12 +71,12 @@ fun Sequence<AbstractUnit>.filterByLev(stringA: String, context: Context): Seque
|
||||
when {
|
||||
// It's the second best possible match if it start with
|
||||
unitFullName.startsWith(stringToCompare) -> {
|
||||
unitsWithDist.add(Pair(unit, 1))
|
||||
unitsWithDist.add(Pair(unit, 0))
|
||||
return@forEach
|
||||
}
|
||||
// It's a little bit worse when it just contains part of the query
|
||||
unitFullName.contains(stringToCompare) -> {
|
||||
unitsWithDist.add(Pair(unit, 2))
|
||||
unitsWithDist.add(Pair(unit, 1))
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
|
@ -174,9 +174,9 @@ class TimeZonesRepository @Inject constructor(
|
||||
query: String,
|
||||
levThreshold: Int,
|
||||
): Int? {
|
||||
if (prop.startsWith(query, true)) return 1
|
||||
if (prop.startsWith(query, true)) return 0
|
||||
|
||||
if (prop.contains(query, true)) return 2
|
||||
if (prop.contains(query, true)) return 1
|
||||
|
||||
val levDist = prop
|
||||
.substring(0, minOf(query.length, prop.length))
|
||||
|
Loading…
x
Reference in New Issue
Block a user