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 {
520520 continue ;
521521 }
522522 var matched = 0 ;
523+ var unmatched = 0 ;
524+ final acceptThreshold = parts.length ~ / 2 ;
525+ final rejectThreshold = parts.length - acceptThreshold;
523526 for (final part in parts) {
524527 if (entry.trigrams.contains (part)) {
525528 matched++ ;
529+ } else {
530+ unmatched++ ;
531+ if (unmatched > rejectThreshold) {
532+ // we have no chance to accept this hit
533+ break ;
534+ }
526535 }
527536 }
528537
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
531540 final v = matched / parts.length;
532541 if (v >= 0.5 ) {
533542 score.setValue (i, v);
You can’t perform that action at this time.
0 commit comments