mirror of https://github.com/morpheus65535/bazarr
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:
parent
85866fc063
commit
778ea39a72
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue