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
|
gradlew
|
||||||
gradle.properties
|
gradle.properties
|
||||||
gradle/
|
gradle/
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store/
|
||||||
|
|||||||
@ -221,9 +221,11 @@ public class DocstrumBlockificationService {
|
|||||||
public void mergeIntersectingBlocks(List<AbstractPageBlock> blocks, float xThreshold, float yThreshold) {
|
public void mergeIntersectingBlocks(List<AbstractPageBlock> blocks, float xThreshold, float yThreshold) {
|
||||||
|
|
||||||
ListIterator<AbstractPageBlock> itty = blocks.listIterator();
|
ListIterator<AbstractPageBlock> itty = blocks.listIterator();
|
||||||
Set<AbstractPageBlock> toRemove = new HashSet<>();
|
|
||||||
while (itty.hasNext()) {
|
while (itty.hasNext()) {
|
||||||
AbstractPageBlock block = itty.next();
|
AbstractPageBlock block = itty.next();
|
||||||
|
if(block == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (block instanceof TablePageBlock) {
|
if (block instanceof TablePageBlock) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -232,7 +234,7 @@ public class DocstrumBlockificationService {
|
|||||||
|
|
||||||
for (int i = 0; i < blocks.size(); i++) {
|
for (int i = 0; i < blocks.size(); i++) {
|
||||||
|
|
||||||
if (toRemove.contains(blocks.get(i))) {
|
if(blocks.get(i) == null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (blocks.get(i) == current) {
|
if (blocks.get(i) == current) {
|
||||||
@ -249,13 +251,19 @@ public class DocstrumBlockificationService {
|
|||||||
boolean toDuplicate = current.isToDuplicate() || inner.isToDuplicate();
|
boolean toDuplicate = current.isToDuplicate() || inner.isToDuplicate();
|
||||||
current.getSequences().addAll(inner.getSequences());
|
current.getSequences().addAll(inner.getSequences());
|
||||||
current = buildTextBlock(current.getSequences(), 0);
|
current = buildTextBlock(current.getSequences(), 0);
|
||||||
|
|
||||||
current.setToDuplicate(toDuplicate);
|
current.setToDuplicate(toDuplicate);
|
||||||
toRemove.add(inner);
|
blocks.set(i, null);
|
||||||
itty.set(current);
|
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