def get_entity_from_bio(tokens, entitys):
    """
    Get {word:entity} from bio labeled sequence,. 
    
    Only accept BIO schema.
    inputs:
    tokens:     A     B     C     D     E F
    entitys:    B-GPE I-GPE B-PER I-PER O O
    return: {'AB': 'GPE', 'CD': 'PER'}
    """
    word2entity = {}
    left = 0
    right = 1

    def _forward(idx, mark):
        while (idx < len(entitys) and entitys[idx][0] == mark):
            idx += 1
        return idx

    def _loc(idx, mark):
        while (idx < len(entitys) and entitys[idx][0] != mark):
            idx += 1
        return idx

    def _get_next(idx, marks):
        while (idx < len(entitys) and entitys[idx][0] not in marks):
            idx += 1
        return idx

    def _add(left, right):
        word = ''.join(tokens[left: right])
        entity = list(set([entity[2:] for entity in entitys[left: right]]))
        assert len(entity) == 1
        word2entity[word] = entity[0]

    while left < len(entitys):
        if entitys[left][0] == 'B':
            if right < len(entitys) and entitys[right][0] == 'I':
                right = _get_next(right, ('B', 'O'))
            _add(left, right)
            left = right
            right += 1
        else:
            left = _get_next(left, ('B'))
            right = left + 1
    
    return word2entity