File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -216,13 +216,14 @@ class TokenIndex {
216216 /// Search the index for [words] , with a (term-match / document coverage percent)
217217 /// scoring.
218218 Score searchWords (List <String > words, {double weight = 1.0 }) {
219+ if (words.isEmpty) return Score .empty;
219220 IndexedScore ? score;
221+ weight = math.pow (weight, 1 / words.length).toDouble ();
220222 for (final w in words) {
221223 final s = IndexedScore (_ids);
222224 searchAndAccumulate (w, score: s, weight: weight);
223225 if (score == null ) {
224226 score = s;
225- // NOTE: in the subsequent round(s), weight will be re-applied on the next word(s) too.
226227 } else {
227228 score.multiplyAllFrom (s);
228229 }
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ void main() {
9999 'packageHits' : [
100100 {
101101 'package' : 'foo' ,
102- 'score' : closeTo (0.18 , 0.01 ), // find WebPageGenerator
102+ 'score' : closeTo (0.26 , 0.01 ), // find WebPageGenerator
103103 'apiPages' : [
104104 {'path' : 'generator.html' },
105105 ],
@@ -119,7 +119,7 @@ void main() {
119119 'packageHits' : [
120120 {
121121 'package' : 'foo' ,
122- 'score' : closeTo (0.11 , 0.01 ), // find WebPageGenerator
122+ 'score' : closeTo (0.16 , 0.01 ), // find WebPageGenerator
123123 'apiPages' : [
124124 {'path' : 'generator.html' },
125125 ],
You can’t perform that action at this time.
0 commit comments