Look at the main function. Notice the following lines that are commented out:
model = gensim.models.Word2Vec() model = model.load_word2vec_format(RESOURCES+'glove_model.txt', binary=False)
These lines will load a pre-trained vector-based model into memory.5 Uncomment them. Before
you do anything else, try running your code again, and notice how the runtime changes.
Now, implement vecSimilarities. The usual list of word pairs and the pre-trained model
will be passed in to your function. Like the other functions, it should return a dictionary of
(word1, word2): score entries. You can use Gensim to get the cosine similarity
between the vector for word1 and the vector for word2; you’ll need to multiply by ten like you
did with the WordNet functions.
Look at the
main
function. Notice the following lines that are commented out:model = gensim.models.Word2Vec() model = model.load_word2vec_format(RESOURCES+'glove_model.txt', binary=False)
These lines will load a pre-trained vector-based model into memory.5 Uncomment them. Before you do anything else, try running your code again, and notice how the runtime changes.
Now, implement
vecSimilarities
. The usual list of word pairs and the pre-trained model will be passed in to your function. Like the other functions, it should return a dictionary of(word1, word2): score
entries. You can use Gensim to get the cosine similarity between the vector for word1 and the vector for word2; you’ll need to multiply by ten like you did with the WordNet functions.Hint: See what the model can do here: https://radimrehurek.com/gensim/models/word2vec.html