Text_Preprocessing.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:AI-Chatbot 作者: anujdutt9 项目源码 文件源码
def vectorize_ques(data, word_id, test_max_length, ques_max_length):
    X = []
    Xq = []
    for subtext, question in data:
        x = [word_id[w] for w in subtext]
        xq = [word_id[w] for w in question]
        # let's not forget that index 0 is reserved
        X.append(x)
        Xq.append(xq)
    return (pad_sequences(X, maxlen=test_max_length),
            pad_sequences(Xq, maxlen=ques_max_length))


# Vectorize the text
# Convert Subtext, Questions, Answers to Vector Form
# Y: array[] of zero's with "1" corresponding to word representing correct answer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号