622
623
export function compareItemsByFuzzyScore<T>(itemA: T, itemB: T, query: IPreparedQuery, allowNonContiguousMatches: boolean, accessor: IItemAccessor<T>, cache: FuzzyScorerCache): number {
624
>
const itemScoreA = scoreItemFuzzy(itemA, query, allowNonContiguousMatches, accessor, cache);
fuzzyScorer.ts
625
>
const itemScoreB = scoreItemFuzzy(itemB, query, allowNonContiguousMatches, accessor, cache);
626
>
627
>
const scoreA = itemScoreA.score;
628
>
const scoreB = itemScoreB.score;
629
>
630
>
// 1.) identity matches have highest score
631
>
if (scoreA === PATH_IDENTITY_SCORE || scoreB === PATH_IDENTITY_SCORE) {
632
if (scoreA !== scoreB) {
633
return scoreA === PATH_IDENTITY_SCORE ? -1 : 1;
634
}
635
}
637
>
// 2.) matches on label are considered higher compared to label+description matches
638
>
if (scoreA > LABEL_SCORE_THRESHOLD || scoreB > LABEL_SCORE_THRESHOLD) {
639
if (scoreA !== scoreB) {
640
return scoreA > scoreB ? -1 : 1;