-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Increase the boost for prefix matches. #3493
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,9 +119,9 @@ define(function (require, exports, module) { | |
var SPECIAL_POINTS = 35; | ||
var MATCH_POINTS = 10; | ||
var LAST_SEGMENT_BOOST = 1; | ||
var BEGINNING_OF_NAME_POINTS = 25; | ||
var BEGINNING_OF_NAME_POINTS = 10; | ||
var DEDUCTION_FOR_LENGTH = 0.2; | ||
var CONSECUTIVE_MATCHES_POINTS = 10; | ||
var CONSECUTIVE_MATCHES_POINTS = 7; | ||
var NOT_STARTING_ON_SPECIAL_PENALTY = 25; | ||
|
||
// Used in match lists to designate matches of "special" characters (see | ||
|
@@ -562,10 +562,24 @@ define(function (require, exports, module) { | |
// handles the initial value of lastMatchIndex which is used for | ||
// constructing ranges but we don't yet have a true match. | ||
if (score > 0 && lastMatchIndex + 1 === c) { | ||
// Continue boosting for each additional match at the beginning | ||
// of the name | ||
if (c - numConsecutive === lastSegmentStart) { | ||
if (DEBUG_SCORES) { | ||
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS; | ||
} | ||
newPoints += BEGINNING_OF_NAME_POINTS; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused about how to interpret I think the code here still works correctly, since segment start is always a special (I can't think of any way to get a false positive or negative). But it does make the code more confusing. What if we change it so var pointMultiplier = currentRangeStartedOnSpecial ? numConsecutive : 1;
...
newPoints += CONSECUTIVE_MATCHES_POINTS * pointMultiplier; |
||
|
||
numConsecutive++; | ||
|
||
// Consecutive matches that started on a special are a | ||
// good indicator of intent, so we award an added bonus there. | ||
if (currentRangeStartedOnSpecial) { | ||
numConsecutive++; | ||
newPoints += CONSECUTIVE_MATCHES_POINTS * numConsecutive; | ||
if (DEBUG_SCORES) { | ||
scoreDebug.consecutive += CONSECUTIVE_MATCHES_POINTS * numConsecutive; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm reading this right, this is basically adding the same bonus as the always case, just a second time. Would it read more clearly to just store |
||
} | ||
|
||
if (DEBUG_SCORES) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the order of these two additions is the opposite of the other pairs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry, that comment was intended for the next block of code, on line 579...