A better design for OMR extraction with KTM (Part 1)

Optical Markup Recognition seems to be a little bit old-school, but every once in a while you have to deal with questionnaires or forms. My goal for today is to optimize OMR – not by the means of recognition, but by evaluating and re-designing the whole concept.

Single Choice OMR

Single Choice OMR is pretty obvious: there are multiple checkboxes, but only one answer is allowed – such as the question for your sex or your nationality. Here is an example:

SingleChoice

I won’t be talking much about the best way on how to set up an Advanced Zone Locator in KTM, because most of you may know that already. I just want to make you aware of a great KTM Wiki article that can save you a lot of time setting up OMR zones, especially if you have several dozens of them. The basic idea is to let KTM search for checkboxes, and create the zones for you.

Let’s go back to the bigger picture: the Advanced Zone Locator does something like that:

AZL

So, the result is a 7-digit string value, option A in the image below. Nothing fancy, and definitely nothing useful, especially if you think about your colleagues performing validation. But we can do better than that – see option B.

Validation-Options

This drop-down will make your results more readable and easier to correct in validation. But how to translate the string into a word? My suggestion is shown in the image below. As one would also apply dictionaries in such a case, why not translating the string into an already present value of the dictionary?

OMR-concept

Basically I am applying two functions: one to translate from the AZL result into an index, and the other one to translate from the index to the appropriate word in the dictionary. However there are three unique possible errors that could occur. The script deals with those issues as well.

Problem 1: Multiple Selections

OMR-invalid

Problem 2: Uncertain Fields

OMR-uncertain

Problem 3: Nothing selected

OMR-nothing-selected

 

The Scripts

All the magic is done by the scripts. Those guys link the result from the AZL with an item out of a dictionary.

OMRSingleChoiceIndex:

‘ Recieves OMR group zones information (e.g.: 0|1|0|0|0) and returns the index of the marked zone (single choice)
‘ Returns -1 if: no zone is marked (nothing is selected)
‘ Returns -2 if: more than one zone were selected
‘ Returns -3 if: at least one uncertain marking is present

OMRSingleChoiceText:

‘ Recieves OMR group zones information (e.g.: 0|1|0|0|0) and returns the mapped text of a dictionary
‘ the item with index 0 in the omrValues will be mapped with the item with index 0 in the dictionary
‘ if indicateError = true, then the first 3 values are reserved and must be present in the dictionary:
‘ item 1: error text if at least one uncertain marking is present –> e.g. “- uncertain -”
‘ item 2: error text if more than one zone were selected –> e.g. “- invalid multiple selection -”
‘ item 3: error text if no zone is marked (nothing is selected) –> e.g. “- nothing selected -”

DictionaryToArray:

A small helper to fetch all dictionary items into an array (KTM still does not offer that by default).

Mapping the result with a field should be done in another script. So long for part 1!