Skip to content

Commit

Permalink
Add script to look up doc text from qrels for MS MARCO passage (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
lintool committed Apr 24, 2021
1 parent 540f83c commit 482aa81
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/msmarco-passage/lookup_docs_from_qrels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import argparse
import json
import sys

# We're going to explicitly use a local installation of Pyserini (as opposed to a pip-installed one).
# Comment these lines out to use a pip-installed one instead.
sys.path.insert(0, './')

from pyserini.search import SimpleSearcher


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--qrels', type=str, help='qrels file', required=True)
parser.add_argument('--index', type=str, help='index location', required=True)
args = parser.parse_args()

searcher = SimpleSearcher(args.index)
with open(args.qrels, 'r') as reader:
for line in reader.readlines():
arr = line.split('\t')
doc = json.loads(searcher.doc(arr[2]).raw())['contents']
print(f'{arr[2]}\t{doc}')

0 comments on commit 482aa81

Please sign in to comment.