Move SSD detection session construction to typed Kotlin
ober
588057d8862e73f518f8bbb58bd9e4f201a033b4
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -548,7 +548,7 @@ SsdSession-cells SsdSession-groups SsdSession-ocrWords SsdSession-suppressedGroups SsdSession-ssdArea SsdSession-ssdArea-set! - ssdSessionOrEmpty ssdSessionAreaOrNone + ssdSessionOrEmpty makeDetectionSession ssdSessionAreaOrNone ssdSessionCellInsideSsdArea ssdSessionGroupInsideSsdArea ssdSessionSuppressedGroupPresent? ssdSessionFindGroupById ssdSessionSelectedGroup @@ -608,6 +608,30 @@ (mutable-list-empty SsdGroup) (nullable-none FloatArray)) (nullable-get session))) + (def (makeDetectionSession (sessionId : String) + (sourceKey : String) + (sourceName : String) + (sourceUri : String) + (page : Int32) + (pageCount : Int32) + (dpi : Int32) + (imageWidth : Int32) + (imageHeight : Int32)) : SsdSession + (make-SsdSession + sessionId + sourceKey + sourceName + sourceUri + page + pageCount + dpi + imageWidth + imageHeight + (mutable-list-empty SsdCell) + (mutable-list-empty SsdGroup) + (mutable-list-empty OcrWord) + (mutable-list-empty SsdGroup) + (nullable-none FloatArray))) (def (ssdSessionAreaOrNone (session : (Nullable SsdSession))) : (Nullable FloatArray) (if (nullable-null? session) (nullable-none FloatArray) @@ -7082,21 +7106,16 @@ " try {" " if (isStaleLoad(expectedGeneration, uri, expectedPageIndex)) return@thread" " val key = sourceKey(expectedPdfSha1, expectedPageIndex + 1, DPI)" - " val session = SsdSession(" - " sessionId = sessionIdFromUuid(UUID.randomUUID().toString())," - " sourceKey = key," - " sourceName = expectedPdfName," - " sourceUri = uri.toString()," - " page = expectedPageIndex + 1," - " pageCount = expectedPageCount," - " dpi = DPI," - " imageWidth = bitmap.width," - " imageHeight = bitmap.height," - " cells = mutableListOf()," - " groups = mutableListOf()," - " ocrWords = mutableListOf()," - " suppressedGroups = mutableListOf()," - " ssdArea = null" + " val session = makeDetectionSession(" + " sessionIdFromUuid(UUID.randomUUID().toString())," + " key," + " expectedPdfName," + " uri.toString()," + " expectedPageIndex + 1," + " expectedPageCount," + " DPI," + " bitmap.width," + " bitmap.height" " )" "" " val localTruth = localTruthForDetection(truthStore, session, forceDetect)"