adding changes
Browse files- nomiracl.py +12 -11
nomiracl.py
CHANGED
|
@@ -119,6 +119,7 @@ class NoMIRACL(datasets.GeneratorBasedBuilder):
|
|
| 119 |
NoMIRACLConfig(name="spanish", description="Spanish NoMIRACL dataset"),
|
| 120 |
NoMIRACLConfig(name="telugu", description="Telugu NoMIRACL dataset"),
|
| 121 |
NoMIRACLConfig(name="yoruba", description="Yoruba NoMIRACL dataset"),
|
|
|
|
| 122 |
]
|
| 123 |
|
| 124 |
def _info(self):
|
|
@@ -128,13 +129,13 @@ class NoMIRACL(datasets.GeneratorBasedBuilder):
|
|
| 128 |
'query_id': datasets.Value('string'),
|
| 129 |
'query': datasets.Value('string'),
|
| 130 |
'positive_passages': [{
|
| 131 |
-
'docid': datasets.Value('string'),
|
| 132 |
-
'text': datasets.Value('string'),
|
| 133 |
'title': datasets.Value('string')
|
| 134 |
}],
|
| 135 |
'negative_passages': [{
|
| 136 |
'docid': datasets.Value('string'),
|
| 137 |
-
'text': datasets.Value('string'),
|
| 138 |
'title': datasets.Value('string'),
|
| 139 |
}],
|
| 140 |
}),
|
|
@@ -146,14 +147,14 @@ class NoMIRACL(datasets.GeneratorBasedBuilder):
|
|
| 146 |
|
| 147 |
def _split_generators(self, dl_manager):
|
| 148 |
|
| 149 |
-
# Download downloaded_files
|
| 150 |
downloaded_files = dl_manager.download_and_extract({
|
| 151 |
"corpus": self.config.data_root_url + "/corpus.jsonl.gz",
|
| 152 |
-
"dev": {"qrels": {"relevant": self.config.data_root_url + "/qrels/dev.relevant.tsv",
|
| 153 |
"non_relevant": self.config.data_root_url + "/qrels/dev.non_relevant.tsv"},
|
| 154 |
"topics": {"relevant": self.config.data_root_url + "/topics/dev.relevant.tsv",
|
| 155 |
"non_relevant": self.config.data_root_url + "/topics/dev.non_relevant.tsv"}},
|
| 156 |
-
"test": {"qrels": {"relevant": self.config.data_root_url + "/qrels/test.relevant.tsv",
|
| 157 |
"non_relevant": self.config.data_root_url + "/qrels/test.non_relevant.tsv"},
|
| 158 |
"topics": {"relevant": self.config.data_root_url + "/topics/test.relevant.tsv",
|
| 159 |
"non_relevant": self.config.data_root_url + "/topics/test.non_relevant.tsv"}},
|
|
@@ -195,9 +196,9 @@ class NoMIRACL(datasets.GeneratorBasedBuilder):
|
|
| 195 |
]
|
| 196 |
|
| 197 |
return splits
|
| 198 |
-
|
| 199 |
def _generate_examples(self, corpus_path, qrels_path, topics_path):
|
| 200 |
-
|
| 201 |
corpus = load_corpus(corpus_path)
|
| 202 |
qrels = load_qrels(qrels_path)
|
| 203 |
topics = load_topics(topics_path)
|
|
@@ -206,15 +207,15 @@ class NoMIRACL(datasets.GeneratorBasedBuilder):
|
|
| 206 |
data = {}
|
| 207 |
data['query_id'] = qid
|
| 208 |
data['query'] = topics[qid]
|
| 209 |
-
|
| 210 |
pos_docids = [docid for docid, rel in qrels[qid].items() if rel == 1] if qrels is not None else []
|
| 211 |
neg_docids = [docid for docid, rel in qrels[qid].items() if rel == 0] if qrels is not None else []
|
| 212 |
data['positive_passages'] = [{
|
| 213 |
-
'docid': docid,
|
| 214 |
**corpus[docid]
|
| 215 |
} for docid in pos_docids if docid in corpus]
|
| 216 |
data['negative_passages'] = [{
|
| 217 |
-
'docid': docid,
|
| 218 |
**corpus[docid]
|
| 219 |
} for docid in neg_docids if docid in corpus]
|
| 220 |
yield qid, data
|
|
|
|
| 119 |
NoMIRACLConfig(name="spanish", description="Spanish NoMIRACL dataset"),
|
| 120 |
NoMIRACLConfig(name="telugu", description="Telugu NoMIRACL dataset"),
|
| 121 |
NoMIRACLConfig(name="yoruba", description="Yoruba NoMIRACL dataset"),
|
| 122 |
+
NoMIRACLConfig(name="portuguese", description="Yoruba NoMIRACL dataset"),
|
| 123 |
]
|
| 124 |
|
| 125 |
def _info(self):
|
|
|
|
| 129 |
'query_id': datasets.Value('string'),
|
| 130 |
'query': datasets.Value('string'),
|
| 131 |
'positive_passages': [{
|
| 132 |
+
'docid': datasets.Value('string'),
|
| 133 |
+
'text': datasets.Value('string'),
|
| 134 |
'title': datasets.Value('string')
|
| 135 |
}],
|
| 136 |
'negative_passages': [{
|
| 137 |
'docid': datasets.Value('string'),
|
| 138 |
+
'text': datasets.Value('string'),
|
| 139 |
'title': datasets.Value('string'),
|
| 140 |
}],
|
| 141 |
}),
|
|
|
|
| 147 |
|
| 148 |
def _split_generators(self, dl_manager):
|
| 149 |
|
| 150 |
+
# Download downloaded_files
|
| 151 |
downloaded_files = dl_manager.download_and_extract({
|
| 152 |
"corpus": self.config.data_root_url + "/corpus.jsonl.gz",
|
| 153 |
+
"dev": {"qrels": {"relevant": self.config.data_root_url + "/qrels/dev.relevant.tsv",
|
| 154 |
"non_relevant": self.config.data_root_url + "/qrels/dev.non_relevant.tsv"},
|
| 155 |
"topics": {"relevant": self.config.data_root_url + "/topics/dev.relevant.tsv",
|
| 156 |
"non_relevant": self.config.data_root_url + "/topics/dev.non_relevant.tsv"}},
|
| 157 |
+
"test": {"qrels": {"relevant": self.config.data_root_url + "/qrels/test.relevant.tsv",
|
| 158 |
"non_relevant": self.config.data_root_url + "/qrels/test.non_relevant.tsv"},
|
| 159 |
"topics": {"relevant": self.config.data_root_url + "/topics/test.relevant.tsv",
|
| 160 |
"non_relevant": self.config.data_root_url + "/topics/test.non_relevant.tsv"}},
|
|
|
|
| 196 |
]
|
| 197 |
|
| 198 |
return splits
|
| 199 |
+
|
| 200 |
def _generate_examples(self, corpus_path, qrels_path, topics_path):
|
| 201 |
+
|
| 202 |
corpus = load_corpus(corpus_path)
|
| 203 |
qrels = load_qrels(qrels_path)
|
| 204 |
topics = load_topics(topics_path)
|
|
|
|
| 207 |
data = {}
|
| 208 |
data['query_id'] = qid
|
| 209 |
data['query'] = topics[qid]
|
| 210 |
+
|
| 211 |
pos_docids = [docid for docid, rel in qrels[qid].items() if rel == 1] if qrels is not None else []
|
| 212 |
neg_docids = [docid for docid, rel in qrels[qid].items() if rel == 0] if qrels is not None else []
|
| 213 |
data['positive_passages'] = [{
|
| 214 |
+
'docid': docid,
|
| 215 |
**corpus[docid]
|
| 216 |
} for docid in pos_docids if docid in corpus]
|
| 217 |
data['negative_passages'] = [{
|
| 218 |
+
'docid': docid,
|
| 219 |
**corpus[docid]
|
| 220 |
} for docid in neg_docids if docid in corpus]
|
| 221 |
yield qid, data
|