RED-8481: Use visual layout parsing to detect signatures

added a new layer for visual parsing results

codestyle
This commit is contained in:
yhampe 2024-02-23 12:46:51 +01:00
parent a927cbd9dc
commit 71477dabde
2 changed files with 31 additions and 24 deletions

View File

@ -3,7 +3,6 @@ package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -45,6 +44,7 @@ public class DocumentStructure implements Serializable {
public static final String ID = "id"; public static final String ID = "id";
} }
@Schema(description = "Object containing the extra field names, a table cell has in its properties field.") @Schema(description = "Object containing the extra field names, a table cell has in its properties field.")
public static class TableCellProperties implements Serializable { public static class TableCellProperties implements Serializable {

View File

@ -61,12 +61,15 @@ public class LayoutGridService {
static Color IMAGE_VISUAL_COLOR = new Color(122, 0, 255); static Color IMAGE_VISUAL_COLOR = new Color(122, 0, 255);
@SneakyThrows @SneakyThrows
@Observed(name = "ViewerDocumentService", contextualName = "create-viewer-document") @Observed(name = "ViewerDocumentService", contextualName = "create-viewer-document")
public void addLayoutGrid(File originFile, Document document, File destinationFile, boolean layerVisibilityDefaultValue) { public void addLayoutGrid(File originFile, Document document, File destinationFile, boolean layerVisibilityDefaultValue) {
this.addLayoutGrid(originFile, document, destinationFile, layerVisibilityDefaultValue, false); this.addLayoutGrid(originFile, document, destinationFile, layerVisibilityDefaultValue, false);
} }
@SneakyThrows @SneakyThrows
@Observed(name = "ViewerDocumentService", contextualName = "create-viewer-document") @Observed(name = "ViewerDocumentService", contextualName = "create-viewer-document")
public void addLayoutGrid(File originFile, Document document, File destinationFile, boolean layerVisibilityDefaultValue, boolean visualParsingGrid) { public void addLayoutGrid(File originFile, Document document, File destinationFile, boolean layerVisibilityDefaultValue, boolean visualParsingGrid) {
@ -82,10 +85,13 @@ public class LayoutGridService {
.build()); .build());
} }
private LayoutGrid createLayoutGrid(Document document, boolean visualParsingGrid) { private LayoutGrid createLayoutGrid(Document document, boolean visualParsingGrid) {
LayoutGrid layoutGrid = new LayoutGrid(document.getNumberOfPages()); LayoutGrid layoutGrid = new LayoutGrid(document.getNumberOfPages());
document.streamAllSubNodes().filter(node -> (node.getEngines().contains(LayoutEngine.AI) && visualParsingGrid ) || (node.getEngines().contains(LayoutEngine.ALGORITHM) && !visualParsingGrid)).forEach(semanticNode -> { document.streamAllSubNodes()
.filter(node -> (node.getEngines().contains(LayoutEngine.AI) && visualParsingGrid) || (node.getEngines().contains(LayoutEngine.ALGORITHM) && !visualParsingGrid))
.forEach(semanticNode -> {
Color color = switch (semanticNode.getType()) { Color color = switch (semanticNode.getType()) {
case PARAGRAPH -> PARAGRAPH_COLOR; case PARAGRAPH -> PARAGRAPH_COLOR;
case TABLE -> TABLE_COLOR; case TABLE -> TABLE_COLOR;
@ -109,6 +115,7 @@ public class LayoutGridService {
return layoutGrid; return layoutGrid;
} }
private void addInnerTableLines(Table table, LayoutGrid layoutGrid) { private void addInnerTableLines(Table table, LayoutGrid layoutGrid) {
if (table.getNumberOfCols() < 1 || table.getNumberOfRows() < 1) { if (table.getNumberOfCols() < 1 || table.getNumberOfRows() < 1) {