RED-8642: Use LineMode from cv-analysis-service instead of table cell mode
* changes for line mode instead of cell mode of cv table parsing
This commit is contained in:
parent
e99fad0c3d
commit
ad1e44ca5c
@ -282,7 +282,7 @@ public class LayoutParsingPipeline {
|
||||
}
|
||||
|
||||
if (signatures.containsKey(pageNumber)) {
|
||||
if (classificationPage.getImages() == null || classificationPage.getImages().size() == 0) {
|
||||
if (classificationPage.getImages() == null || classificationPage.getImages().isEmpty()) {
|
||||
classificationPage.setImages(signatures.get(pageNumber));
|
||||
} else {
|
||||
classificationPage.getImages().addAll(signatures.get(pageNumber));
|
||||
|
||||
@ -6,13 +6,11 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.knecon.fforesight.service.layoutparser.processor.model.table.Ruling;
|
||||
import com.knecon.fforesight.service.layoutparser.processor.python_api.model.table.PageInfo;
|
||||
import com.knecon.fforesight.service.layoutparser.processor.python_api.model.table.TableCell;
|
||||
import com.knecon.fforesight.service.layoutparser.processor.python_api.model.table.TableLine;
|
||||
import com.knecon.fforesight.service.layoutparser.processor.python_api.model.table.TableServiceResponse;
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class TableData {
|
||||
|
||||
private PageInfo pageInfo;;
|
||||
private PageInfo pageInfo;
|
||||
private List<TableLine> tableLines = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@ -35,10 +35,10 @@ public class RulingCleaningService {
|
||||
Rulings verticalAndHorizontalRulingLines;
|
||||
|
||||
// todo 8642: set cv parsed only when no rulings exist or just always add them?
|
||||
if (!rulings.isEmpty()) {
|
||||
verticalAndHorizontalRulingLines = extractVerticalAndHorizontalRulingLines(rulings);
|
||||
} else {
|
||||
if (rulings.isEmpty() && parsedRulings != null) {
|
||||
verticalAndHorizontalRulingLines = extractVerticalAndHorizontalRulingLines(parsedRulings);
|
||||
} else {
|
||||
verticalAndHorizontalRulingLines = extractVerticalAndHorizontalRulingLines(rulings);
|
||||
}
|
||||
|
||||
verticalAndHorizontalRulingLines.verticalLines.sort(X_FIRST_RULING_COMPARATOR);
|
||||
@ -81,7 +81,7 @@ public class RulingCleaningService {
|
||||
Rectangle rectangle2 = rectangles.get(j);
|
||||
|
||||
// we can stop early when we are too far off because of x-y-sorting
|
||||
if(rectangle1.getRight() < rectangle2.getLeft() && rectangle1.getBottom() < rectangle2.getTop()) {
|
||||
if (rectangle1.getRight() < rectangle2.getLeft() && rectangle1.getBottom() < rectangle2.getTop()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -159,43 +159,19 @@ public class RulingCleaningService {
|
||||
private Rulings extractVerticalAndHorizontalRulingLines(List<Ruling> rulings) {
|
||||
|
||||
List<Ruling> vrs = new ArrayList<>();
|
||||
for (Ruling vr : rulings) {
|
||||
if (vr.vertical()) {
|
||||
vrs.add(vr);
|
||||
List<Ruling> hrs = new ArrayList<>();
|
||||
for (Ruling r : rulings) {
|
||||
if (r.vertical()) {
|
||||
vrs.add(r);
|
||||
}
|
||||
if (r.horizontal()) {
|
||||
hrs.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
List<Ruling> hrs = new ArrayList<>();
|
||||
for (Ruling hr : rulings) {
|
||||
if (hr.horizontal()) {
|
||||
hrs.add(hr);
|
||||
}
|
||||
}
|
||||
return new Rulings(vrs, hrs);
|
||||
}
|
||||
|
||||
|
||||
private Ruling createRuling(float tableCellX0, float tableCellX1, float tableCellY0, float tableCellY1) {
|
||||
|
||||
float x0 = tableCellX0;
|
||||
float x1 = tableCellX1;
|
||||
float y0 = tableCellY0;
|
||||
float y1 = tableCellY1;
|
||||
|
||||
if (x1 < x0) {
|
||||
x0 = tableCellX1;
|
||||
x1 = tableCellX0;
|
||||
}
|
||||
|
||||
if (y1 < y0) {
|
||||
y0 = tableCellY1;
|
||||
y1 = tableCellY0;
|
||||
}
|
||||
|
||||
return new Ruling(new Point2D.Float(x0, y0), new Point2D.Float(x1, y1));
|
||||
}
|
||||
|
||||
|
||||
private record Rulings(List<Ruling> verticalLines, List<Ruling> horizontalLines) {
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user