Skip to content

Commit

Permalink
fix: more alphanumeric handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NiceAesth committed Jun 26, 2024
1 parent 7457a50 commit 4b11e35
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/humanizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def song_title_match(guess: str, answer: str) -> bool:
"sped up",
]

alphanumeric = " ".join(alphanumeric_rx.split(answer)).strip()
alphanumeric_matches = alphanumeric_rx.split(answer)
alphanumeric = alphanumeric_matches[0]
alphanumeric_full = " ".join(alphanumeric_matches).strip()
answer_length = min(len(alphanumeric.split(" ")), len(answer.split(" ")))
minimum_words_required = 2 if answer_length > 2 else 1
guess_length = max(len(guess.split(" ")), minimum_words_required)
Expand All @@ -96,7 +98,7 @@ def song_title_match(guess: str, answer: str) -> bool:
partial_words_end_alphanumeric = " ".join(alphanumeric.split(" ")[-guess_length:])
return (
fuzzy_string_match(guess, answer)
or fuzzy_string_match(guess, alphanumeric)
or fuzzy_string_match(guess, alphanumeric_full)
or fuzzy_string_match(guess, partial_words_start)
or fuzzy_string_match(guess, partial_words_end)
or fuzzy_string_match(guess, partial_words_start_alphanumeric)
Expand Down

0 comments on commit 4b11e35

Please sign in to comment.