Pull request #398: RED-4064: Fixed override logic for resized entries

Merge in RED/redaction-service from RED-4064 to master

* commit '7ca3416d1d809189430540603034b67dfddd5bcd':
  RED-4064: Fixed override logic for resized entries
This commit is contained in:
Dominique Eiflaender 2022-06-02 12:43:07 +02:00
commit a16f9c6d6e
6 changed files with 19 additions and 8 deletions

View File

@ -56,6 +56,8 @@ public class Entity implements ReasonHolder {
private EntityType entityType;
private boolean resized;
public Entity(String word, String type, boolean redaction, String redactionReason,
List<EntityPositionSequence> positionSequences, String headline, int matchedRule, int sectionNumber,

View File

@ -901,10 +901,13 @@ public class Section {
if (resize.getAnnotationId().equals(pos.getId()) && resize.getValue().length() < e.getWord().length() && e.getWord().contains(resize.getValue())) {
int start = e.getWord().indexOf(resize.getValue());
e.setStart(e.getStart() + start);
e.setEnd(e.getEnd() - resize.getValue().length());
e.setEnd(e.getStart() + resize.getValue().length());
e.setResized(true);
e.setWord(resize.getValue());
}
});
}));
return entitiesWithPositions;
}

View File

@ -112,7 +112,11 @@ public class EntitySearchUtils {
wordsToRemove.add(word);
} else if(!(inner.getEntityType() == EntityType.FALSE_RECOMMENDATION && word.getEntityType() == EntityType.ENTITY ||
inner.getEntityType() == EntityType.ENTITY && word.getEntityType() == EntityType.FALSE_RECOMMENDATION)) {
wordsToRemove.add(inner);
if(inner.isResized()){
wordsToRemove.add(word);
} else {
wordsToRemove.add(inner);
}
}
}
}

View File

@ -822,21 +822,22 @@ public class RedactionIntegrationTest {
long start = System.currentTimeMillis();
AnalyzeRequest request = prepareStorage("files/new/ResizeRedactionTestDoc.pdf");
AnalyzeRequest request = prepareStorage("files/new/S157.pdf");
ManualRedactions manualRedactions = new ManualRedactions();
manualRedactions.getResizeRedactions()
.add(ManualResizeRedaction.builder()
.annotationId("fd5ee82900beb7383f00480dea417569")
.annotationId("ca2b437e2480a4b5966cb8386020d454")
.fileId(TEST_FILE_ID)
.status(AnnotationStatus.APPROVED)
.requestDate(OffsetDateTime.of(2022, 05, 23, 8, 30, 07, 475479, ZoneOffset.UTC))
.processedDate(OffsetDateTime.of(2022, 05, 23, 8, 30, 07, 483651, ZoneOffset.UTC))
.value("Regina")
.positions(List.of(new Rectangle(147.86f, 225.9895f, 31.17696f, 10.048125f, 1)))
.textBefore("Switzerland Contact point: ")
.textAfter(" Dorn Phone:")
.value("Bera P")
.positions(List.of(new Rectangle(382.12485f, 235.94246f, 8.768621f, -21.632504f, 1)))
.textBefore("")
.textAfter("")
.build());
request.setManualRedactions(manualRedactions);

View File

@ -10,3 +10,4 @@ Naka-27 Aomachi, Nomi, Ishikawa 923-1101, Japan, JP
Sude Halide Nurullah
Xinyi Y. Tao
Dorn
Prasher