(collection_file)
| 83 | |
| 84 | |
| 85 | def 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 | |
| 101 | def tensor_to_list(tensor): |
| 102 | return tensor.detach().cpu().tolist() |
nothing calls this directly
no outgoing calls
no test coverage detected