This scoring algorithm uses a sum-of-squares approach to determine
the score. In order for there to be a match, all of the characters
in querymust appear in source in order. The index of each
matching character is squared and added to the score. This means
that early and consecutive character matches are preferred, while
late matches are heavily penalized.
A string matcher which uses a sum-of-squares algorithm.
Returns
The match result, or
nullif there is no match. A lowerscorerepresents a stronger match.Complexity
Linear on
sourceText.Notes
This scoring algorithm uses a sum-of-squares approach to determine the score. In order for there to be a match, all of the characters in
querymust appear insourcein order. The index of each matching character is squared and added to the score. This means that early and consecutive character matches are preferred, while late matches are heavily penalized.