[aligner] Add an option to normalize distance matrix, see #183457
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 15 Oct 2013 09:16:10 +0000
changeset 313 4b4bd8713f9f
parent 312 74d0a106fe23
child 314 22de89ab1274
[aligner] Add an option to normalize distance matrix, see #183457
aligner.py
--- a/aligner.py	Tue Oct 15 12:21:38 2013 +0000
+++ b/aligner.py	Tue Oct 15 09:16:10 2013 +0000
@@ -48,10 +48,11 @@
 ###############################################################################
 class BaseAligner(object):
 
-    def __init__(self, threshold, processings, verbose=False):
+    def __init__(self, threshold, processings, normalize_matrix=False, verbose=False):
         self.threshold = threshold
         self.processings = processings
         self.verbose = verbose
+        self.normalize_matrix = normalize_matrix
         self.ref_normalizer = None
         self.target_normalizer = None
         self.blocking = None
@@ -99,8 +100,8 @@
         values being a list of couple (indice from Y, distance)
         """
         match = defaultdict(list)
-        # if normalized:
-        #     distmatrix /= distmatrix.max()
+        if self.normalize_matrix:
+            distmatrix /= distmatrix.max()
         ind = (distmatrix <= self.threshold).nonzero()
         indrow = ind[0].tolist()
         indcol = ind[1].tolist()