Function Block SIMILAR_TEXT

The function block SIMILAR_TEXT calculates the similarity of two strings.

The calculation of the similarity of two strings is performed according to the method described in Programming Classics: Implementing the World's Best Algorithms by Oliver (ISBN 0-131-00413-1). Note that this implementation does not use a stack as in Oliver's pseudo-code, but instead uses recursive calls which can increase performance (but do not have to). Also note that the complexity of this algorithm is O(N³), where N is the length of the longest string.

Input STR1

The input defines the first string to be compared.

Input STR2

The input defines the second string to be compared.

Output SIM

The output returns the number of matching characters in both strings.

The number of matching characters is calculated by finding the longest first common substring and then repeating this recursively for the prefixes and suffixes. The lengths of all found common substrings are summed up.

Output PERCENT

The output returns the similarity as a percentage value as a floating-point number. To do this, the result is divided by the average length of the specified strings and multiplied by 100.