utils.py 文件源码

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

项目:QueryReformulator 作者: nyu-dl 项目源码 文件源码
def BOW2(texts, vocab, dim):
    '''
    Convert a list of texts to the BoW dense representation.
    '''
    out = np.zeros((len(texts), dim), dtype=np.int32)
    mask = np.zeros((len(texts), dim), dtype=np.float32)
    for i, text in enumerate(texts):
        bow = BOW(wordpunct_tokenize(text), vocab)
        out[i,:len(bow[0])] = bow[0]
        mask[i,:len(bow[1])] = bow[1]

    return out, mask
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号