Merge branch 'RED-8827' into 'main'
Red 8827 See merge request fforesight/layout-parser!122
This commit is contained in:
commit
8bd0de6263
2
.gitignore
vendored
2
.gitignore
vendored
@ -42,3 +42,5 @@ gradlew.bat
|
||||
gradlew
|
||||
gradle.properties
|
||||
gradle/
|
||||
.DS_Store
|
||||
.DS_Store/
|
||||
|
||||
@ -221,9 +221,11 @@ public class DocstrumBlockificationService {
|
||||
public void mergeIntersectingBlocks(List<AbstractPageBlock> blocks, float xThreshold, float yThreshold) {
|
||||
|
||||
ListIterator<AbstractPageBlock> itty = blocks.listIterator();
|
||||
Set<AbstractPageBlock> toRemove = new HashSet<>();
|
||||
while (itty.hasNext()) {
|
||||
AbstractPageBlock block = itty.next();
|
||||
if(block == null){
|
||||
continue;
|
||||
}
|
||||
if (block instanceof TablePageBlock) {
|
||||
continue;
|
||||
}
|
||||
@ -232,7 +234,7 @@ public class DocstrumBlockificationService {
|
||||
|
||||
for (int i = 0; i < blocks.size(); i++) {
|
||||
|
||||
if (toRemove.contains(blocks.get(i))) {
|
||||
if(blocks.get(i) == null){
|
||||
continue;
|
||||
}
|
||||
if (blocks.get(i) == current) {
|
||||
@ -249,13 +251,19 @@ public class DocstrumBlockificationService {
|
||||
boolean toDuplicate = current.isToDuplicate() || inner.isToDuplicate();
|
||||
current.getSequences().addAll(inner.getSequences());
|
||||
current = buildTextBlock(current.getSequences(), 0);
|
||||
|
||||
current.setToDuplicate(toDuplicate);
|
||||
toRemove.add(inner);
|
||||
blocks.set(i, null);
|
||||
itty.set(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
blocks.removeAll(toRemove);
|
||||
var blocksIterator = blocks.iterator();
|
||||
while(blocksIterator.hasNext()){
|
||||
if(blocksIterator.next() == null){
|
||||
blocksIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user