Pull request #116: Fixed table extraction problems
Merge in RED/redaction-service from TableExtractionProbemFix to master * commit 'fc2ac03691871a8a1f3c8a29756e3a60e63e16bf': Fixed table extraction problems
This commit is contained in:
commit
76ecfdabd3
@ -54,10 +54,7 @@ public class PDFLinesTextStripper extends PDFTextStripper {
|
|||||||
protected PDPage pdpage;
|
protected PDPage pdpage;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int maxCharWidths;
|
private int minCharWidths;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int maxCharHeight;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final List<TextPositionSequence> textPositionSequences = new ArrayList<>();
|
private final List<TextPositionSequence> textPositionSequences = new ArrayList<>();
|
||||||
@ -282,14 +279,9 @@ public class PDFLinesTextStripper extends PDFTextStripper {
|
|||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
for (int i = 0; i <= textPositions.size() - 1; i++) {
|
for (int i = 0; i <= textPositions.size() - 1; i++) {
|
||||||
|
|
||||||
int charHeight = (int) textPositions.get(i).getHeightDir();
|
|
||||||
if (charHeight > maxCharHeight) {
|
|
||||||
maxCharHeight = charHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int charWidth = (int) textPositions.get(i).getWidthDirAdj();
|
int charWidth = (int) textPositions.get(i).getWidthDirAdj();
|
||||||
if (charWidth > maxCharWidths) {
|
if (charWidth < minCharWidths) {
|
||||||
maxCharWidths = charWidth;
|
minCharWidths = charWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0 && (textPositions.get(i).getUnicode().equals(" ") || textPositions.get(i)
|
if (i == 0 && (textPositions.get(i).getUnicode().equals(" ") || textPositions.get(i)
|
||||||
@ -341,8 +333,7 @@ public class PDFLinesTextStripper extends PDFTextStripper {
|
|||||||
@Override
|
@Override
|
||||||
public String getText(PDDocument doc) throws IOException {
|
public String getText(PDDocument doc) throws IOException {
|
||||||
|
|
||||||
maxCharWidths = 0;
|
minCharWidths = Integer.MAX_VALUE;
|
||||||
maxCharWidths = 0;
|
|
||||||
textPositionSequences.clear();
|
textPositionSequences.clear();
|
||||||
imageBounds = new ArrayList<>();
|
imageBounds = new ArrayList<>();
|
||||||
rulings.clear();
|
rulings.clear();
|
||||||
|
|||||||
@ -19,6 +19,5 @@ public class ParsedElements {
|
|||||||
private boolean landscape;
|
private boolean landscape;
|
||||||
private boolean rotated;
|
private boolean rotated;
|
||||||
|
|
||||||
private float maxCharWidth;
|
private float minCharWidth;
|
||||||
private float maxCharHeight;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,14 +61,13 @@ public class PdfSegmentationService {
|
|||||||
.rulings(stripper.getRulings())
|
.rulings(stripper.getRulings())
|
||||||
.sequences(stripper.getTextPositionSequences())
|
.sequences(stripper.getTextPositionSequences())
|
||||||
.imageBounds(stripper.getImageBounds())
|
.imageBounds(stripper.getImageBounds())
|
||||||
.maxCharWidth(stripper.getMaxCharWidths())
|
.minCharWidth(stripper.getMinCharWidths())
|
||||||
.maxCharHeight(stripper.getMaxCharWidths())
|
|
||||||
.landscape(isLandscape)
|
.landscape(isLandscape)
|
||||||
.rotated(isRotated)
|
.rotated(isRotated)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
CleanRulings cleanRulings = rulingCleaningService.getCleanRulings(parsedElements.getRulings(), parsedElements
|
CleanRulings cleanRulings = rulingCleaningService.getCleanRulings(parsedElements.getRulings(), parsedElements
|
||||||
.getMaxCharWidth(), parsedElements.getMaxCharHeight());
|
.getMinCharWidth());
|
||||||
|
|
||||||
Page page = blockificationService.blockify(parsedElements.getSequences(), cleanRulings.getHorizontal(), cleanRulings
|
Page page = blockificationService.blockify(parsedElements.getSequences(), cleanRulings.getHorizontal(), cleanRulings
|
||||||
.getVertical());
|
.getVertical());
|
||||||
|
|||||||
@ -18,9 +18,9 @@ import com.iqser.red.service.redaction.v1.server.tableextraction.utils.Utils;
|
|||||||
@Service
|
@Service
|
||||||
public class RulingCleaningService {
|
public class RulingCleaningService {
|
||||||
|
|
||||||
public CleanRulings getCleanRulings(List<Ruling> rulings, float maxCharWidth, float maxCharHeight){
|
public CleanRulings getCleanRulings(List<Ruling> rulings, float minCharWidth){
|
||||||
if (!rulings.isEmpty()) {
|
if (!rulings.isEmpty()) {
|
||||||
snapPoints(rulings, maxCharWidth , maxCharHeight);
|
snapPoints(rulings, minCharWidth , minCharWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Ruling> vrs = new ArrayList<>();
|
List<Ruling> vrs = new ArrayList<>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user