Merge branch 'RED-8834-4.0' into 'release/4.244.x'

RED-8834: Fixed text entities with empty text range

See merge request redactmanager/redaction-service!346
This commit is contained in:
Dominique Eifländer 2024-03-27 10:02:00 +01:00
commit 895d56c05f

View File

@ -590,6 +590,9 @@ public class EntityCreationService {
throw new IllegalArgumentException(String.format("%s is not in the %s of the provided semantic node %s", textRange, node.getTextRange(), node));
}
TextRange trimmedTextRange = textRange.trim(node.getTextBlock());
if (trimmedTextRange.length() == 0){
return Optional.empty();
}
TextEntity entity = TextEntity.initialEntityNode(trimmedTextRange, type, entityType, node);
if (node.getEntities().contains(entity)) {
Optional<TextEntity> optionalTextEntity = node.getEntities().stream().filter(e -> e.equals(entity) && e.type().equals(type)).peek(e -> e.addEngines(engines)).findAny();