From f2bc66540383fafb9043e376ea47b5f21a10919c Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 18 Jun 2019 14:45:15 +0200 Subject: [PATCH] avoid to divide by zero: in case of missing values, return undefined response --- .../src/main/java/eu/dnetlib/pace/condition/PidMatch.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dnet-pace-core/src/main/java/eu/dnetlib/pace/condition/PidMatch.java b/dnet-pace-core/src/main/java/eu/dnetlib/pace/condition/PidMatch.java index 53aa2deb9..7222eaf8a 100644 --- a/dnet-pace-core/src/main/java/eu/dnetlib/pace/condition/PidMatch.java +++ b/dnet-pace-core/src/main/java/eu/dnetlib/pace/condition/PidMatch.java @@ -43,6 +43,10 @@ public class PidMatch extends AbstractCondition { int incommon = Sets.intersection(pidAset, pidBset).size(); int simDiff = Sets.symmetricDifference(pidAset, pidBset).size(); + if (incommon + simDiff == 0) { + return new ConditionEval(cond, a, b, 0); + } + int result = incommon / (incommon + simDiff) > 0.5 ? 1 : -1; return new ConditionEval(cond, a, b, result);