Commit e60eb311 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Rename some methods

parent e3f7a2a1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -18,12 +18,12 @@ class Robustness:
				self.l.append(word)
		self.distance = leven.distance
		self.k = len(self.l)
		self.algo = self.rperm
		self.algo = self.random_permutation

	def swap(self, i, j):
		self.l[i], self.l[j] = self.l[j], self.l[i]

	def rperm(self):
	def random_permutation(self):
		"""
		generator for a random permutation of the list self.l using
		Fisher-Yates algorithm
@@ -103,7 +103,7 @@ class Robustness:
			k -= 1
		return int(c * ratio)

	def min_rperm(self, n=1):
	def min_cost(self, n=1):
		"""
		runs n excursions and returns the lowest cost rate found among them.
		"""
@@ -119,6 +119,9 @@ class Robustness:
		return min_c

	def all_distances(self):
		"""
		computes and stores all the distances between every couple of words
		"""
		ad = dict()
		for i, w in enumerate(self.l):
			before = time.time()
@@ -134,4 +137,4 @@ if __name__ == '__main__':
	R.algo = R.closest_word
	# R.distance = jaro.jaro_winkler_metric
	# R.k = int(len(R.l)/10)
	print(R.min_rperm(n=10))
	print(R.min_cost(n=10))