def search(pattern, sequence):
    """从sequence中寻找子串pattern
    如果找到，返回第一个下标；否则返回-1。
    """
    ret = []
    n = len(pattern)
    for i in range(len(sequence)):
        if sequence[i:i + n] == pattern:
            ret.append(i)
    return ret or -1


# if __name__ == "__main__":
    # vocab = ['我们', '我们是', '我们是冠军', '是冠军', '冠军']
    # text = 'hello laughing 我们是冠军'
    # labels = ['a', 'b']
    # label = {'我们': 'a', '冠军': 'b'}
    # flat = FLATDataProcessor(labels, vocab)
    # for k, v in flat.encode(text, label).items():
    #     print(k, v)