How to use the textdistance.algorithms.simple.Postfix function in textdistance

To help you get started, we’ve selected a few textdistance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github life4 / textdistance / textdistance / algorithms / simple.py View on Github external
if sequences in self.mat:
            return self.mat[sequences]
        # search in symmetric matrix
        if self.symmetric:
            sequences = tuple(reversed(sequences))
            if sequences in self.mat:
                return self.mat[sequences]
        # if identity then return match_cost
        if self._ident(*sequences):
            return self.match_cost
        # not found
        return self.mismatch_cost


prefix = Prefix()
postfix = Postfix()
length = Length()
identity = Identity()
matrix = Matrix()
github life4 / textdistance / textdistance / algorithms / simple.py View on Github external
def __call__(self, *sequences):
        s = sequences[0]
        sequences = [reversed(s) for s in sequences]
        result = reversed(super(Postfix, self).__call__(*sequences))
        if isinstance(s, string_types):
            return ''.join(result)
        if isinstance(s, bytes):
            return b''.join(result)
        return list(result)