def sims2scores(self, sims, eps=<NUM_LIT>):
result = []<EOL>if isinstance(sims, numpy.ndarray):<EOL><INDENT>sims = abs(sims) <EOL>for pos in numpy.argsort(sims)[::-<NUM_LIT:1>]:<EOL><INDENT>if pos in self.pos2id and sims[pos] > eps: <EOL><INDENT>result.append((self.pos2id[pos], sims[pos]))<EOL>if len(result) == self.topsims:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for pos, score in sims:<EOL><INDENT>if pos in self.pos2id and abs(score) > eps: <EOL><INDENT>result.append((self.pos2id[pos], abs(score)))<EOL>if len(result) == self.topsims:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Convert raw similarity vector to a list of (docid, similarity) results.