Skip to content

Conversation

jjw24
Copy link
Member

@jjw24 jjw24 commented Nov 4, 2022

Context

Currently scoring is the same regardless of the position of the matched string, e.g. 'hello world' and 'world hello' have the same score. This change adds an adjustment during score calculation to allow 'world hello' to score higher than 'hello world' when query is 'world'.

How

The conditions for this adjustment to kick in is:

  • the matched string has to be immediately preceding a space, and
  • query must be a fully contained substring of the compare string.

Score adjustment is done by:
Counting the number of spaces from the start of the string and deduct this from the score. So when matching 'world', 'world hello' has 0 spaces, so nothing is deducted from the score. On the other hand 'crazy on fire world' has three spaces so deduct three from the score.

Some pretty pictures

Before, notice 'Graphics Settings' should be higher:
image

After:
image

What's tested

  • Added new unit test covering several scenarios
  • Manually tested some of the results via running the launcher
  • Checked the score adjustment does not impact greatly on other non-relevant results

@jjw24 jjw24 added the enhancement New feature or request label Nov 4, 2022
@jjw24 jjw24 added this to the 1.10.0 milestone Nov 4, 2022
@jjw24 jjw24 self-assigned this Nov 4, 2022
@jjw24 jjw24 enabled auto-merge November 4, 2022 11:20
@jjw24 jjw24 merged commit 14c137a into dev Nov 4, 2022
@jjw24 jjw24 deleted the update_stringmatcher_score_startstring branch November 4, 2022 12:48
@Garulf
Copy link
Member

Garulf commented Nov 4, 2022

Wow amazingly fast! I have to try this first chance I get. Ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants