Open topic with navigation

# Write a Lua Script for Post-Processing

An Eduction post-processing task runs a Lua script.

Your script must define a function named `processmatch`, which takes a single argument, an `edkMatch` object. The matches that are found by Eduction are passed into the script one at a time. The script must return a Boolean value: `true` to keep the match or `false` to discard it.

The following example changes the score for every match to `0.5`:

    function processmatch(edkmatch)
        if edkmatch then
            -- change the score for the match
            edkmatch:setScore(0.5)
        end
        return true
    end

## Process Matches En Masse

Sometimes, you might prefer to process all of the matches together. For example, you might want to increase the scores of matches that appear near other matches. It is easier to do this if you process all of the matches at the same time.

To process all of the matches at the same time, modify your Eduction configuration and set the parameter `ProcessEnMasse` to `TRUE`. When `ProcessEnMasse=TRUE`, all of the matches found by Eduction are passed into the script together.

Your script must define a function named `processmatches`, which takes a single argument, a Lua table of `edkEnMasseMatch` objects. Each of these objects represents a single match, but you must call the `getMatch` method to obtain an `edkMatch` object. You can then use the `edkMatch` object to manipulate the match. If you want to discard a match, call the method `setOutput` on the relevant `edkEnMasseMatch` object.

The following example demonstrates how to iterate over the elements in the table and discard any match with a score that is less than `0.5`:

    function processmatches(matches)
        -- example that discards matches with score < 0.5
        for k,v in ipairs (matches) do
            local edkmatch = v:getMatch()
            if edkmatch:getScore() < 0.5 then
                v:setOutput(false)
            end
        end
    end

For information about the objects and methods that you can use in your Lua post-processing scripts, see Eduction Lua Methods Reference.

© Copyright 2013-2019 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm