Issue with merging text blocks multiple times
This commit is contained in:
parent
a35d77be2e
commit
5c1708f97f
@ -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