Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingTil committed Nov 8, 2023
1 parent 0c13b46 commit a0d9cbd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions py_css/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ def gen_context_docs(context: Context) -> Generator[Document, None, None]:
for doc in docs:
if doc.docno != EMPTY_PLACEHOLDER_DOC.docno:
yield doc
i: int = 1
while True:
yield Document(f"{i}", "")
i += 1

# if in df there are multiple rows that have the same qid and docno, keep the one with the highest score. For the ones removed, add a row each with the EMPTY_PLACEHOLDER_DOC
rank_size_per_qid: int = df.groupby("qid").size().max()
df = df.sort_values(["qid", "docno", "score"], ascending=[True, True, False])
df = df.drop_duplicates(subset=["qid", "docno"], keep="first")
df = df.reset_index(drop=True)
df = self.pad_empty_documents(
df, df["qid"].unique(), rank_size_per_qid, df[["qid", "query"]]
)

for query, context in context_list:
# check if there is a row in the df with "qid" == query.query_id, where "docno" == EMPTY_PLACEHOLDER_DOC.docno
Expand Down

0 comments on commit a0d9cbd

Please sign in to comment.