-
Notifications
You must be signed in to change notification settings - Fork 20
/
result.dart
93 lines (73 loc) · 1.83 KB
/
result.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import '../bitap/bitap.dart';
import '../bitap/data/match_index.dart';
/// Class to hold searchers
class Searchers {
/// Instantiates it
Searchers({
this.tokenSearchers,
this.fullSearcher,
});
/// All searchers, if tokenized
final List<Bitap> tokenSearchers;
/// The whole string searcher
final Bitap fullSearcher;
@override
String toString() =>
'tokenSearchers: $tokenSearchers, fullSearcher: $fullSearcher';
}
/// Class to hold results and weights
class ResultsAndWeights<T> {
/// Instantiates it
ResultsAndWeights({
this.results,
this.weights,
});
/// The list of results
final List<Result<T>> results;
/// The weights
final Map<String, double> weights;
}
/// Holds the result (with score and index)
class Result<T> {
/// Instantiates it
Result({
this.item,
this.matches = const [],
this.score = 0,
});
/// Item in the original list
final T item;
/// Details of this result
final List<ResultDetails<T>> matches;
/// Score of this result
double score;
@override
String toString() => 'item: $item, score: $score, matches: $matches';
}
/// Details of a result.
class ResultDetails<T> {
/// Instantiates it
ResultDetails({
this.key = '',
this.arrayIndex,
this.value,
this.score,
this.matchedIndices,
this.nScore,
});
/// Key ([WeightedKey.name]) used to create this
final String key;
/// Index of result in the original list
final int arrayIndex;
/// Original value
final String value;
/// Score of this result
final double score;
/// nScore of this result (?)
double nScore;
/// Indexes of matched patterns on the value
final List<MatchIndex> matchedIndices;
@override
String toString() =>
'arrayIndex: $arrayIndex, value: $value, score: $score, nScore: $nScore, matchedIndices: $matchedIndices';
}