From b602d8469afa1bc4f6209105b9933529419003b2 Mon Sep 17 00:00:00 2001 From: gpapadis Date: Thu, 8 Mar 2018 16:05:16 +0200 Subject: [PATCH] Fixed bug in the extraction of blocking keys. --- .../blockbuilding/AbstractBlockBuilding.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java b/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java index dbce6c96..8a7ed48f 100644 --- a/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java +++ b/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -108,19 +109,24 @@ public double getTotalNoOfEntities() { protected void indexEntities(Map index, List entities) { int counter = 0; for (EntityProfile profile : entities) { + final Set allKeys = new HashSet<>(); for (Attribute attribute : profile.getAttributes()) { for (String key : getBlockingKeys(attribute.getValue())) { String normalizedKey = key.trim().toLowerCase(); if (0 < normalizedKey.length()) { - TIntList entityList = index.get(normalizedKey); - if (entityList == null) { - entityList = new TIntArrayList(); - index.put(normalizedKey, entityList); - } - entityList.add(counter); + allKeys.add(normalizedKey); } } } + + for (String key : allKeys) { + TIntList entityList = index.get(key); + if (entityList == null) { + entityList = new TIntArrayList(); + index.put(key, entityList); + } + entityList.add(counter); + } counter++; } }