def nn_words(table, wordvecs, query, k=10):
 keys = table.keys()
 qf = table[query]
 scores = numpy.dot(qf, wordvecs.T).flatten()
 sorted_args = numpy.argsort(scores)[::(-1)]
 words = [keys[a] for a in sorted_args[:k]]
 print ('QUERY: ' + query)
 print 'NEAREST: '
 for (i, w) in enumerate(words):
  print w

def nn_words ( table , wordvecs , query , k = 10 ) : keys = table . keys ( ) qf = table [ query ] scores = numpy . dot ( qf , wordvecs . T ) . flatten ( ) sorted_args = numpy . argsort ( scores ) [ : : ( - 1 ) ] words = [ keys [ a ] for a in sorted_args [ : k ] ] print ( 'QUERY: ' + query ) print 'NEAREST: ' for ( i , w ) in enumerate ( words ) : print w
get the nearest neighbour words .