Update ciral.py
Browse files
ciral.py
CHANGED
@@ -148,8 +148,8 @@ class CIRAL(datasets.GeneratorBasedBuilder):
|
|
148 |
qrels = load_qrels(qrel_file)
|
149 |
for query_id in queries:
|
150 |
|
151 |
-
positive_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==1]
|
152 |
-
negative_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==0]
|
153 |
|
154 |
data = {}
|
155 |
data['query_id'] = query_id
|
@@ -162,10 +162,5 @@ class CIRAL(datasets.GeneratorBasedBuilder):
|
|
162 |
'docid': docid,
|
163 |
'text': docid2doc[docid]
|
164 |
} for docid in negative_docids if docid in docid2doc]
|
165 |
-
# data['judgements'] = [{
|
166 |
-
# 'docid': docid,
|
167 |
-
# 'judgement': judgement,
|
168 |
-
# 'text': docid2doc[docid]
|
169 |
-
# } for docid, judgement in qrels[query_id].items()]
|
170 |
|
171 |
yield query_id, data
|
|
|
148 |
qrels = load_qrels(qrel_file)
|
149 |
for query_id in queries:
|
150 |
|
151 |
+
positive_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==1] if qrels is not None else []
|
152 |
+
negative_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==0] if qrels is not None else []
|
153 |
|
154 |
data = {}
|
155 |
data['query_id'] = query_id
|
|
|
162 |
'docid': docid,
|
163 |
'text': docid2doc[docid]
|
164 |
} for docid in negative_docids if docid in docid2doc]
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
yield query_id, data
|