RSS-266: Allow duplicated entries with different types for scm
This commit is contained in:
parent
47a13f5a99
commit
0d353f99cd
@ -18,6 +18,8 @@ import java.util.Set;
|
||||
public class Entity implements ReasonHolder {
|
||||
|
||||
private String word;
|
||||
|
||||
@EqualsAndHashCode.Include
|
||||
private String type;
|
||||
private boolean redaction;
|
||||
private boolean falsePositive;
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.redaction.v1.model.Point;
|
||||
@ -92,7 +93,7 @@ public class RedactionLogCreatorService {
|
||||
List<RedactionLogEntry> redactionLogEntities = new ArrayList<>();
|
||||
|
||||
// Duplicates can exist due table extraction columns over multiple rows.
|
||||
Set<String> processedIds = new HashSet<>();
|
||||
Set<Pair<String, String>> processedIds = new HashSet<>();
|
||||
|
||||
entityLoop:
|
||||
for (Entity entity : entities.get(page)) {
|
||||
@ -100,12 +101,11 @@ public class RedactionLogCreatorService {
|
||||
for (EntityPositionSequence entityPositionSequence : entity.getPositionSequences()) {
|
||||
|
||||
RedactionLogEntry redactionLogEntry = createRedactionLogEntry(entity, dossierTemplateId);
|
||||
if (processedIds.contains(entityPositionSequence.getId())) {
|
||||
if (processedIds.contains(Pair.of(entityPositionSequence.getId(), entity.getType()))) {
|
||||
|
||||
// TODO refactor this outer loop jump as soon as we have the time.
|
||||
continue entityLoop;
|
||||
} else {
|
||||
processedIds.add(entityPositionSequence.getId());
|
||||
processedIds.add(Pair.of(entityPositionSequence.getId(), entity.getType()));
|
||||
}
|
||||
|
||||
redactionLogEntry.setId(entityPositionSequence.getId());
|
||||
|
||||
@ -152,10 +152,10 @@ public class RedactionLogMergeService {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (processedIds.contains(entry.getId())) {
|
||||
log.info("Duplicate annotation found with id {}", entry.getId());
|
||||
return true;
|
||||
}
|
||||
// if (processedIds.contains(entry.getId())) {
|
||||
// log.info("Duplicate annotation found with id {}", entry.getId());
|
||||
// return true;
|
||||
// }
|
||||
processedIds.add(entry.getId());
|
||||
return false;
|
||||
});
|
||||
|
||||
@ -286,7 +286,7 @@ public class EntitySearchUtils {
|
||||
existing.setRedaction(true);
|
||||
}
|
||||
}
|
||||
} else if (dictionary.getDictionaryRank(existing.getType()) <= dictionary.getDictionaryRank(found.getType())) {
|
||||
} else if (dictionary.getDictionaryRank(existing.getType()) < dictionary.getDictionaryRank(found.getType())) {
|
||||
entities.remove(found);
|
||||
entities.add(found);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user