- minipileoflaw.py +13 -13
minipileoflaw.py
CHANGED
@@ -94,21 +94,21 @@ class MiniPileOfLaw(datasets.GeneratorBasedBuilder):
|
|
94 |
name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": validation_downloaded_files}
|
95 |
),
|
96 |
]
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
def _generate_examples(self, filepaths):
|
101 |
-
"""This function returns the examples from
|
102 |
for filepath in filepaths:
|
103 |
try:
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
113 |
except Exception as e:
|
114 |
print(f"Error reading file {filepath}: {e}")
|
|
|
|
94 |
name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": validation_downloaded_files}
|
95 |
),
|
96 |
]
|
97 |
+
|
|
|
|
|
98 |
def _generate_examples(self, filepaths):
|
99 |
+
"""This function returns the examples from JSONL files, with each line being a separate JSON object."""
|
100 |
for filepath in filepaths:
|
101 |
try:
|
102 |
+
with open(filepath, 'r', encoding='utf-8') as file:
|
103 |
+
for line in file:
|
104 |
+
# Parse each line as a separate JSON object
|
105 |
+
item = json.loads(line.strip())
|
106 |
+
yield {
|
107 |
+
"text": item.get("text", ""),
|
108 |
+
"created_timestamp": item.get("created_timestamp", ""),
|
109 |
+
"downloaded_timestamp": item.get("downloaded_timestamp", ""),
|
110 |
+
"url": item.get("url", "")
|
111 |
+
}
|
112 |
except Exception as e:
|
113 |
print(f"Error reading file {filepath}: {e}")
|
114 |
+
|