This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Increase the boost for prefix matches. #3493
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,16 +562,29 @@ 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++; | ||
|
||
var boost = CONSECUTIVE_MATCHES_POINTS * numConsecutive; | ||
|
||
// Consecutive matches that started on a special are a | ||
// good indicator of intent, so we award an added bonus there. | ||
if (currentRangeStartedOnSpecial) { | ||
numConsecutive++; | ||
boost = boost * 2; | ||
} | ||
|
||
if (DEBUG_SCORES) { | ||
scoreDebug.consecutive += CONSECUTIVE_MATCHES_POINTS * numConsecutive; | ||
scoreDebug.consecutive += boost; | ||
} | ||
newPoints += CONSECUTIVE_MATCHES_POINTS * numConsecutive; | ||
newPoints += boost; | ||
} else { | ||
numConsecutive = 1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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...