Datasets:
Add files using upload-large-folder tool
Browse files- MixBench25.py +15 -7
MixBench25.py
CHANGED
|
@@ -65,15 +65,23 @@ class MixBench(datasets.GeneratorBasedBuilder):
|
|
| 65 |
|
| 66 |
def _generate_examples(self, path, split):
|
| 67 |
if split == "qrel":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
with open(path, encoding="utf-8") as f:
|
| 69 |
-
|
| 70 |
-
|
| 71 |
yield idx, {
|
| 72 |
-
"query_id":
|
| 73 |
-
"corpus_id":
|
| 74 |
-
"
|
| 75 |
-
"image": "",
|
| 76 |
-
"score": int(score),
|
| 77 |
}
|
| 78 |
else:
|
| 79 |
with open(path, encoding="utf-8") as f:
|
|
|
|
| 65 |
|
| 66 |
def _generate_examples(self, path, split):
|
| 67 |
if split == "qrel":
|
| 68 |
+
# with open(path, encoding="utf-8") as f:
|
| 69 |
+
# for idx, line in enumerate(f):
|
| 70 |
+
# qid, did, score = line.strip().split()
|
| 71 |
+
# yield idx, {
|
| 72 |
+
# "query_id": qid,
|
| 73 |
+
# "corpus_id": did,
|
| 74 |
+
# "text": "",
|
| 75 |
+
# "image": "",
|
| 76 |
+
# "score": int(score),
|
| 77 |
+
# }
|
| 78 |
with open(path, encoding="utf-8") as f:
|
| 79 |
+
reader = csv.DictReader(f, delimiter="\t") # 使用 DictReader 读取有表头的 tsv
|
| 80 |
+
for idx, row in enumerate(reader):
|
| 81 |
yield idx, {
|
| 82 |
+
"query_id": row["query_id"],
|
| 83 |
+
"corpus_id": row["corpus_id"],
|
| 84 |
+
"score": int(row["score"]),
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
else:
|
| 87 |
with open(path, encoding="utf-8") as f:
|