Move SSD learned guess detection branch to typed Kotlin

ober

bb8cb37c517bfb8c362fae833f7b5a7b5052b875

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index e85c7d3..a23773f 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -4568,7 +4568,8 @@
                 localTruthForDetection existingTruthForDetection
                 shouldUseExistingTruth shouldApplyExistingTruth
                 shouldUseExistingTruthObject shouldApplyExistingTruthObject
-                shouldApplyLearnedGuesses shouldMergeRemoteTruth
+                shouldApplyLearnedGuesses learnedGuessesForDetection
+                shouldMergeRemoteTruth
                 shouldMergeRemoteTruthObject detectionTruthNoteFor
                 reviewPrimaryColor reviewWhiteColor reviewLabelTextColor
                 reviewLabelBackgroundColor reviewCanvasBackgroundColor
@@ -4625,6 +4626,9 @@
         (extern (truthStoreLoadTruth (store : TruthStore)
                                      (session : SsdSession)) : (Nullable JSONObject)
           (kotlin-member-call loadTruth))
+        (extern (truthStoreApplyLearnedGuesses (store : TruthStore)
+                                               (session : SsdSession)) : Int32
+          (kotlin-member-call applyLearnedGuesses))
         (extern (reviewViewCaptureViewport (view : SsdReviewView)) : (Nullable ViewportState)
           (kotlin-member-call captureViewport))
         (def (normalizeFiringArc (value : String)) : String
@@ -5302,6 +5306,12 @@
                (shouldApplyExistingTruth existingTruthGroupCount)))
         (def (shouldApplyLearnedGuesses (existingTruthGroupCount : Int32)) : Bool
           (= existingTruthGroupCount (int32 0)))
+        (def (learnedGuessesForDetection (store : TruthStore)
+                                         (session : SsdSession)
+                                         (existingTruthGroupCount : Int32)) : Int32
+          (if (shouldApplyLearnedGuesses existingTruthGroupCount)
+            (truthStoreApplyLearnedGuesses store session)
+            (int32 0)))
         (def (shouldMergeRemoteTruth (hasExistingTruth : Bool)
                                      (forceDetect : Bool)) : Bool
           (and (not hasExistingTruth) (not forceDetect)))
@@ -7121,7 +7131,7 @@
        "                    session.ocrWords.addAll(SsdOcr.recognizeWords(bitmap))"
        "                    ocrGuesses = applyOcrGuesses(this, session, SsdOcr.patterns)"
        "                }"
-       "                val learnedGuesses = if (shouldApplyLearnedGuesses(existingTruthGroupCount)) truthStore.applyLearnedGuesses(session) else 0"
+       "                val learnedGuesses = learnedGuessesForDetection(truthStore, session, existingTruthGroupCount)"
        "                runOnUiThread {"
        "                    if (isStaleLoad(expectedGeneration, uri, expectedPageIndex)) return@runOnUiThread"
        "                    currentSession = session"