RED-5381: Further imporve

This commit is contained in:
deiflaender 2022-10-14 12:48:13 +02:00
parent 2f72dc895c
commit 248e4100c0
4 changed files with 13 additions and 25 deletions

View File

@ -69,7 +69,7 @@ public class TextBlock extends AbstractTextContainer {
public float getX1() { public float getX1() {
if (getDir().getDegrees() == 90) { if (getDir().getDegrees() == 90) {
return minX; return minY;
} }
else if (getDir().getDegrees() == 180) { else if (getDir().getDegrees() == 180) {
return getPageWidth() - maxX; return getPageWidth() - maxX;
@ -90,7 +90,7 @@ public class TextBlock extends AbstractTextContainer {
public float getX2() { public float getX2() {
if (getDir().getDegrees() == 90) { if (getDir().getDegrees() == 90) {
return maxX; return maxY;
} }
else if (getDir().getDegrees() == 180) { else if (getDir().getDegrees() == 180) {
@ -116,7 +116,7 @@ public class TextBlock extends AbstractTextContainer {
public float getY1() { public float getY1() {
if (getDir().getDegrees() == 90 ) { if (getDir().getDegrees() == 90 ) {
return minY; return minX;
} }
else if (getDir().getDegrees() == 180) { else if (getDir().getDegrees() == 180) {
@ -139,7 +139,7 @@ public class TextBlock extends AbstractTextContainer {
public float getY2() { public float getY2() {
if (getDir().getDegrees() == 90) { if (getDir().getDegrees() == 90) {
return maxY; return maxX;
} }
else if (getDir().getDegrees() == 180 ) { else if (getDir().getDegrees() == 180 ) {

View File

@ -68,7 +68,7 @@ public class ClassificationService {
public void classifyBlock(TextBlock textBlock, Rectangle bodyTextFrame, Page page, Document document, public void classifyBlock(TextBlock textBlock, Rectangle bodyTextFrame, Page page, Document document,
List<Float> headlineFontSizes) { List<Float> headlineFontSizes) {
System.out.println("B" + textBlock.getSequences().get(0).getDir()); System.out.println("Page: " + page.getPageNumber() + " rotation " + page.getRotation() +" B " + textBlock.getSequences().get(0).getDir());
if (document.getFontSizeCounter().getMostPopular() == null) { if (document.getFontSizeCounter().getMostPopular() == null) {
textBlock.setClassification("Other"); textBlock.setClassification("Other");

View File

@ -160,12 +160,9 @@ public class TextPositionSequence implements CharSequence {
@JsonAttribute(ignore = true) @JsonAttribute(ignore = true)
public float getX1() { public float getX1() {
if (getDir().getDegrees() == 90) {
return textPositions.get(0).getYDirAdj() - getTextHeight();
}
else {
return textPositions.get(0).getXDirAdj(); return textPositions.get(0).getXDirAdj();
}
} }
@ -173,14 +170,9 @@ public class TextPositionSequence implements CharSequence {
@JsonAttribute(ignore = true) @JsonAttribute(ignore = true)
public float getX2() { public float getX2() {
if (getDir().getDegrees() == 90) {
return textPositions.get(0).getYDirAdj();
}
else {
return textPositions.get(textPositions.size() - 1).getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + HEIGHT_PADDING; return textPositions.get(textPositions.size() - 1).getXDirAdj() + textPositions.get(textPositions.size() - 1).getWidthDirAdj() + HEIGHT_PADDING;
}
} }
@ -191,11 +183,9 @@ public class TextPositionSequence implements CharSequence {
@JsonAttribute(ignore = true) @JsonAttribute(ignore = true)
public float getY1() { public float getY1() {
if (getDir().getDegrees() == 90 ) {
return textPositions.get(0).getXDirAdj();
}
if (getDir().getDegrees() == 270) {
if (getDir().getDegrees() == 270 || getDir().getDegrees() == 90) {
return textPositions.get(0).getYDirAdj() - getTextHeight(); return textPositions.get(0).getYDirAdj() - getTextHeight();
} }
@ -210,11 +200,9 @@ public class TextPositionSequence implements CharSequence {
@JsonAttribute(ignore = true) @JsonAttribute(ignore = true)
public float getY2() { public float getY2() {
if (getDir().getDegrees() == 90) {
return textPositions.get(textPositions.size() - 1).getXDirAdj() + getTextHeight() - HEIGHT_PADDING;
}
if (getDir().getDegrees() == 270) {
if (getDir().getDegrees() == 270 || getDir().getDegrees() == 90) {
return textPositions.get(0).getYDirAdj(); return textPositions.get(0).getYDirAdj();
} }

View File

@ -1098,7 +1098,7 @@ public class RedactionIntegrationTest {
System.out.println("classificationTest"); System.out.println("classificationTest");
AnalyzeRequest request = prepareStorage("files/RSS/02 - A22833B - Acute Oral (Up and Down) - Final Report1.pdf"); AnalyzeRequest request = prepareStorage("files/new/VV-511309_OCR.pdf");
RedactionRequest redactionRequest = RedactionRequest.builder() RedactionRequest redactionRequest = RedactionRequest.builder()
.dossierId(request.getDossierId()) .dossierId(request.getDossierId())