Skip to content
Snippets Groups Projects
Unverified Commit b3fe444a authored by James Briggs's avatar James Briggs
Browse files

fixed bm25 encoder

parent 9b34b58b
No related branches found
No related tags found
No related merge requests found
...@@ -23,14 +23,14 @@ class BM25Encoder(BaseEncoder): ...@@ -23,14 +23,14 @@ class BM25Encoder(BaseEncoder):
else: else:
raise ValueError("No documents to encode.") raise ValueError("No documents to encode.")
# convert sparse dict to sparse vector # convert sparse dict to sparse vector
embeds = [0.0] * len(self.idx_mapping) embeds = [[0.0] * len(self.idx_mapping)] * len(docs)
for output in sparse_dicts: for i, output in enumerate(sparse_dicts):
indices = output["indices"] indices = output["indices"]
values = output["values"] values = output["values"]
for idx, val in zip(indices, values): for idx, val in zip(indices, values):
if idx in self.idx_mapping: if idx in self.idx_mapping:
position = self.idx_mapping[idx] position = self.idx_mapping[idx]
embeds[position] = val embeds[i][position] = val
else: else:
print(idx, "not in encoder.idx_mapping") print(idx, "not in encoder.idx_mapping")
return embeds return embeds
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment