Reuse typed Kotlin compact helper in BoxTypes
ober
e628ca71af70d947d66879afccbd33e118f3ef8f
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -554,18 +554,18 @@ " fun resolve(context: Context, raw: String): BoxType? {" " val text = raw.trim()" " if (text.isBlank()) return null" - " val normalized = normalize(text)" + " val normalized = compact(text)" " val lowered = text.lowercase()" " val items = load(context)" " items.firstOrNull {" " it.id == text ||" " box_type_display(it).lowercase() == lowered ||" " it.name.lowercase() == lowered ||" - " normalize(it.name) == normalized" + " compact(it.name) == normalized" " }?.let { return it }" " val matches = items.filter {" " box_type_display(it).lowercase().contains(lowered) ||" - " normalize(it.name).contains(normalized)" + " compact(it.name).contains(normalized)" " }" " return matches.singleOrNull()" " }" @@ -574,13 +574,11 @@ " val text = raw.trim()" " if (text.isBlank()) return false" " val resolved = resolve(context, text)" - " val normalized = normalize(resolved?.name ?: text)" + " val normalized = compact(resolved?.name ?: text)" " if (nonWeaponTerms.any { normalized.contains(it) }) return false" " return weaponTerms.any { normalized.contains(it) }" " }" "" - " private fun normalize(value: String): String =" - " value.lowercase().filter { it.isLetterOrDigit() }" "}" )) (kotlin-file-lines "com/sfb/ssdreview/Guessing.kt"