def get_token_index(text, offset, tokens):
    """
    >>> text = "A quick brownDasheyBhgx fox jump's over the lazy dog"
    >>> tokens = ['[CLS]', 'a', 'quick', 'brown', '##das', '##hey', '##bh',
    ...           '##g', '##x', 'fox', 'jump', "'", 's', 'over', 'the', 'lazy',
    ...           'dog', '[SEP]']
    >>> tokens[get_token_index(text, text.index('fox'), tokens)] == 'fox'
    True
    >>> tokens[get_token_index(text, text.index('over'), tokens)] == 'over'
    True
    """
    # the idea is, match tokens chunk by chunk
    i = 1  # skip [CLS] in the beginning
    for chunk in text[:offset].split():
        acc = ''
        while len(acc) < len(chunk):
            acc += tokens[i].lstrip('##')
            i += 1
            if i >=len(tokens):
                break
    return i