package com.knecon.fforesight.service.layoutparser.processor.model;

import java.util.Map;
import java.util.stream.Collectors;

import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.NodeType;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode;
import com.knecon.fforesight.service.layoutparser.processor.visualization.LayoutDebugLayer;

public record DocumentWithVisualization(Document document, LayoutDebugLayer layoutDebugLayer) {

    public Map<NodeType, Long> buildSemanticNodeCounts() {

        return document.streamAllSubNodes()
                .collect(Collectors.groupingBy(SemanticNode::getType, Collectors.counting()));
    }

}
