Skip to content

Commit

Permalink
Fix topics-and-qrels integration issue for search._base (#1501)
Browse files Browse the repository at this point in the history
Fixed functions for getting qrels.
  • Loading branch information
ArthurChen189 authored Apr 19, 2023
1 parent d66c557 commit 2828d4f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyserini/search/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

# Wrappers around Lucene classes
JQuery = autoclass('org.apache.lucene.search.Query')
JPath = autoclass('java.nio.file.Path')

# Wrappers around Anserini classes
JQrels = autoclass('io.anserini.eval.Qrels')
Expand Down Expand Up @@ -510,14 +511,14 @@ def get_qrels_file(collection_name):
"""
if collection_name in qrels_mapping:
qrels = qrels_mapping[collection_name]
target_path = os.path.join(get_cache_home(), qrels.path)
target_path = JRelevanceJudgments.getQrelsPath(JPath.of(qrels.path)).toString()
if os.path.exists(target_path):
return target_path
target_dir = os.path.split(target_path)[0]
if not os.path.exists(target_dir):
os.makedirs(target_dir)
with open(target_path, 'w') as file:
qrels_content = JRelevanceJudgments.getQrelsResource(qrels)
qrels_content = JRelevanceJudgments.getQrelsResource(JPath.of(target_path))
file.write(qrels_content)
return target_path

Expand Down

0 comments on commit 2828d4f

Please sign in to comment.