Skip to content

Instantly share code, notes, and snippets.

@sid321axn
Created August 7, 2020 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sid321axn/6b88d3ecc506df27c59b6c8a70ae55c8 to your computer and use it in GitHub Desktop.
Save sid321axn/6b88d3ecc506df27c59b6c8a70ae55c8 to your computer and use it in GitHub Desktop.
# load in pre-trained word vectors
print('Loading word vectors...')
word2vec = {}
with open(EMBEDDING_FILE) as f:
# is just a space-separated text file in the format:
# word vec[0] vec[1] vec[2] ...
for line in f:
values = line.split()
word = values[0]
vec = np.asarray(values[1:], dtype='float32')
word2vec[word] = vec
print('Found %s word vectors.' % len(word2vec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment