Skip to content

Instantly share code, notes, and snippets.

@arunm8489
Created August 1, 2020 14:21
Show Gist options
  • Save arunm8489/01792149503e6f2b39c204507560da10 to your computer and use it in GitHub Desktop.
Save arunm8489/01792149503e6f2b39c204507560da10 to your computer and use it in GitHub Desktop.
#code from https://stackoverflow.com/questions/37793118/load-pretrained-glove-vectors-in-python
def loadGloveModel(File):
print("Loading Glove Model")
f = open(File,'r')
gloveModel = {}
for line in f:
splitLines = line.split()
word = splitLines[0]
wordEmbedding = np.array([float(value) for value in splitLines[1:]])
gloveModel[word] = wordEmbedding
print(len(gloveModel)," words loaded!")
return gloveModel
glove_dict = loadGloveModel("glove.42B.300d.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment