RED-8402: Header and footer are not indexed / searched

checkstyle
added review comments
This commit is contained in:
yhampe 2024-04-08 12:17:49 +02:00
parent 5d3826e9b9
commit c13ff7fbf6
2 changed files with 10 additions and 8 deletions

View File

@ -63,23 +63,25 @@ public class Document implements GenericSemanticNode {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public List<Header> getHeaderSections() {
public List<Header> getHeaders() {
return streamChildrenOfType(NodeType.HEADER).map(node -> (Header) node) return streamChildrenOfType(NodeType.HEADER).map(node -> (Header) node)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public List<Footer> getFooterSections() {
public List<Footer> getFooters() {
return streamChildrenOfType(NodeType.FOOTER).map(node -> (Footer) node) return streamChildrenOfType(NodeType.FOOTER).map(node -> (Footer) node)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public Stream<TextBlock> streamTerminalTextBlocksInOrder() { public Stream<TextBlock> streamTerminalTextBlocksInOrder() {
return streamAllNodes().filter(SemanticNode::isLeaf).map(SemanticNode::getTextBlock); return streamAllNodes().filter(SemanticNode::isLeaf)
.map(SemanticNode::getTextBlock);
} }

View File

@ -10,7 +10,7 @@ import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.Si
import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.SimplifiedText; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.SimplifiedText;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.GenericSemanticNode; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.GenericSemanticNode;
import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Section; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.SemanticNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -24,11 +24,11 @@ public class SimplifiedSectionTextService {
.stream() .stream()
.map(this::toSimplifiedSectionText) .map(this::toSimplifiedSectionText)
.toList(); .toList();
List<SimplifiedSectionText> simplifiedHeadersList = document.getHeaderSections() List<SimplifiedSectionText> simplifiedHeadersList = document.getHeaders()
.stream() .stream()
.map(this::toSimplifiedSectionText) .map(this::toSimplifiedSectionText)
.toList(); .toList();
List<SimplifiedSectionText> simplifiedFootersList = document.getFooterSections() List<SimplifiedSectionText> simplifiedFootersList = document.getFooters()
.stream() .stream()
.map(this::toSimplifiedSectionText) .map(this::toSimplifiedSectionText)
.toList(); .toList();
@ -39,7 +39,7 @@ public class SimplifiedSectionTextService {
} }
private SimplifiedSectionText toSimplifiedSectionText(GenericSemanticNode section) { private SimplifiedSectionText toSimplifiedSectionText(SemanticNode section) {
return SimplifiedSectionText.builder() return SimplifiedSectionText.builder()
.sectionNumber(section.getTreeId() .sectionNumber(section.getTreeId()