Example Scripts

The following example post-processing script sets the score for all matches to 0.5:

function processmatch (edkmatch)
if edkmatch then
    -- just overwrite the score
    edkmatch:setScore(0.5)
    end
return true

You can also use the sample scripts that are included with Eduction to perform the following tasks, or you can use the sample scripts as a reference if you want to write your own scripts.

Checksum Validation

The checksum_luhn.lua script verifies the checksum digit of each match using the Luhn algorithm, and reduces the score associated with the match if the checksum is wrong. The checksum_luhn_enmasse.lua script performs checksum validation as an en masse processing task, discards incorrect matches, and alters the score of correct matches to equal the proportion of matches that have the correct checksum digit.

You can use these scripts with the number_cc.ecr and number_sin_ca.ecr grammar files to validate most credit card numbers.

Spanish Identity Card Number Validation

You can use the checksum_dni_es.lua script with the number_dni_es.ecr grammar file to validate Spanish Documento Nacional de Identidad (national identity card) numbers.

Dutch Citizen Service Number Validation

You can use the number_bsn_nl.lua script with the number_bsn_nl.ecr grammar file to validate Dutch Citizen Service Numbers (Burgerservicenummer, or BSNs).

Geographical Co-ordinate Standardization

You can use the lat_long.lua script with the place_lat_long.ecr grammar file to convert and standardize the output of geographical co-ordinates.

Date and Time Standardization

You can use the datetime.lua script with the datetime_advanced_eng.ecr grammar file to convert and standardize the output of dates and times in English into a standardized format in cases where there are matches on several formats. For example, you can convert both 23/11/13 and Nov 23 2013 to epoch seconds, or to 20131123.

The datetime_advanced_eng.ecr grammar file can understand English natural language, and relative dates such as last Saturday morning. You can provide a reference date for <today> in the Lua script to enable normalization of relative dates into standard formats.

You can also use datetime.lua to convert number matches expressed in English to numeric format


_HP_HTML5_bannerTitle.htm