diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/classification/service/ClassificationService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/classification/service/ClassificationService.java index c028d9d4..4362a97f 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/classification/service/ClassificationService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/classification/service/ClassificationService.java @@ -67,15 +67,7 @@ public class ClassificationService { // textBlock.setClassification("Other"); // return; // } - if (PositionUtils.isOverBodyTextFrame(bodyTextFrame, textBlock, page.isRotated()) && (document.getFontSizeCounter() - .getMostPopular() == null || textBlock.getHighestFontSize() <= document.getFontSizeCounter() - .getMostPopular())) { - textBlock.setClassification("Header"); - } else if (PositionUtils.isUnderBodyTextFrame(bodyTextFrame, textBlock) && (document.getFontSizeCounter() - .getMostPopular() == null || textBlock.getHighestFontSize() <= document.getFontSizeCounter() - .getMostPopular())) { - textBlock.setClassification("Footer"); // } else if (page.getPageNumber() == 1 && (!PositionUtils.isTouchingUnderBodyTextFrame(bodyTextFrame, textBlock) && PositionUtils // .getHeightDifferenceBetweenChunkWordAndDocumentWord(textBlock, document.getTextHeightCounter() // .getMostPopular()) > 2.5 && textBlock.getHighestFontSize() > document.getFontSizeCounter() @@ -83,11 +75,13 @@ public class ClassificationService { // if (!Pattern.matches("[0-9]+", textBlock.toString())) { // textBlock.setClassification("Title"); // } - } else + if (textBlock.getText().length() > 5 && textBlock.getMostPopularWordHeight() > document.getTextHeightCounter().getMostPopular() && PositionUtils.getApproxLineCount(textBlock) < 5.9 && !textBlock.getOrientation().equals(Orientation.RIGHT) - && ((textBlock.getMostPopularWordStyle().contains("bold") && Character.isDigit(textBlock.toString().charAt(0))) || textBlock.toString().equals(textBlock.toString().toUpperCase(Locale.ROOT)))) { + && ((textBlock.getMostPopularWordStyle().contains("bold") && Character.isDigit(textBlock.toString().charAt(0))) + || textBlock.toString().equals(textBlock.toString().toUpperCase(Locale.ROOT)) + || textBlock.toString().startsWith("APPENDIX") || textBlock.toString().startsWith("TABLE"))) { textBlock.setClassification("H 1"); document.setHeadlines(true); @@ -97,6 +91,18 @@ public class ClassificationService { textBlock.setClassification("H 2"); document.setHeadlines(true); } + + else if (PositionUtils.isOverBodyTextFrame(bodyTextFrame, textBlock, page.isRotated()) && (document.getFontSizeCounter() + .getMostPopular() == null || textBlock.getHighestFontSize() <= document.getFontSizeCounter() + .getMostPopular())) { + textBlock.setClassification("Header"); + + } else if (PositionUtils.isUnderBodyTextFrame(bodyTextFrame, textBlock) && (document.getFontSizeCounter() + .getMostPopular() == null || textBlock.getHighestFontSize() <= document.getFontSizeCounter() + .getMostPopular())) { + textBlock.setClassification("Footer"); + } + // else if (textBlock.getMostPopularWordStyle().equals("bold") && !document.getFontStyleCounter() // .getMostPopular() // .equals("bold") && PositionUtils.getApproxLineCount(textBlock) < 2.9 && textBlock.getSequences().get(0).getTextPositions().get(0).getFontSizeInPt() >= textBlock.getMostPopularWordFontSize()) { @@ -121,10 +127,11 @@ public class ClassificationService { // .getMostPopular() // .equals("italic") && PositionUtils.getApproxLineCount(textBlock) < 2.9) { // textBlock.setClassification("TextBlock Italic"); -// } else if (PositionUtils.isWithinBodyTextFrame(bodyTextFrame, textBlock)) { -// textBlock.setClassification("TextBlock Unknown"); + else if (PositionUtils.isWithinBodyTextFrame(bodyTextFrame, textBlock)) { + textBlock.setClassification("TextBlock"); + } else { - textBlock.setClassification("TextBlock"); + textBlock.setClassification("Other"); } } diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/segmentation/PdfSegmentationService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/segmentation/PdfSegmentationService.java index 497e30fd..c9fad942 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/segmentation/PdfSegmentationService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/segmentation/PdfSegmentationService.java @@ -96,6 +96,9 @@ public class PdfSegmentationService { boolean isLandscape = pdr.getWidth() > pdr.getHeight(); int rotation = pdPage.getRotation(); + + System.out.println("PageNr: " + pageNumber + " rotation: "+rotation); + boolean isRotated = rotation != 0 && rotation != 360; CleanRulings cleanRulings = rulingCleaningService.getCleanRulings(stripper.getRulings(), stripper.getMinCharWidth(), stripper