From 43e2c40d06e0a503e45f4e401c384cb64a5eed99 Mon Sep 17 00:00:00 2001 From: Ji Sun Date: Tue, 23 Oct 2018 11:08:51 +0800 Subject: [PATCH] Fix bug in abs_norm with negative number em.abs_norm(0.0, -1.0) will throw ZeroDivisionError in previous version. --- py_entitymatching/feature/simfunctions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py_entitymatching/feature/simfunctions.py b/py_entitymatching/feature/simfunctions.py index 3525e230..ae547a59 100644 --- a/py_entitymatching/feature/simfunctions.py +++ b/py_entitymatching/feature/simfunctions.py @@ -760,7 +760,7 @@ def abs_norm(d1, d2): return 0 else: # Compute absolute norm similarity between two numbers. - x = (abs(d1 - d2) / max(d1, d2)) + x = (abs(d1 - d2) / max(abs(d1), abs(d2))) if x <= 10e-5: x = 0 return 1.0 - x