Function Block LEVENSHTEIN

The Function Block LEVENSHTEIN calculates the Levenshtein distance between two strings.

The Levenshtein distance refers to the minimum number of characters that you must replace, insert or delete in order to transform the value from input STR1 into the value from input STR2. The complexity of the algorithm is O(m*n), where n and m represent the length of STR1 and STR2 (fairly good compared to the Function Block SIMILAR_TEXT, which is O(max(n,m)³) but still expensive).

Input STR1

The input defines the first string that should be compared.

Input STR2

The input defines the second string that should be compared.

Input COST_INS

The input defines the cost of insertion.

Input COST_REP

The input defines the cost of replacement.

Input COST_DEL

The input defines the cost of deletion.

Output

The output returns the Levenshtein distance between the two inputs STR1 and STR2 or -1 if one of the arguments is longer than 255 characters.