levenshteinFunction static method
Calculates the Levenshtein distance between an item and a collection of search terms.
The Levenshtein distance is a measure of the difference between two strings.
This function takes an item, a collection of search terms, a function to extract search terms from the item,
and a maximum allowed Levenshtein distance. It returns true
if there is at least one search term that is within
the specified Levenshtein distance of the item, and false
otherwise.
The searchTerms
parameter is the collection of search terms to compare against the item.
The searchOnItems
parameter is a list of search terms to compare against.
The levenshteinDistance
parameter is the maximum allowed Levenshtein distance.
The ignoreCase
parameter specifies whether to ignore case when comparing strings. It is true
by default.
Returns true
if there is at least one search term within the specified Levenshtein distance of the item,
and false
otherwise.
Implementation
static bool levenshteinFunction({
required dynamic searchTerms,
required Iterable searchOnItems,
required int levenshteinDistance,
bool ignoreCase = true,
}) =>
countLevenshtein(
searchTerms: searchTerms,
searchOnItems: searchOnItems,
levenshteinDistance: levenshteinDistance,
ignoreCase: ignoreCase,
) >
0;