Beispiel #1
0
 def _load_run_base_infer(self, run_dir, rankfn, ranktopk, fmt='dict'):
     best_candidate_run, best_topk = None, None
     for candidate_run in glob(os.path.join(run_dir, f'{rankfn}.*.run')):
         c_topk = int(candidate_run.split('.')[-2])
         if c_topk > ranktopk and (best_topk is None or c_topk < best_topk):
             best_candidate_run = candidate_run
             best_topk = c_topk
     if best_candidate_run is not None:
         with self.logger.duration(f'loading {rankfn}:{ranktopk} from larger batch {rankfn}:{best_topk}'):
             return trec.read_run_fmt(best_candidate_run, fmt, top=ranktopk)
     return None
Beispiel #2
0
 def _load_run_base_query(self, index, subset, rankfn, ranktopk, run_path,
                          fmt):
     queries = self._load_queries_base(subset).items()
     index.batch_query(queries, rankfn, ranktopk, destf=run_path)
     return trec.read_run_fmt(run_path, fmt)
Beispiel #3
0
 def _load_run_base_direct(self, run_path, rankfn, ranktopk, fmt='dict'):
     if os.path.exists(run_path):
         with self.logger.duration(f'reading {rankfn}:{ranktopk}'):
             return trec.read_run_fmt(run_path, fmt=fmt)
     return None