Pull request #292: RED-3059: Fixed inital expansion overlaps
Merge in RED/redaction-service from RED-3059-port to master * commit '0e21e5b4d988d43040573a4fc71547829c815ec0': RED-3059: Fixed inital expansion overlaps
This commit is contained in:
commit
a2c57b94a2
@ -193,15 +193,35 @@ public class EntitySearchUtils {
|
|||||||
|
|
||||||
Set<Entity> result = new HashSet<>();
|
Set<Entity> result = new HashSet<>();
|
||||||
if (existingEntities != null && foundEntities != null) {
|
if (existingEntities != null && foundEntities != null) {
|
||||||
for (Entity existingEntity : existingEntities) {
|
for (Entity foundEntity : foundEntities) {
|
||||||
for (Entity foundEntity : foundEntities) {
|
|
||||||
if (existingEntity.getEnd() < foundEntity.getStart() || foundEntity.getEnd() < existingEntity.getStart()) {
|
if (!overlaps(existingEntities, foundEntity)) {
|
||||||
result.add(foundEntity);
|
result.add(foundEntity);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean overlaps(Set<Entity> existingEntities, Entity found) {
|
||||||
|
|
||||||
|
for (Entity existing : existingEntities) {
|
||||||
|
|
||||||
|
if(existing.getStart().equals(found.getStart())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = existing.getStart(); i <= existing.getEnd(); i++) {
|
||||||
|
for (int j = found.getStart(); j <= found.getEnd(); j++) {
|
||||||
|
if (i == j) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -611,6 +611,23 @@ public class RedactionIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redactionExpansionOverlap() throws IOException {
|
||||||
|
|
||||||
|
ClassPathResource pdfFileResource = new ClassPathResource("files/Minimal Examples/ExpansionTest.pdf");
|
||||||
|
AnalyzeRequest request = prepareStorage(pdfFileResource.getInputStream());
|
||||||
|
|
||||||
|
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(request.getDossierId(), request.getFileId()));
|
||||||
|
AnalyzeResult result = analyzeService.analyze(request);
|
||||||
|
|
||||||
|
var redactionLog = redactionStorageService.getRedactionLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||||
|
|
||||||
|
var values = redactionLog.getRedactionLogEntry().stream().map(RedactionLogEntry::getValue).collect(Collectors.toList());
|
||||||
|
|
||||||
|
assertThat(values).containsExactlyInAnyOrder("Lastname M.", "Doe", "Doe J.", "M. Mustermann", "Mustermann M.", "F. Lastname");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void noExceptionShouldBeThrownForAnyFiles() throws IOException {
|
public void noExceptionShouldBeThrownForAnyFiles() throws IOException {
|
||||||
|
|||||||
@ -151,8 +151,7 @@ public class EntitySearchUtilsTest {
|
|||||||
Set<Entity> result = EntitySearchUtils.findNonOverlappingMatchEntities(existingEntities, foundEntities);
|
Set<Entity> result = EntitySearchUtils.findNonOverlappingMatchEntities(existingEntities, foundEntities);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(0);
|
||||||
assertThat(result).contains(foundEntities2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,8 +181,7 @@ public class EntitySearchUtilsTest {
|
|||||||
Set<Entity> result = EntitySearchUtils.findNonOverlappingMatchEntities(existingEntities, foundEntities);
|
Set<Entity> result = EntitySearchUtils.findNonOverlappingMatchEntities(existingEntities, foundEntities);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(0);
|
||||||
assertThat(result).contains(foundEntities2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8616,3 +8616,8 @@ Zoriki Hosomi Rosana
|
|||||||
Zuberer D
|
Zuberer D
|
||||||
Zubrod J
|
Zubrod J
|
||||||
Zwicker R.E.
|
Zwicker R.E.
|
||||||
|
Doe
|
||||||
|
M. Mustermann
|
||||||
|
F. Lastname
|
||||||
|
Mustermann
|
||||||
|
Lastname
|
||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user