Datasets:
fix script to display dataset preview
Browse files- euscrawl.py +16 -16
euscrawl.py
CHANGED
@@ -74,26 +74,26 @@ class EusCrawl(datasets.GeneratorBasedBuilder):
|
|
74 |
)
|
75 |
|
76 |
def _split_generators(self, dl_manager):
|
77 |
-
path = dl_manager.
|
78 |
-
filepath = f"{path}/{_FILEPATH}"
|
79 |
return [
|
80 |
datasets.SplitGenerator(
|
81 |
name=datasets.Split.TRAIN,
|
82 |
-
gen_kwargs={"
|
83 |
)
|
84 |
]
|
85 |
|
86 |
-
def _generate_examples(self,
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
74 |
)
|
75 |
|
76 |
def _split_generators(self, dl_manager):
|
77 |
+
path = dl_manager.download(_URL)
|
|
|
78 |
return [
|
79 |
datasets.SplitGenerator(
|
80 |
name=datasets.Split.TRAIN,
|
81 |
+
gen_kwargs={"filepaths": dl_manager.iter_archive(path)},
|
82 |
)
|
83 |
]
|
84 |
|
85 |
+
def _generate_examples(self, filepaths):
|
86 |
+
for filepath, file in filepaths:
|
87 |
+
if filepath == _FILEPATH:
|
88 |
+
for id, line in enumerate(file):
|
89 |
+
data = json.loads(line)
|
90 |
|
91 |
+
# defaut to empty string if field is missing
|
92 |
+
yield id, {
|
93 |
+
"id": id,
|
94 |
+
"title": data.get("title", ""),
|
95 |
+
"text": data.get("text", ""),
|
96 |
+
"source": data.get("source", ""),
|
97 |
+
"license": data.get("license", ""),
|
98 |
+
"url": data.get("url", ""),
|
99 |
+
}
|