(text,tokenizer,max_len=52)
return indices,segments
得到bert的输入
    :param text:
    :param tokenizer:
    :param max_len:
    :return:
得到bert的输入
    :param text:
    :param tokenizer:
    :param max_len:
    :return:
得到bert的输入 : param text : : param tokenizer : : param max_len : : return :
def get_ids_seg(text,tokenizer,max_len=52):
    '''
    得到bert的输入
    :param text:
    :param tokenizer:
    :param max_len:
    :return:
    '''
    indices, segments = [], []
    for ch in text[:max_len-2]:
        indice, segment = tokenizer.encode(first=ch)
        if len(indice) != 3:
            indices += [100]
            segments += [0]
        else:
            indices += indice[1:-1]
            segments += segment[1:-1]
    segments = [0] + segments + [0]
    indices = [101] + indices + [102]
    return indices,segments
def get_ids_seg ( text , tokenizer , max_len = 52 ) : indices , segments = [ ] , [ ] for ch in text [ : max_len - 2 ] : indice , segment = tokenizer . encode ( first = ch ) if len ( indice ) != 3 : indices += [ 100 ] segments += [ 0 ] else : indices += indice [ 1 : - 1 ] segments += segment [ 1 : - 1 ] segments = [ 0 ] + segments + [ 0 ] indices = [ 101 ] + indices + [ 102 ] return indices , segments