SimilarityScore

SimilarityScore(string1, string2, ignoreCase): float

Calculates a similarity score between two strings using Levenshtein distance.

Table 1. Parameters

string1

String

First string to compare

string2

String

Second string to compare

ignoreCase

Boolean

Optional. If TRUE, performs case-insensitive comparison. Defaults to FALSE

Return

Float value between 0.0 (completely different) and 1.0 (identical strings). Calculated as: 1.0 - (distance / max(len1, len2)).

// Calculate similarity between two strings
score = SimilarityScore("hello", "hallo");
println(score);  // prints 0.8

// Identical strings
score = SimilarityScore("test", "test");
println(score);  // prints 1.0

// Case-insensitive comparison
score = SimilarityScore("Hello", "hello", true);
println(score);  // prints 1.0