def __init__()

in pipeline/postprocessing/fn-postprocess/main.py [0:0]


    def __init__(self, trp_words, cls_id: int, cls_name: str, page_num: int):
        self.cls_id = cls_id
        self.cls_name = cls_name
        self.page_num = page_num

        if len(trp_words) and not hasattr(trp_words[0], "id"):
            trp_words_by_line = trp_words
            trp_words_flat = [w for ws in trp_words for w in ws]

        else:
            trp_words_by_line = [trp_words]
            trp_words_flat = trp_words
        self.bbox = UniversalBox.aggregate(
            boxes=[UniversalBox(box=w.geometry.boundingBox) for w in trp_words_flat],
        )
        self.blocks = list(map(lambda w: w.id, trp_words_flat))
        self.confidence = min(
            map(
                lambda w: min(
                    w._block.get("PredictedClassConfidence", 1.0),
                    w.confidence,
                ),
                trp_words_flat,
            )
        )
        self.text = "\n".join(
            map(
                lambda words: " ".join([w.text for w in words]),
                trp_words_by_line,
            )
        )