From 5c4515b32433910a254a55c9f43b3f6530ea800d Mon Sep 17 00:00:00 2001 From: tenzin3 Date: Tue, 25 Feb 2025 10:14:37 +0000 Subject: [PATCH] fix commentary text when no mapping --- src/alignment_ann_transfer/commentary.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/alignment_ann_transfer/commentary.py b/src/alignment_ann_transfer/commentary.py index 3481e85..0c8ebfe 100644 --- a/src/alignment_ann_transfer/commentary.py +++ b/src/alignment_ann_transfer/commentary.py @@ -46,10 +46,16 @@ def get_serialized_commentary( root_indices = parse_root_mapping(ann["root_idx_mapping"]) first_idx = root_indices[0] commentary_text = ann["text"] - if not map.get(first_idx): + + if not commentary_text.strip(): continue - display_idx = map[first_idx][0][0] - segments.append(f"<1><{display_idx}>{commentary_text}") + + if not map.get(first_idx): + curr_segment = f"{commentary_text}" + else: + display_idx = map[first_idx][0][0] + curr_segment = f"<1><{display_idx}>{commentary_text}" + segments.append(curr_segment) return segments def get_aligned_display_commentary(