RED-7074: Design Subsection section tree structure algorithm
* fix for boundary error
This commit is contained in:
parent
d2dc369df3
commit
a9338262c5
@ -56,8 +56,7 @@ public class ConcatenatedTextBlock implements TextBlock {
|
|||||||
boundary.setStart(start);
|
boundary.setStart(start);
|
||||||
boundary.setEnd(end);
|
boundary.setEnd(end);
|
||||||
} else if (boundary.end() != start) {
|
} else if (boundary.end() != start) {
|
||||||
//throw new UnsupportedOperationException(format("Can only concat consecutive TextBlocks, trying to concat %s and %s", boundary, textBlock.getBoundary()));
|
throw new UnsupportedOperationException(format("Can only concat consecutive TextBlocks, trying to concat %s and %s", boundary, textBlock.getBoundary()));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
this.atomicTextBlocks.addAll(textBlock.getAtomicTextBlocks());
|
this.atomicTextBlocks.addAll(textBlock.getAtomicTextBlocks());
|
||||||
boundary.setEnd(end);
|
boundary.setEnd(end);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.knecon.fforesight.service.layoutparser.processor.model.outline;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -26,6 +27,11 @@ public class TOCEnrichmentService {
|
|||||||
public void assignSectionBlocksAndImages(ClassificationDocument document) {
|
public void assignSectionBlocksAndImages(ClassificationDocument document) {
|
||||||
|
|
||||||
TableOfContents toc = document.getTableOfContents();
|
TableOfContents toc = document.getTableOfContents();
|
||||||
|
Iterator<TableOfContentItem> iterator = toc.iterator();
|
||||||
|
TableOfContentItem currentTOCItem = null;
|
||||||
|
if(iterator.hasNext()) {
|
||||||
|
currentTOCItem = iterator.next();
|
||||||
|
}
|
||||||
List<AbstractPageBlock> startBlocks = new ArrayList<>();
|
List<AbstractPageBlock> startBlocks = new ArrayList<>();
|
||||||
List<ClassifiedImage> startImages = new ArrayList<>();
|
List<ClassifiedImage> startImages = new ArrayList<>();
|
||||||
TableOfContentItem currentSection = null;
|
TableOfContentItem currentSection = null;
|
||||||
@ -64,28 +70,24 @@ public class TOCEnrichmentService {
|
|||||||
}
|
}
|
||||||
previousTable = table;
|
previousTable = table;
|
||||||
}
|
}
|
||||||
boolean matched = false;
|
|
||||||
|
|
||||||
for (TableOfContentItem tocItem : toc) {
|
if (current instanceof TextPageBlock && currentTOCItem != null && currentTOCItem.getHeadline().getText().equals(current.getText())) {
|
||||||
if (current instanceof TextPageBlock && tocItem.getHeadline().getText().equals(current.getText())) {
|
if (!foundFirstHeadline) {
|
||||||
if (!foundFirstHeadline) {
|
foundFirstHeadline = true;
|
||||||
foundFirstHeadline = true;
|
}
|
||||||
}
|
currentSection = currentTOCItem;
|
||||||
currentSection = tocItem;
|
currentTOCItem.getSectionBlocks().add(current);
|
||||||
//sectionsMap.get(tocItem).add(current);
|
currentPageTOCItems.add(currentTOCItem);
|
||||||
tocItem.getSectionBlocks().add(current);
|
|
||||||
currentPageTOCItems.add(tocItem);
|
if(iterator.hasNext()) {
|
||||||
matched = true;
|
currentTOCItem = iterator.next();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!matched) {
|
if (!foundFirstHeadline) {
|
||||||
if (!foundFirstHeadline) {
|
startBlocks.add(current);
|
||||||
startBlocks.add(current);
|
} else {
|
||||||
} else {
|
currentSection.getSectionBlocks().add(current);
|
||||||
currentSection.getSectionBlocks().add(current);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user