in source/paraphrase.py [0:0]
def MarginAbs(em, ofp, params, args, stats):
D, I = params.idx.search(em, args.kmax)
thresh = args.threshold_faiss
if args.embed:
D, I = IndexDistL2(em, params.E, D, I, args.threshold_faiss)
thresh = args.threshold_L2
for n in range(D.shape[0]):
prev = {} # for deduplication
for i in range(args.kmax):
txt = IndexTextQuery(params.T, params.R, I[n, i])
if (args.dedup and txt not in prev) and D[n, i] <= thresh:
prev[txt] = 1
ofp.write('{:d}\t{:7.5f}\t{}\n'
.format(stats.nbs, D[n, i], txt))
stats.nbp += 1
# display source sentece if requested
if (args.include_source == 'matches' and len(prev) > 0):
ofp.write('{:d}\t{:6.1f}\t{}\n'
.format(stats.nbs, 0.0, sentences[n].replace('@@ ', '')))
if args.include_source == 'always':
ofp.write('{:d}\t{:6.1f}\t{}\n'
.format(stats.nbs, 0.0, sentences[n].replace('@@ ', '')))
stats.nbs += 1