mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45: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 {
|
when {
|
||||||
// It's the second best possible match if it start with
|
// It's the second best possible match if it start with
|
||||||
unitFullName.startsWith(stringToCompare) -> {
|
unitFullName.startsWith(stringToCompare) -> {
|
||||||
unitsWithDist.add(Pair(unit, 1))
|
unitsWithDist.add(Pair(unit, 0))
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
// It's a little bit worse when it just contains part of the query
|
// It's a little bit worse when it just contains part of the query
|
||||||
unitFullName.contains(stringToCompare) -> {
|
unitFullName.contains(stringToCompare) -> {
|
||||||
unitsWithDist.add(Pair(unit, 2))
|
unitsWithDist.add(Pair(unit, 1))
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,9 +174,9 @@ class TimeZonesRepository @Inject constructor(
|
|||||||
query: String,
|
query: String,
|
||||||
levThreshold: Int,
|
levThreshold: Int,
|
||||||
): 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
|
val levDist = prop
|
||||||
.substring(0, minOf(query.length, prop.length))
|
.substring(0, minOf(query.length, prop.length))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user