code: def get_glove(base_dir="./data/glove.6B", dim=100):
      """
      Parse the pre-trained glove6B word2vec and return a dict mapping from word to vector,
      given the dim of a vector.
      The word embeddings will be downloaded automatically if not found in the target base_dir.
      """
      glove_dir = base_dir + "/glove.6B"
      if not os.path.isdir(glove_dir):
          download_glove(base_dir)
      glove_path = os.path.join(glove_dir, "glove.6B.%sd.txt" % dim)
      if sys.version_info < (3,):
          w2v_f = open(glove_path)
      else:
          w2v_f = open(glove_path, encoding="latin-1")
      pre_w2v = {}
      for line in w2v_f.readlines():
          items = line.split(" ")
          pre_w2v[items[0]] = [float(i) for i in items[1:]]
      w2v_f.close()
      return pre_w2v
  
file_path: analytics-zoo/pyzoo/zoo/examples/textclassification/news20.py
imports: import tarfile
  import zipfile
  from bigdl.dataset import base
  from bigdl.util.common import *
label_desc: Use image node_id 2 for calling a global function with example usage: get_glove(base_dir, dim) and returns: pre_w2v