def check_struct_missing_desc()

in src/models/struxgpt_v1.py [0:0]


    def check_struct_missing_desc(self, struct_item: StructItem, ignore_single_para=True, min_words_per_para=10):
        assert struct_item.valid and struct_item.raw_query and len(struct_item.aspects)
        raw_paras = [para for para in struct_item.raw_query.splitlines() \
                     if len(white_space_fix(para).split()) > min_words_per_para]
        is_missing = False
        if len(raw_paras) == 1 and ignore_single_para:
            return is_missing
        curr_aspect_idx, curr_desc_ind = 0, 0
        for pi, para in enumerate(raw_paras):
            for sent in self.split_to_sentence(para):
                total_recalls = []
                for ai, aspect in enumerate(struct_item.aspects):
                    recalls = [f1_score_auto(prediction=desc, ground_truth=sent, term='recall') \
                                    for desc in aspect.get_descs()]
                    total_recalls.append(recalls if len(recalls) else [0])
                max_recall_per_aspect = np.array([max(recalls) for recalls in total_recalls])

                ## choose target aspect between current and next aspect
                max_recall_per_aspect[:curr_aspect_idx] = 0.
                max_recall_per_aspect[curr_aspect_idx+2:] = 0.

                if max(max_recall_per_aspect) > 0.5:
                    max_aspect_idx = np.argmax(max_recall_per_aspect)
                    curr_aspect_idx = max(curr_aspect_idx, min(max_aspect_idx, curr_aspect_idx+1))
                    curr_aspect_idx = min(curr_aspect_idx, len(struct_item.aspects)-1)
                    curr_desc_ind = np.argmax(total_recalls[curr_aspect_idx])
                else:
                    is_missing = True
                    descs = struct_item.aspects[curr_aspect_idx].get_descs()
                    descs = descs[:curr_desc_ind] + [sent] + descs[curr_desc_ind:]
                    struct_item.aspects[curr_aspect_idx].set_descs(descs)
    
        return is_missing