ACI Server > Lua Post-Processing

Lua Post-Processing

Topics in this Section

Eduction Server supports Lua post-processing. You can use this to carry out internal consistency checks, or to format your output.
To configure Lua post-processing tasks, you must specify the number of tasks and task names in the [PostProcessingTasks] section of the configuration file, for example:
[PostProcessingTasks]
numTasks=2
task0=checksum
task1=filterscore
 
Each task must also have its own section in the configuration file, for example:
[checksum]
type=lua
script=./scripts/checksum.lua
entities=number/creditcard
 
You must define a processmatch function in your script:
function processmatch (edkmatch)
where edkmatch is the object to match. This returns a Boolean value; set this to true to keep the match, or false to discard it.
The following methods and parameters are available:
*
edkmatch:getEntityName(), edkmatch:setEntityName(new_name)
*
edkmatch:getOutputText(), edkmatch:setOutputText(new_text)
*
edkmatch:getMatchedText(), edkmatch:setMatchedText(new_text)
*
*
edkmatch:getOffsetLength(), edkmatch:setOffsetLength(new_length)
*
*
*
The getComponent method returns the component object, which you can use in your scripts as follows:
*
*
The addComponent method adds a component object with the specified name, offset, and offset length to the match. The component text is the empty string, which you can edit later using the edkcomponent:setText(text) function.
*
Eduction also includes a sample Lua post-processing script, checksum_luhn.lua. This verifies the checksum digit of each match using the Luhn algorithm, and reduces the score associated with the match if the checksum is wrong. You can use this script to validate most credit card numbers, or you can use it as a reference if you wish to write your own scripts.