Customizing Match Criteria with JavaScript Functions

In a lot of cases, expanding on the existing normalizers or matchers with functionality specific to the dataset and sources at hand will be necessary. The match criteria offers a number of places where this can be achieved, typically through JavaScript business functions. A range of tools are made available to such JavaScript functions, to support their implementation.

This section provides a number of example normalizers and matchers implemented in JavaScript to showcase some of the tools that are available. These functions can be drawn upon for both pure JavaScript matching algorithms and JavaScript in decision tables.

Important: The below functions are examples and likely cannot be used in their current form for your business case. Test thoroughly with your own data before implementing in your production STEP system.

normalizeValue

This normalizeValue function uses JavaScript and regular expressions to make a text lowercase and remove everything but letters and digits.

function normalizeValue(value) {
if(value) {
var normVal = value + "";
normVal = normVal.toLowerCase();
normVal = normVal.replace(/[^\w]|_/g, "");
return normVal;
}
else {
return "";
}
}

normalizeStreet

This function demonstrates how to access lookup tables. For more information on lookup tables, see the Transformation Lookup Tables topic in Resource Materials documentation here.

The normalizeStreet function applies basic normalization to 'Street' values and uses a transformation lookup table with ID 'AddressAbbreviations' to replace common abbreviations like 'rd,' 'ave,' and 'ap' with their full word counterpart.

The logic reads:

function normalizeStreet(input, lookupTableHome) {
var output = "";
if(input) {
input = input + "";
input = input.toLowerCase();
input = input.replace(/[\.\,#]|_/g, "");
var inArr = input.split(" ");
var outArr = [];
for(var i = 0; i < inArr.length; i++) {
outArr.push(lookupTableHome.getLookupTableValue("AddressAbbreviations", inArr[i]));
}
for(var j = 0; j < outArr.length; j++) {
output += outArr[j];
if(j != outArr.length - 1) {
	output += " ";
}
}
}
return output;
}

Core Matching Functions

The function below uses the built-in levenshteinDistance function to get the edit distance between normalized street values. 'Matching Functions' is bound to 'coreMatchingFunctions.'

var street1 = mec.evaluate("normStreet", "first");
var street2 = mec.evaluate("normStreet", "second");
return coreMatchingFunctions.levenshteinDistance(street1, street2);