Skip to content

KFuzzyMatcher update

Waqar Ahmed requested to merge work/waqar/fuzzy2 into master

This is a proposed revision to the KFuzzyMatcher. Notable modifications are:

  • There is only one method to do weighted matching now: match(). I feel this is better as the user doesn't have to worry about which one is right for them.
  • The quality of the match is much better now. KFuzzyMatcher::match now correctly handles both sequential and separator based matches and ranks them correctly. The correctness has been mostly measured against Sublime Text 3 and we come pretty close to it now. To do this, I changed the internal algorithm to categorize a sequence into two types: a sequence that starts from the start of a string(scored higher), a sequence that is anywhere in the middle of the string (scored lower). This also allows us to limit the recursion early if we know that we are in the "initial sequence". As a result, the performance has increased by about 3-4ms. I have added extra tests for this.
  • The match function will now return true if the pattern is empty. This saves a user from putting this check everywhere they use match because if it returns false, you get an empty view.
  • A new method, toActualFuzzyMatchedDisplayString is introduced which shows the "actual" match as it happened. The previous method works but it uses just simple character matching. This will be a bit slower but it will output much better results in the view.

Merge request reports