mod split_generators
Browse files- regulatory_comments.py +21 -21
regulatory_comments.py
CHANGED
@@ -104,29 +104,29 @@ class RegComments(datasets.GeneratorBasedBuilder):
|
|
104 |
data_dir = dl_manager.download_and_extract(urls)
|
105 |
print("urls accessed")
|
106 |
print(data_dir)
|
107 |
-
|
108 |
return [datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
109 |
# These kwargs will be passed to _generate_examples
|
110 |
gen_kwargs={
|
111 |
-
"filepath":
|
112 |
-
"split": "train",
|
113 |
},),]
|
114 |
|
115 |
-
#
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
104 |
data_dir = dl_manager.download_and_extract(urls)
|
105 |
print("urls accessed")
|
106 |
print(data_dir)
|
107 |
+
#print("File path:", os.path.join(data_dir, "train.csv"))
|
108 |
return [datasets.SplitGenerator(name=datasets.Split.TRAIN,
|
109 |
# These kwargs will be passed to _generate_examples
|
110 |
gen_kwargs={
|
111 |
+
"filepath": data_dir,
|
112 |
+
#"split": "train",
|
113 |
},),]
|
114 |
|
115 |
+
#method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
116 |
+
def _generate_examples(self, filepath):
|
117 |
+
print("generate examples called")
|
118 |
+
with open(filepath, encoding="utf-8") as f:
|
119 |
+
reader = csv.DictReader(f)
|
120 |
+
for key, row in enumerate(reader):
|
121 |
+
yield key, {
|
122 |
+
"docket_agency": row["docket_agency"],
|
123 |
+
"docket_title": row["docket_title"],
|
124 |
+
"docket_date": row["docket_date"],
|
125 |
+
"comment_id": row["comment_id"],
|
126 |
+
"comment_date": row["comment_date"],
|
127 |
+
"comment_url": row["comment_url"],
|
128 |
+
"comment_title": row["comment_title"],
|
129 |
+
"commenter_name": row["commenter_name"],
|
130 |
+
"comment_length": int(row["comment_length"]),
|
131 |
+
"comment_text": row["comment_text"],
|
132 |
+
}
|