This commit is contained in:
2025-01-12 20:20:57 -05:00
parent 725e463992
commit 945a3d9bf6
3 changed files with 3 additions and 42 deletions

View File

@@ -4,37 +4,6 @@ from difflib import SequenceMatcher
from typing import List, Optional, Tuple
import re
# Example usage:
if __name__ == "__main__":
matcher = TrackMatcher(threshold=0.85)
candidate_tracks = [
"The Beatles - Hey Jude",
"Led Zeppelin - Stairway to Heaven",
"Queen - Bohemian Rhapsody",
"Pink Floyd - Comfortably Numb",
"The Beatles - Hey Jules", # Intentionally similar to "Hey Jude"
]
# Test cases
test_tracks = [
"The Beatles - Hey Jude", # Exact match
"Beatles - Hey Jude", # Similar match
"The Beatles - Hey Jules", # Similar but different
"Metallica - Nothing Else Matters", # No match
"Queen - bohemian rhapsody", # Different case
]
for test_track in test_tracks:
result = matcher.find_best_match(test_track, candidate_tracks)
if result:
match, score = result
print(f"Input: {test_track}")
print(f"Best match: {match}")
print(f"Similarity score: {score:.3f}\n")
else:
print(f"No good match found for: {test_track}\n")
class TrackMatcher:
"""Track Matcher"""
def __init__(self, threshold: float = 0.85):