Move SSD OCR string helpers to typed Kotlin

ober

d71cf03b9d25ca8ac41c8a356a9c7db85b439b77

diff --git a/.build.yml b/.build.yml
index 1cfa6da..b3ecfdb 100644
--- a/.build.yml
+++ b/.build.yml
@@ -5,7 +5,7 @@ packages:
   - make=4.4.1-r4
 sources:
   # Build dependency: full immutable commit, mirrored in dependencies.lock.json.
-  - "https://git.sr.ht/~lisp/jerboa#ac1666a396e49cc6cc7df24669fc68a7075e8439"
+  - "https://git.sr.ht/~lisp/jerboa#d18e446827df749d11ab9b84c6a3602a40ed9ffa"
   # The second source is the build subject selected by the SourceHut submitter.
   - https://git.sr.ht/~lisp/jerboa-android
 tasks:
@@ -14,6 +14,6 @@ tasks:
       test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2
       test "$(apk info -v git)" = git-2.54.0-r0
       test "$(apk info -v make)" = make-4.4.1-r4
-      test "$(git -C ../jerboa rev-parse HEAD)" = ac1666a396e49cc6cc7df24669fc68a7075e8439
-      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = c131825cfad0ca160b0e7e0347157fef7ebedf1e
+      test "$(git -C ../jerboa rev-parse HEAD)" = d18e446827df749d11ab9b84c6a3602a40ed9ffa
+      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = a6ca4d76314ba0b773011f6185f822563e1647dd
       JERBOA="chez --libdirs .:../jerboa/lib --script" make test
diff --git a/dependencies.lock.json b/dependencies.lock.json
index e132165..fd907aa 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -11,8 +11,8 @@
   "generator_runtime": {
     "name": "jerboa",
     "repository": "https://git.sr.ht/~lisp/jerboa",
-    "commit": "ac1666a396e49cc6cc7df24669fc68a7075e8439",
-    "tree": "c131825cfad0ca160b0e7e0347157fef7ebedf1e"
+    "commit": "d18e446827df749d11ab9b84c6a3602a40ed9ffa",
+    "tree": "a6ca4d76314ba0b773011f6185f822563e1647dd"
   },
   "assurance_tools": {
     "osv_scanner": {
diff --git a/full-kotlin.md b/full-kotlin.md
index 5178581..0e431bf 100644
--- a/full-kotlin.md
+++ b/full-kotlin.md
@@ -43,7 +43,7 @@ The vendored Jerboa tree already has the right starting point:
 
 Do not fork that model inside `jandroid.ss`. General Kotlin backend work belongs in Jerboa. Android project and Android DSL work belongs in `jerboa-android`.
 
-Version caveat: this repository now pins Jerboa commit `ac1666a396e49cc6cc7df24669fc68a7075e8439`, tree `c131825cfad0ca160b0e7e0347157fef7ebedf1e`. Before editing compiler APIs, check out the exact pinned commit (or the intended replacement commit), rerun the typed parser/checker/core inventory, and record any differences. Do not assume two Jerboa snapshots expose identical IR.
+Version caveat: this repository now pins Jerboa commit `d18e446827df749d11ab9b84c6a3602a40ed9ffa`, tree `a6ca4d76314ba0b773011f6185f822563e1647dd`. Before editing compiler APIs, check out the exact pinned commit (or the intended replacement commit), rerun the typed parser/checker/core inventory, and record any differences. Do not assume two Jerboa snapshots expose identical IR.
 
 ### 2.3 `~/sfb` source requirements
 
diff --git a/scripts/verify-supply-chain.sh b/scripts/verify-supply-chain.sh
index d29c17b..ff53ba8 100755
--- a/scripts/verify-supply-chain.sh
+++ b/scripts/verify-supply-chain.sh
@@ -3,8 +3,8 @@ set -eu
 
 repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)
 lock="$repo/dependencies.lock.json"
-jerboa_commit=ac1666a396e49cc6cc7df24669fc68a7075e8439 # gitsafe:ignore
-jerboa_tree=c131825cfad0ca160b0e7e0347157fef7ebedf1e # gitsafe:ignore
+jerboa_commit=d18e446827df749d11ab9b84c6a3602a40ed9ffa # gitsafe:ignore
+jerboa_tree=a6ca4d76314ba0b773011f6185f822563e1647dd # gitsafe:ignore
 gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336
 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331
diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 372e422..590bd1b 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -364,6 +364,21 @@
            (confidence : Float32)
            (reason : String)))))
 
+    (typed-kotlin-file "com/sfb/ssdreview/OcrStrings.kt"
+      (typed-library (com sfb ssdreview)
+        (export normalizeOcr compact)
+        (def (normalizeOcr (value : String)) : String
+          (string-replace-regex
+            (string-trim
+              (string-replace-regex
+                (string-uppercase value)
+                "[^A-Z0-9]+"
+                " "))
+            "\\s+"
+            " "))
+        (def (compact (value : String)) : String
+          (string-filter-letter-or-digit (string-lowercase value)))))
+
     (kotlin-file-lines "com/sfb/ssdreview/BoxTypes.kt"
       (
        "package com.sfb.ssdreview"
@@ -3205,12 +3220,6 @@
        "        return false"
        "    }"
        ""
-       "    private fun normalizeOcr(value: String): String = value.uppercase()"
-       "        .replace(Regex(\"[^A-Z0-9]+\"), \" \")"
-       "        .trim()"
-       "        .replace(Regex(\"\\\\s+\"), \" \")"
-       ""
-       "    private fun compact(value: String): String = value.lowercase().filter { it.isLetterOrDigit() }"
        "}"
        ))
     (kotlin-file-lines "com/sfb/ssdreview/SsdReviewView.kt"