extractWithoutOrder<T> method
List<ExtractedResult<T> >
extractWithoutOrder<T>(
- String query,
- List<
T> choices, - Applicable func, [
- String getter(
- T obj
Returns the list of choices with their associated scores of similarity in a list of ExtractedResult
Implementation
List<ExtractedResult<T>> extractWithoutOrder<T>(
String query, List<T> choices, Applicable func,
[String Function(T obj)? getter]) {
var yields = List<ExtractedResult<T>>.empty(growable: true);
var index = 0;
if (T != String) {
if (getter == null) {
throw ArgumentError('Getter cannot be null for non-string types!');
}
} else {
getter = (obj) => (obj as String);
}
for (var s in choices) {
var score = func.apply(query.toLowerCase(), getter(s).toLowerCase());
if (score >= _cutoff) {
yields.add(ExtractedResult<T>(s, score, index, getter));
}
index++;
}
return yields;
}