Python version of distance calculation for word2vec