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 @@ -519,14 +519,23 @@ class PackageNameIndex {
519519 continue ;
520520 }
521521 var matched = 0 ;
522+ var unmatched = 0 ;
523+ final acceptThreshold = parts.length ~ / 2 ;
524+ final rejectThreshold = parts.length - acceptThreshold;
522525 for (final part in parts) {
523526 if (entry.trigrams.contains (part)) {
524527 matched++ ;
528+ } else {
529+ unmatched++ ;
530+ if (unmatched > rejectThreshold) {
531+ // we have no chance to accept this hit
532+ break ;
533+ }
525534 }
526535 }
527536
528- // making sure that match score is minimum 0.5
529- if (matched > 0 ) {
537+ if (matched >= acceptThreshold) {
538+ // making sure that match score is minimum 0.5
530539 final v = matched / parts.length;
531540 if (v >= 0.5 ) {
532541 score.setValue (i, v);
You can’t perform that action at this time.
0 commit comments