jaroSimilarityOf function
Find the Jaro Similarity index between two strings.
Parameters
source
andtarget
are two strings.- if
ignoreCase
is true, the character case shall be ignored. - if
ignoreWhitespace
is true, space, tab, newlines etc whitespace characters will be ignored. - if
ignoreNumbers
is true, numbers will be ignored. - if
alphaNumericOnly
is true, only letters and digits will be matched.
Details
The Jaro similarity index between two strings is the weighted sum of percentage of matched characters from each string and transposed characters.
See Also: jaroSimilarity
If n
is the length of source
and m
is the length of target
,
Complexity: Time O(nm)
| Space O(n+m)
Implementation
double jaroSimilarityOf(
String source,
String target, {
bool ignoreCase = false,
bool ignoreWhitespace = false,
bool ignoreNumbers = false,
bool alphaNumericOnly = false,
}) {
source = cleanupString(
source,
ignoreCase: ignoreCase,
ignoreWhitespace: ignoreWhitespace,
ignoreNumbers: ignoreNumbers,
alphaNumericOnly: alphaNumericOnly,
);
target = cleanupString(
target,
ignoreCase: ignoreCase,
ignoreWhitespace: ignoreWhitespace,
ignoreNumbers: ignoreNumbers,
alphaNumericOnly: alphaNumericOnly,
);
return jaroSimilarity(
source.codeUnits,
target.codeUnits,
);
}