various fixes and updates

This commit is contained in:
Finnley Somdahl
2023-10-20 21:38:40 -05:00
parent da81646297
commit d1270c7c83
21 changed files with 487 additions and 162 deletions

View File

@@ -1,5 +1,7 @@
package ani.dantotsu.parsers
import ani.dantotsu.logger
class StringMatcher {
companion object {
private fun levenshteinDistance(s1: String, s2: String): Int {
@@ -52,8 +54,10 @@ class StringMatcher {
val closestShowAndIndex = closestShow(target, shows)
val closestIndex = closestShowAndIndex.second
if (closestIndex == -1) {
logger("No closest show found for $target")
return shows // Return original list if no closest show found
}
logger("Closest show found for $target is ${closestShowAndIndex.first.name}")
return listOf(shows[closestIndex]) + shows.subList(0, closestIndex) + shows.subList(closestIndex + 1, shows.size)
}