def _get_correct_alignement(context, answer):
    """ Some original examples in SQuAD have indices wrong by 1 or 2 character. We test and fix this here. """
    gold_text = answer['text']
    start_idx = answer['answer_start']
    end_idx = start_idx + len(gold_text)
    if context[start_idx-1:end_idx-1] == gold_text:
        return start_idx-1, end_idx-1   # When the gold label is off by one character
    elif context[start_idx-2:end_idx-2] == gold_text:
        return start_idx-2, end_idx-2   # When the gold label is off by two character
    elif context[start_idx+1:end_idx+1] == gold_text:
        return start_idx+1, end_idx+1   # When the gold label is off by one character
    elif context[start_idx+2:end_idx+2] == gold_text:
        return start_idx+2, end_idx+2   # When the gold label is off by two character
    else:
        return start_idx, end_idx # When the gold label position is good or can't be found