RED-10633: Duplicated values when extracting from table in DM 1.3.0

This commit is contained in:
maverickstuder 2024-12-12 13:23:17 +01:00
parent 22b2a6474b
commit 9bd5577986
4 changed files with 9 additions and 11 deletions

View File

@ -47,7 +47,7 @@ public class TextEntity implements IEntity {
TextRange textRange; TextRange textRange;
@Builder.Default @Builder.Default
List<TextRange> duplicateTextRanges = new ArrayList<>(); Set<TextRange> duplicateTextRanges = new HashSet<>();
String type; // TODO: make final once ManualChangesApplicationService::recategorize is deleted String type; // TODO: make final once ManualChangesApplicationService::recategorize is deleted
final EntityType entityType; final EntityType entityType;
@ -215,22 +215,20 @@ public class TextEntity implements IEntity {
return textEntity.contains(this); return textEntity.contains(this);
} }
public boolean contains(TextEntity textEntity) { public boolean contains(TextEntity textEntity) {
if (this.textRange.contains(textEntity.getTextRange())) { if (this.textRange.contains(textEntity.getTextRange())) {
return true; return true;
} }
List<TextRange> textEntityDuplicateRanges = textEntity.getDuplicateTextRanges(); Set<TextRange> textEntityDuplicateRanges = textEntity.getDuplicateTextRanges();
// use optimized indexed loops for extra performance boost
for (int i = 0, duplicateTextRangesSize = duplicateTextRanges.size(); i < duplicateTextRangesSize; i++) { for (TextRange duplicateTextRange : this.duplicateTextRanges) {
TextRange duplicateTextRange = duplicateTextRanges.get(i);
if (duplicateTextRange.contains(textEntity.getTextRange())) { if (duplicateTextRange.contains(textEntity.getTextRange())) {
return true; return true;
} }
for (int j = 0, textEntityDuplicateRangesSize = textEntityDuplicateRanges.size(); j < textEntityDuplicateRangesSize; j++) {
TextRange otherRange = textEntityDuplicateRanges.get(j); for (TextRange otherRange : textEntityDuplicateRanges) {
if (duplicateTextRange.contains(otherRange)) { if (duplicateTextRange.contains(otherRange)) {
return true; return true;
} }
@ -241,6 +239,7 @@ public class TextEntity implements IEntity {
} }
public boolean intersects(TextEntity textEntity) { public boolean intersects(TextEntity textEntity) {
return this.textRange.intersects(textEntity.getTextRange()) // return this.textRange.intersects(textEntity.getTextRange()) //

View File

@ -155,7 +155,7 @@ public class ManualChangesApplicationService {
entityToBeResized.setTextRange(closestEntity.getTextRange()); entityToBeResized.setTextRange(closestEntity.getTextRange());
entityToBeResized.setTextAfter(closestEntity.getTextAfter()); entityToBeResized.setTextAfter(closestEntity.getTextAfter());
entityToBeResized.setTextBefore(closestEntity.getTextBefore()); entityToBeResized.setTextBefore(closestEntity.getTextBefore());
entityToBeResized.setDuplicateTextRanges(new ArrayList<>(closestEntity.getDuplicateTextRanges())); entityToBeResized.setDuplicateTextRanges(new HashSet<>(closestEntity.getDuplicateTextRanges()));
entityToBeResized.setValue(closestEntity.getValue()); entityToBeResized.setValue(closestEntity.getValue());
entityToBeResized.setPages(newIntersectingPages); entityToBeResized.setPages(newIntersectingPages);
} }

View File

@ -140,7 +140,7 @@ public class EntityFromPrecursorCreationService {
} }
correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode()); correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode());
correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes())); correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes()));
correctEntity.setDuplicateTextRanges(new ArrayList<>(closestEntity.getDuplicateTextRanges())); correctEntity.setDuplicateTextRanges(new HashSet<>(closestEntity.getDuplicateTextRanges()));
correctEntity.setPages(new HashSet<>(closestEntity.getPages())); correctEntity.setPages(new HashSet<>(closestEntity.getPages()));
correctEntity.setValue(closestEntity.getValue()); correctEntity.setValue(closestEntity.getValue());

View File

@ -261,7 +261,6 @@ public class DocumineFloraTest extends AbstractRedactionIntegrationTest {
} }
@Disabled
@Test @Test
public void testDoseMortalityExtraction() { public void testDoseMortalityExtraction() {