def merge_slots()

in code/scripts/utils.py [0:0]


def merge_slots(slots, alignment):
    merged_slots = []
    start_idx = alignment[0]
    for end_idx in alignment[1:]:
        tag = slots[start_idx]
        for slot in slots[start_idx: end_idx]:
            if slot.startswith('B') and tag == 'O':
                tag = slot
            elif slot.startswith('I') and tag == 'O':
                tag = slot
        start_idx = end_idx
        merged_slots.append(tag)
    return merged_slots