From: kaliko Date: Thu, 5 Dec 2013 10:28:36 +0000 (+0100) Subject: Add class attribute toggle for diacritics filter X-Git-Tag: mpd-sima/0.12.0pr2~11 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=e73aeec41c2065c852294253a8ed85a5d0958f76;hp=50a7a9b43940155f8b0a3b81bb91a79585104eb9;p=mpd-sima.git Add class attribute toggle for diacritics filter Add class attribute for levenshtein ratio --- diff --git a/sima/lib/simastr.py b/sima/lib/simastr.py index c716214..9dacc45 100644 --- a/sima/lib/simastr.py +++ b/sima/lib/simastr.py @@ -80,6 +80,8 @@ class SimaStr(str): Specific string object for artist names and song titles. Here follows some class variables for regex to run on strings. """ + diafilter = True + leven_ratio = 0.82 regexp_dict = dict() # Leading patterns: The Le Les @@ -105,7 +107,8 @@ class SimaStr(str): self.stripped = str(fuzzstr.strip()) # fuzzy computation self._get_root() - self.remove_diacritics() + if self.__class__.diafilter: + self.remove_diacritics() def __new__(cls, fuzzstr): return super(SimaStr, cls).__new__(cls, fuzzstr) @@ -145,7 +148,7 @@ class SimaStr(str): other.stripped.lower()) if hash(self) == hash(other): return True - return levenr >= 0.82 + return levenr >= self.__class__.leven_ratio def __ne__(self, other): if not isinstance(other, SimaStr):