From 259668655cda00ec0808535c2d273e667a65ecd7 Mon Sep 17 00:00:00 2001 From: Sean DeNigris Date: Thu, 29 Oct 2020 06:53:33 -0400 Subject: [PATCH] Issue #26: OCR 2nd Pass Guided by User (WIP) It seems we have a good hook set up, now to implement the second pass --- .../RlhOCRElement.class.st | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ResourcesLive-GToolkit/RlhOCRElement.class.st b/src/ResourcesLive-GToolkit/RlhOCRElement.class.st index fd6a450..ba79aea 100644 --- a/src/ResourcesLive-GToolkit/RlhOCRElement.class.st +++ b/src/ResourcesLive-GToolkit/RlhOCRElement.class.st @@ -29,10 +29,8 @@ RlhOCRElement >> addShortcuts [ build. shortcut := BlShortcut new combination: keyCombo; - action: [ :anEvent :aShortcut | - self client - write: (desc fromString: self selectedText) - using: desc. ]. + action: [ :anEvent :aShortcut | self applySelectedTextTo: desc ]; + yourself. self addShortcut: shortcut ] ] @@ -57,6 +55,18 @@ RlhOCRElement >> add_hOCR [ self addEventHandler: self selectionHandler ] +{ #category : #accessing } +RlhOCRElement >> applySelectedTextTo: desc [ + "Adaptation of MADescription>>#validate:, which is the main access point to validation i.e. all roads (e.g. mementos, forms) ultimately end up here. We're partially reimplementing instead of sending it ourselves because Magritte does not seem to really be set up to interact with element descriptions individually, but through their containers. In this case, the container supplies the proper validator for the domain object" + + [ self client magritteDescription validator + on: (desc fromString: self selectedText) + description: desc ] + on: MAError + do: [ Halt now. "Try to OCR again based on desc" ]. + self client write: (desc fromString: self selectedText) using: desc +] + { #category : #accessing } RlhOCRElement >> client [ ^ client