MCPcopy Create free account
hub / github.com/BeastyZ/ConvSearch-R1 / load_collection

Function load_collection

index/dense/utils.py:85–99  ·  view source on GitHub ↗
(collection_file)

Source from the content-addressed store, hash-verified

83
84
85def load_collection(collection_file):
86 all_docs = {}
87 with open(collection_file, "r") as f:
88 for line in f:
89 line = line.strip()
90 try:
91 line_arr = line.split("\t")
92 pid = int(line_arr[0])
93 passage = line_arr[1].rstrip()
94 all_docs[pid] = passage
95 except IndexError:
96 print("bad passage")
97 except ValueError:
98 print("bad pid")
99 return all_docs
100
101def tensor_to_list(tensor):
102 return tensor.detach().cpu().tolist()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected