Skip to content

Commit

Permalink
use directory for vocab
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonwalters committed Sep 8, 2024
1 parent 663182f commit 78a2d4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gen_vocab_vecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@

#pickle the entire vocab
#pickle.HIGHEST_PROTOCOL depends on Python version
with open('vocab.pkl', 'wb') as f:
with open('./vocab/vocab.pkl', 'wb') as f:
pickle.dump(words,f,protocol=4)
print("Dumped vocab words to pickle file vocab.pkl")

#place all wordvectors in balltree, and pickle entire tree
tree = nbs.BallTree(wordvecs)
with open('balltree.pkl', 'wb') as f:
with open('./vocab/balltree.pkl', 'wb') as f:
pickle.dump(tree,f,protocol=4)
print("Dumped wordvector BallTree to pickle file balltree.pkl")

#create word:vector dict and pickle it
dict = dict(zip(words,wordvecs))
with open('dict.pkl', 'wb') as f:
with open('./vocab/dict.pkl', 'wb') as f:
pickle.dump(dict,f,protocol=4)
print("Dumped word2vec dictionary in dict.pkl")

0 comments on commit 78a2d4e

Please sign in to comment.