If you are trying to rank them per Doc I suggest using a tuple per Token. I'm not certain on the maths behind cosine similarity but assuming we can use a function f(x,y)
that returns the cosine similarity between x and y, we can apply this to Token 1 to Token 2 and 3 as per your suggestion as follows:
list_with_scores = []
for i,doc in enumerate(Docs):
score1_3 = f(doc[0],doc[1])
score1_3 = f(doc[0],doc[2])
list_with_scores.append(i,score1_3, score_2_3,)
#then sort by score1_3
sortedlist1 = sorted(list_with_scores, key = lambda x:x[1])
#similary, sort by score2_3
sortedlist2 = sorted(list_with_scores, key = lambda x:x[2])
You can also keep the token score in the tuple if required. And the explicit saving to score1_3
and score1_2
can be removed, it's done for readiblity, probably better to leave them as is. For more information regarding the sorting part, check Sort a list of tuples by 2nd item (integer value)