Update app.py
Browse files
app.py
CHANGED
|
@@ -408,6 +408,9 @@ class CSCBM25Index(CSCInvertedIndex):
|
|
| 408 |
indices.append(docid)
|
| 409 |
indptr.append(len(data))
|
| 410 |
|
|
|
|
|
|
|
|
|
|
| 411 |
posting_lists_matrix = csc_matrix(
|
| 412 |
(data, indices, indptr),
|
| 413 |
shape=(total_docs, len(posting_lists))
|
|
@@ -490,6 +493,7 @@ class BaseCSCInvertedIndexRetriever(BaseRetriever):
|
|
| 490 |
continue
|
| 491 |
tid = self.index.vocab[tok]
|
| 492 |
weight = self.index.posting_lists_matrix[target_docid, tid]
|
|
|
|
| 493 |
term_weights[tok] = weight
|
| 494 |
return term_weights
|
| 495 |
## YOUR_CODE_ENDS_HERE
|
|
|
|
| 408 |
indices.append(docid)
|
| 409 |
indptr.append(len(data))
|
| 410 |
|
| 411 |
+
data = np.array(data, dtype=np.float32)
|
| 412 |
+
indices = np.array(indices, dtype=np.int32)
|
| 413 |
+
indptr = np.array(indptr, dtype=np.int32)
|
| 414 |
posting_lists_matrix = csc_matrix(
|
| 415 |
(data, indices, indptr),
|
| 416 |
shape=(total_docs, len(posting_lists))
|
|
|
|
| 493 |
continue
|
| 494 |
tid = self.index.vocab[tok]
|
| 495 |
weight = self.index.posting_lists_matrix[target_docid, tid]
|
| 496 |
+
if weight == 0: continue
|
| 497 |
term_weights[tok] = weight
|
| 498 |
return term_weights
|
| 499 |
## YOUR_CODE_ENDS_HERE
|