I am trying to compute the dot product of 2 vectors in Python to ultimately calculate cosine similarity.
When it coms to computing the dot product, I'm creating a separate dictionary to store the dot product of each pair of words. Take ('danced', 'sang') as an example.
Both appear to be keys in the vectors dictionary, but when I try to get all pairs of words in the vectors dictionary, the ('danced', 'sang') pair doesn't seem to exist in the dot_products dictionary. Am I doing something wrong when it comes to getting all possible pairs? I would imagine that that would have to be done with nested loops, no?
Here's a basic outline of how you can compute the dot product for each pair of words and store the results in a dictionary: