(sentence)
return index_list
将一个句子转换成index的list，并截断或补零
将一个句子转换成index的list，并截断或补零
将一个句子转换成index的list，并截断或补零
def sentence2index(sentence):
    """将一个句子转换成index的list，并截断或补零"""
    word_list = sentence.strip().split()
    index_list = list(map(word2index, word_list))
    len_sen = len(index_list)
    if  len_sen < fix_len:
        index_list = index_list + [0]*(fix_len - len_sen)
    else:
        index_list = index_list[:fix_len]
    return index_list
def sentence2index ( sentence ) : word_list = sentence . strip ( ) . split ( ) index_list = list ( map ( word2index , word_list ) ) len_sen = len ( index_list ) if len_sen < fix_len : index_list = index_list + [ 0 ] * ( fix_len - len_sen ) else : index_list = index_list [ : fix_len ] return index_list