def fuzz(term, other): d = distance(term.lower(), other.lower()) denominator = float(len(term + other)) if denominator == 0: return False return int(100 * float(d) / denominator) <= 25
def __eq__(self, other): from levenshtein_distance import levenshtein_distance as distance d = distance(self.lower(), other.lower()) return int(100 * float(d) / len(self+other)) <= 25
#!/usr/bin/env python3 # coding=utf-8 from levenshtein_distance import distance if __name__ == '__main__': # 3 print(distance("mitcmu", "mtacnu")) # 3 print(distance("kitten", "sitting")) # 192 dist = distance( "Apache Spark achieves high performance for both batch and streaming data, using a state-of-the-art DAG scheduler, a query optimizer, and a physical execution engine. Write applications quickly in Java, Scala, Python, R, and SQL.", "Apache Flink is a framework and distributed processing engine for stateful computations over unbounded and bounded data streams. Flink has been designed to run in all common cluster environments, perform computations at in-memory speed and at any scale." ) print(dist)
def __eq__(self, other): from levenshtein_distance import levenshtein_distance as distance d = distance(self.lower(), other.lower()) return int(100 * float(d) / len(self + other)) <= 25