Move SSD learned suppression helpers to typed Kotlin

ober

c6ed78da47d9462b8ed36a28d33397a5b660907e

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index f2bb357..e0c4169 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -367,7 +367,8 @@
     (typed-kotlin-file "com/sfb/ssdreview/OcrStrings.kt"
       (typed-library (com sfb ssdreview)
         (export normalizeOcr compact ocrTokenMatches
-                bankCompatible suppressedByRace shouldReplaceOcrLabel)
+                bankCompatible isPaPanelExample isShieldLabel
+                suppressedByRace shouldReplaceOcrLabel)
         (def (normalizeOcr (value : String)) : String
           (string-replace-regex
             (string-trim
@@ -397,6 +398,14 @@
                 (or (or (string-contains? key "papanel")
                         (string-contains? key "powerabsorber"))
                     (string-contains? key "padegradation")))))
+        (def (isPaPanelExample (label : String) (boxTypeId : String)) : Bool
+          (let ((key (compact label)))
+            (or (or (equal? boxTypeId "52")
+                    (equal? boxTypeId "99"))
+                (or (string-contains? key "papanel")
+                    (string-contains? key "padegradation")))))
+        (def (isShieldLabel (label : String)) : Bool
+          (string-contains? (compact label) "shield"))
         (def (suppressedByRace (race : String) (label : String)) : Bool
           (let ((key (compact label)))
             (if (and (equal? race "andromedan") (string-contains? key "shield"))
@@ -4918,39 +4927,15 @@
        "    private fun suppressedLearnedExample(session: SsdSession, example: JSONObject): Boolean {"
        "        val label = example.optString(\"label\")"
        "        val boxTypeId = example.optString(\"box_type_id\")"
-       "        val andromedan = isAndromedanSource(session)"
+       "        val andromedan = raceKey(\"${session.sourceName} ${session.sourceUri}\") == \"andromedan\""
        "        if (!andromedan && isPaPanelExample(label, boxTypeId)) return true"
-       "        if (andromedan && label.lowercase().contains(\"shield\")) return true"
+       "        if (andromedan && isShieldLabel(label)) return true"
        "        return false"
        "    }"
        ""
        "    private fun suppressedLearnedForGroup(group: SsdGroup, example: JSONObject): Boolean {"
-       "        if (!isBankLabel(group.label, group.boxTypeId)) return false"
-       "        return !isBankLabel(example.optString(\"label\"), example.optString(\"box_type_id\"))"
-       "    }"
-       ""
-       "    private fun isAndromedanSource(session: SsdSession): Boolean {"
-       "        val text = \"${session.sourceName} ${session.sourceUri}\".lowercase()"
-       "        return text.contains(\"andromedan\") || text.contains(\"module_c3\") || text.contains(\"module c3\")"
-       "    }"
-       ""
-       "    private fun isPaPanelExample(label: String, boxTypeId: String): Boolean {"
-       "        val normalized = label.lowercase().filter { it.isLetterOrDigit() }"
-       "        return boxTypeId == \"52\" ||"
-       "            boxTypeId == \"99\" ||"
-       "            normalized.contains(\"papanel\") ||"
-       "            normalized.contains(\"padegradation\")"
-       "    }"
-       ""
-       "    private fun isBankLabel(label: String, boxTypeId: String): Boolean {"
-       "        val normalized = label.lowercase().filter { it.isLetterOrDigit() }"
-       "        return boxTypeId == \"26\" ||"
-       "            boxTypeId == \"52\" ||"
-       "            boxTypeId == \"99\" ||"
-       "            normalized.contains(\"shield\") ||"
-       "            normalized.contains(\"papanel\") ||"
-       "            normalized.contains(\"powerabsorber\") ||"
-       "            normalized.contains(\"padegradation\")"
+       "        if (!bankCompatible(group.label, group.boxTypeId)) return false"
+       "        return !bankCompatible(example.optString(\"label\"), example.optString(\"box_type_id\"))"
        "    }"
        "}"
        ""