Merge branch 'RED-9760-4.1' into 'release/0.142.x'
RED-9760: Fixed missing newLines See merge request fforesight/layout-parser!185
This commit is contained in:
commit
ca69d3f5dc
@ -1,5 +1,7 @@
|
|||||||
package com.knecon.fforesight.service.layoutparser.processor.model.text;
|
package com.knecon.fforesight.service.layoutparser.processor.model.text;
|
||||||
|
|
||||||
|
import static com.knecon.fforesight.service.layoutparser.processor.utils.ParsingConstants.NEW_LINE_TEXT_HEIGHT_PERCENTAGE;
|
||||||
|
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -208,7 +210,7 @@ public class TextPageBlock extends AbstractPageBlock {
|
|||||||
TextPositionSequence previous = null;
|
TextPositionSequence previous = null;
|
||||||
for (TextPositionSequence word : sequences) {
|
for (TextPositionSequence word : sequences) {
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
if (Math.abs(previous.getMaxYDirAdj() - word.getMaxYDirAdj()) > word.getTextHeight()) {
|
if (Math.abs(previous.getMaxYDirAdj() - word.getMaxYDirAdj()) > word.getTextHeight() * NEW_LINE_TEXT_HEIGHT_PERCENTAGE) {
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
} else {
|
} else {
|
||||||
sb.append(' ');
|
sb.append(' ');
|
||||||
@ -228,7 +230,7 @@ public class TextPageBlock extends AbstractPageBlock {
|
|||||||
TextPositionSequence previous = null;
|
TextPositionSequence previous = null;
|
||||||
for (TextPositionSequence word : sequences) {
|
for (TextPositionSequence word : sequences) {
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
if (word.getMaxYDirAdj() - previous.getMaxYDirAdj() > word.getTextHeight()) {
|
if (word.getMaxYDirAdj() - previous.getMaxYDirAdj() > word.getTextHeight() * NEW_LINE_TEXT_HEIGHT_PERCENTAGE) {
|
||||||
numberOfLines++;
|
numberOfLines++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.knecon.fforesight.service.layoutparser.processor.services.factory;
|
package com.knecon.fforesight.service.layoutparser.processor.services.factory;
|
||||||
|
|
||||||
|
import static com.knecon.fforesight.service.layoutparser.processor.utils.ParsingConstants.NEW_LINE_TEXT_HEIGHT_PERCENTAGE;
|
||||||
|
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -67,7 +69,6 @@ public class SearchTextWithTextPositionFactory {
|
|||||||
++context.stringIdx;
|
++context.stringIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<Rectangle2D> positions = sequences.stream()
|
List<Rectangle2D> positions = sequences.stream()
|
||||||
.map(TextPositionSequence::getTextPositions)
|
.map(TextPositionSequence::getTextPositions)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
@ -161,7 +162,7 @@ public class SearchTextWithTextPositionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double deltaY = Math.abs(currentPosition.getYDirAdj() - previousPosition.getYDirAdj());
|
double deltaY = Math.abs(currentPosition.getYDirAdj() - previousPosition.getYDirAdj());
|
||||||
return deltaY >= currentPosition.getHeightDir();
|
return deltaY >= currentPosition.getHeightDir() * NEW_LINE_TEXT_HEIGHT_PERCENTAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,9 +192,9 @@ public class SearchTextWithTextPositionFactory {
|
|||||||
|
|
||||||
float textHeight = sequence.getTextHeight() + HEIGHT_PADDING;
|
float textHeight = sequence.getTextHeight() + HEIGHT_PADDING;
|
||||||
Rectangle2D rectangle2D = new Rectangle2D.Double(textPosition.getXDirAdj(),
|
Rectangle2D rectangle2D = new Rectangle2D.Double(textPosition.getXDirAdj(),
|
||||||
textPosition.getYDirAdj() - textHeight,
|
textPosition.getYDirAdj() - textHeight,
|
||||||
textPosition.getWidthDirAdj(),
|
textPosition.getWidthDirAdj(),
|
||||||
textHeight + HEIGHT_PADDING);
|
textHeight + HEIGHT_PADDING);
|
||||||
|
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.knecon.fforesight.service.layoutparser.processor.utils;
|
||||||
|
|
||||||
|
public class ParsingConstants {
|
||||||
|
|
||||||
|
public final static float NEW_LINE_TEXT_HEIGHT_PERCENTAGE = 0.6f;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user