Switch to textdistance pure Python library

Also switch to Hamming algorithm as it appears to give similar or even arguably better results but executes more quickly than Levenshtein.
This commit is contained in:
JayZed 2024-05-02 14:51:42 -04:00
parent 85866fc063
commit 778ea39a72
1 changed files with 2 additions and 3 deletions

View File

@ -8,7 +8,7 @@ from app.database import TableShows, TableMovies, database, select
from ..utils import authenticate
import Levenshtein
import textdistance
api_ns_system_searches = Namespace('System Searches', description='Search for series or movies by name')
@ -64,6 +64,5 @@ class Searches(Resource):
results.append(result)
# sort results by how closely they match the query
results = sorted(results, key=lambda x: Levenshtein.distance(query, x['title']))
results = sorted(results, key=lambda x: textdistance.hamming.distance(query, x['title']))
return results