in src/models/struxgpt_v1.py [0:0]
def remapping_struct_source(self, struct_item: StructItem):
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))]
new_aspect_descs: List[List[str]] = [[] for _ in range(len(struct_item.aspects))]
curr_aspect_idx = 0
for pi, para in enumerate(raw_paras):
total_recalls = []
for ai, aspect in enumerate(struct_item.aspects):
# recalls = [f1_score_auto(prediction=desc, ground_truth=para, term='recall') \
# for desc in aspect.get_descs()]
# total_recalls.append(recalls if len(recalls) else [0])
total_recalls.append([f1_score_auto(prediction=aspect.get_descs(merge=True),
ground_truth=para, term='recall')])
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.
max_aspect_idx = np.argmax(max_recall_per_aspect)
new_aspect_descs[max_aspect_idx].extend(self.split_to_sentence(para))
curr_aspect_idx = max_aspect_idx
for ai, descs in enumerate(new_aspect_descs):
struct_item.aspects[ai].set_descs(descs)
struct_item.aspects = [aspect for aspect in struct_item.aspects if not aspect.is_desc_empty()]