import codecs
def read_glove_vecs(glove_file):
    with open(glove_file, 'r', encoding='utf-8') as f:   # 修改这个
        words = set()
        word_to_vec_map = {}
        
        for line in f:
            line = line.strip().split()
            curr_word = line[0]
            words.add(curr_word)
            word_to_vec_map[curr_word] = np.array(line[1:], dtype=np.float64)
            
    return words, word_to_vec_map

重启jupyter

相关文章:

  • 2021-07-22
  • 2021-09-21
  • 2022-01-16
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-04-19
  • 2021-12-27
  • 2021-11-19
  • 2021-06-07
相关资源
相似解决方案