Simple replace missread character from ZoneOCR result

  • 256 Views
  • Last Post 05 January 2022
Anders Hantveit posted this 17 December 2021

Hello

I'm trying to use the "replace script" from this location https://forum.scanshare.com/thread/script-replace-specific-character-in-string/ to replace my missread characters from the OCR text (Zone OCR).

I can't get the script to work even with minor simple changes, it ends up as error in the log.

Detailed | Script engine finished, result: -1983
Error | The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

Since I'm not very skillful in scripting, but normally understand enough to make minor changes to simple scripts....anyone can guide me in the right direction (even more than the sample script ) of just using this script to replace "O" to "0" (and possible other characters as well) for the whole text (in this case 17 characters) put via the script?

Thanks in advance

Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS

Order By: Standard | Newest | Votes
luca.scarpati posted this 17 December 2021

Hi Anders,

 

the error below due to some exception inside your VBS script that crashes and generates no error message, just this exception.

So the above script get a string part of the variable, checks if it needs to be changed with RegExp part and Replace the character in the various possible position.

 

I think your case is much simpler, for example for "O" to "0":

      zone = Metadata.Values("YOURVARIABLE")

      modzone = Replace(zone, "O", "0")

      call Metadata.SetValues("YOURNEWVARIABLE", modzone)

 

Just for info you can also use a JS script (available from some versions, much faster respect VBS and much detailed in case of error), or again instead of using the ocr zone have you tried the SmartOCR? innocent

 

Have a nice day and in case of you need specific support please feel free to contact our support.

 

Best regards,

Luca

 

  • Liked by
  • Anders Hantveit
Anders Hantveit posted this 17 December 2021

Hello!

I'm so grateful for these quick replies of yours. This kind of support is so valuable!

Thanks, your script works great!

btw: I was actually using SmartOCR, I just forgot it because I used ZoneOCR first and then switched to SmartOCR.

 

BR, Anders

Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS

luca.scarpati posted this 17 December 2021

Great Anders and more than welcome as always.

 

Enjoy the weekend cool!

Luca

Anders Hantveit posted this 04 January 2022

Hello again! Seems I need some more help

It works fine with replacing string, but what I noticed now is that when performing splitting for each OrderNumber in the scanned batch, the process of replacing missread characters makes the modified variable "global" for every document in the splitted group.

My workflow is now with "Zone OCR" for automatic splitting every time it detects an ordernumber top right corner.
(I wish Smart OCR could split like Zone OCR)

Then Smart OCR performs detecting of a chassisnumber (and also the ordernumber again).

After Smart OCR, the result for chassisnumber goes through the "replace O to 0" script, and this makes the variable the same result for every next document in the batch.

 

Example below, shows the 3 PDF marked within blue line at the bottom, named correctly (but takes 0 for an O in chassisnumber WB*) without using the replacement variable. The 3 PDF at top (marked within blue line), this is named with the same modified variable for the rest of the files.

 

So my question is: Ho to modify this so that the variable from each document follows the document being splitted?

Thanks

Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS

luca.scarpati posted this 05 January 2022

Hi Anders,

 

I think your problem is in page separation, you do everything in one workflow right?

If yes, It is not the correct way to work, as our process works you first need to separate (in your case by ocr zone).

So you will have two workflows:

  1. Separate the document for automatic splitting every time it detects an ordernumber top right corner -> Output in TIFF as output profile using a WFS
  2. Watchfolder with path the output of 1. and  a Smart OCR and here you can enter the remaining part (SmartOCR, Script and final output in pdf for example)

I hope it is clear if you need anything special steps, please contact the support for more specific detailed.

 

Best regards,

Luca

 

Anders Hantveit posted this 05 January 2022

Hi, yes, everything in one workflow.

Aha, this makes it really complex (for me), as I am using MFP input and lookup in TXT file (script) to grab some info based on the IP-address of the MFP. This metadata (grabbed from the lookup) is again used to determine where in Sharepoint it shall store the output, and also who shall receive e-mail if it does not detect the two zones.

I've used "two-step" workflows other places, but not with metadata transfer...If this has to be done with scripting I'm on thin ice
Maybe I can enter the metadata into filename in step 1, then grab info from filename using "script and split on" in step 2...
Well, I'll look into it, and see if I can solve it.

Thanks for quick reply.

Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS

Anders Hantveit posted this 05 January 2022

Seems I've made it using "two step WorkFlow" now, by entering the MFP IP as part of filename in step 1, then grabbing this IP from filename and use this as lookup reference to grab the needed metadata in the next workflow.

Messy setup, but seems to work

Senior System Engineer, MCS, PRS and IMS ## Konica Minolta Business Solutions Norway AS

  • Liked by
  • luca.scarpati
Close