File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -520,14 +520,23 @@ class PackageNameIndex {
520
520
continue ;
521
521
}
522
522
var matched = 0 ;
523
+ var unmatched = 0 ;
524
+ final acceptThreshold = parts.length ~ / 2 ;
525
+ final rejectThreshold = parts.length - acceptThreshold;
523
526
for (final part in parts) {
524
527
if (entry.trigrams.contains (part)) {
525
528
matched++ ;
529
+ } else {
530
+ unmatched++ ;
531
+ if (unmatched > rejectThreshold) {
532
+ // we have no chance to accept this hit
533
+ break ;
534
+ }
526
535
}
527
536
}
528
537
529
- // making sure that match score is minimum 0.5
530
- if (matched > 0 ) {
538
+ if (matched >= acceptThreshold) {
539
+ // making sure that match score is minimum 0.5
531
540
final v = matched / parts.length;
532
541
if (v >= 0.5 ) {
533
542
score.setValue (i, v);
You can’t perform that action at this time.
0 commit comments