Skip to content

Commit

Permalink
Merge pull request #12 from OpenPecha/fix/get-serialize-commentary
Browse files Browse the repository at this point in the history
fix commentary text when no mapping
  • Loading branch information
tenzin3 authored Feb 25, 2025
2 parents 2816943 + 5c4515b commit ea85517
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/alignment_ann_transfer/commentary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ea85517

Please sign in to comment.