Skip to content

Commit

Permalink
Returned 0 since we were always returning 10 anyways
Browse files Browse the repository at this point in the history
  • Loading branch information
scohen committed Apr 23, 2024
1 parent fc47eb0 commit 01d9f11
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Lexical.RemoteControl.Search.Fuzzy.Scorer do
2. Patterns that match more consecutive characters
3. Patterns that match the beginning of the subject
4. Patterns that match the case of the subject
5. Patterns that match after the last period
5. Patterns that match the tail of a subject starting at the last period
Based loosely on https://medium.com/@Srekel/implementing-a-fuzzy-search-algorithm-for-the-debuginator-cacc349e6c55
"""
Expand Down Expand Up @@ -170,7 +170,7 @@ defmodule Lexical.RemoteControl.Search.Fuzzy.Scorer do

match_amount_boost = consecutive_count * pattern_length

match_boost = match_boost(score, subject, pattern_length)
match_boost = tail_match_boost(score, subject, pattern_length)

camel_case_boost = camel_case_boost(score.matched_character_positions, subject)

Expand All @@ -187,9 +187,8 @@ defmodule Lexical.RemoteControl.Search.Fuzzy.Scorer do
end

@tail_match_boost 55
@max_match_boost_boost 10

defp match_boost(
defp tail_match_boost(
%__MODULE__{} = score,
subject(graphemes: graphemes, period_positions: period_positions),
pattern_length
Expand All @@ -204,8 +203,7 @@ defmodule Lexical.RemoteControl.Search.Fuzzy.Scorer do
# and the pattern matches the most local parts
@tail_match_boost
else
# penalize first matches further in the string by making them negative.
max(0 - first_match_position, @max_match_boost_boost)
0
end
end

Expand Down

0 comments on commit 01d9f11

Please sign in to comment.