from pyserini.search import get_topics, get_qrels import json topics = get_topics('dl19-passage') qrels = get_qrels('dl19-passage') with open('dl19.jsonl', 'w') as f: for topic_id in qrels: query_id = topic_id query = topics[query_id]['title'] positive_passages = [] negative_passages = [] f.write(json.dumps({ 'query_id': str(query_id), 'query': query, 'positive_passages': positive_passages, 'negative_passages': negative_passages, }) + '\n')