Update msmarco-passage-corpus.py
Browse files- msmarco-passage-corpus.py +13 -9
msmarco-passage-corpus.py
CHANGED
@@ -66,22 +66,26 @@ class MsMarcoPassageCorpus(datasets.GeneratorBasedBuilder):
|
|
66 |
# Citation for the dataset
|
67 |
citation=_CITATION,
|
68 |
)
|
69 |
-
|
70 |
def _split_generators(self, dl_manager):
|
71 |
-
|
|
|
|
|
|
|
72 |
splits = [
|
73 |
datasets.SplitGenerator(
|
74 |
-
name=
|
75 |
gen_kwargs={
|
76 |
-
"
|
77 |
},
|
78 |
-
)
|
79 |
]
|
80 |
return splits
|
81 |
|
82 |
def _generate_examples(self, filepath):
|
83 |
"""Yields examples."""
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
66 |
# Citation for the dataset
|
67 |
citation=_CITATION,
|
68 |
)
|
69 |
+
|
70 |
def _split_generators(self, dl_manager):
|
71 |
+
if self.config.data_files:
|
72 |
+
downloaded_files = self.config.data_files
|
73 |
+
else:
|
74 |
+
downloaded_files = dl_manager.download_and_extract(_DATASET_URLS)
|
75 |
splits = [
|
76 |
datasets.SplitGenerator(
|
77 |
+
name=split,
|
78 |
gen_kwargs={
|
79 |
+
"files": [downloaded_files[split]] if isinstance(downloaded_files[split], str) else downloaded_files[split],
|
80 |
},
|
81 |
+
) for split in downloaded_files
|
82 |
]
|
83 |
return splits
|
84 |
|
85 |
def _generate_examples(self, filepath):
|
86 |
"""Yields examples."""
|
87 |
+
for filepath in files:
|
88 |
+
with open(filepath, encoding="utf-8") as f:
|
89 |
+
for line in f:
|
90 |
+
data = json.loads(line)
|
91 |
+
yield data['docid'], data
|