def IndexSearchKNN()

in src/indexing.py [0:0]


def IndexSearchKNN(index, x, T, R, kmax=1, dedup=True):
    D, I = index.search(x, kmax)
    all_res = []
    for n in range(x.shape[0]):
        prev = set()  # for depuplication
        res = []
        for i in range(kmax):
            txt = IndexTextQuery(T, R, I[n, i])
            # txt = T[I[n, i]]
            if dedup and txt not in prev:
                prev.add(txt)
                res.append((txt, D[n, i]))
        all_res.append(res)
    return all_res