mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-21 10:13:39 +00:00
2a73990c82
Removes Levenshtein requirement with direct use of rapidfuzz instead Fallback to old fuzzywuzzy for pure python implementation
22 lines
509 B
Python
22 lines
509 B
Python
from rapidfuzz.utils import default_process as _default_process
|
|
|
|
translation_table = {i: None for i in range(128, 256)} # ascii dammit!
|
|
|
|
|
|
def ascii_only(s):
|
|
return s.translate(translation_table)
|
|
|
|
|
|
def full_process(s, force_ascii=False):
|
|
"""
|
|
Process string by
|
|
-- removing all but letters and numbers
|
|
-- trim whitespace
|
|
-- force to lower case
|
|
if force_ascii == True, force convert to ascii
|
|
"""
|
|
|
|
if force_ascii:
|
|
s = ascii_only(str(s))
|
|
|
|
return _default_process(s)
|