Lua Post Processing
A Named Entity Recognition Lua Post Processing task runs a Lua script that modifies the output from the Named Entity Recognition module. For example, you might want to increase the score for a match if it is found near similar matches.
NOTE: The Lua script is run by the Named Entity Recognition module, not by CFS. The Named Entity Recognition module expects the script to start with function processmatch (edkmatch)
. You cannot modify the document being processed by CFS, or use the Lua methods that are available to CFS Lua scripts. For information about the Lua methods that are available in the Named Entity Recognition module, refer to the Named Entity Recognition User and Programming Guide.
To create a Named Entity Recognition Lua Post Processing task, set the PostProcessingTaskN
parameter. This specifies the name of a section in the CFS configuration file that contains parameters to configure the task. For example:
[ImportTasks] Post0=Eduction:EductionSettings [EductionSettings] ResourceFiles=C:\MyGrammar\gram1.ecr SearchFields=DRECONTENT Entity0=edk_common_entities/postal_address EntityField0=SHIPPING_ADDRESS PostProcessingTask0=EductionLuaPostProcessing [EductionLuaPostProcessing] Script=scripts/eduction_post_process.lua ProcessEnMasse=False
The Eduction Lua module will call function processmatch (edkmatch)
. For example:
function processmatch(edkmatch) if edkmatch then local text = edkmatch:getOutputText() -- modify the match edkmatch:setOutputText(text) return true end return false -- return false to drop the match end
The edkmatch
argument represents a single Named Entity Recognition match, or the complete set of matches if you set the configuration parameter ProcessEnMasse
to true
.
If the processmatch
function returns true
, the match is returned to CFS. If the function returns false
, the match is discarded.
For more information about writing Named Entity Recognition post-processing scripts, and information about the Lua methods that you can use, refer to the Named Entity Recognition User and Programming Guide.