Update GitTables.py
Browse files- GitTables.py +25 -24
GitTables.py
CHANGED
|
@@ -152,27 +152,28 @@ class GitTables(datasets.GeneratorBasedBuilder):
|
|
| 152 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 153 |
def _generate_examples(self, filepath, split):
|
| 154 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 155 |
-
with
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
|
|
|
|
|
| 152 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 153 |
def _generate_examples(self, filepath, split):
|
| 154 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 155 |
+
with open(filepath, encoding="utf-8") as f:
|
| 156 |
+
with jsonlines.open(rf"{f}", mode="r") as reader:
|
| 157 |
+
for key, row in enumerate(reader):
|
| 158 |
+
data = json.loads(row)
|
| 159 |
+
if self.config.name == "dbpedia":
|
| 160 |
+
# Yields examples as (key, example) tuples
|
| 161 |
+
yield key, {
|
| 162 |
+
"id": data["id"],
|
| 163 |
+
"table_id": data["table_id"],
|
| 164 |
+
"target_column": data["target_column"],
|
| 165 |
+
"column_text": data["column_text"],
|
| 166 |
+
"annotation_id": data["annotation_id"],
|
| 167 |
+
"annotation_label": data["annotation_label"],
|
| 168 |
+
"table_text": data["table_text"]
|
| 169 |
+
}
|
| 170 |
+
else:
|
| 171 |
+
yield key, {
|
| 172 |
+
"id": data["id"],
|
| 173 |
+
"table_id": data["table_id"],
|
| 174 |
+
"target_column": data["target_column"],
|
| 175 |
+
"column_text": data["column_text"],
|
| 176 |
+
"annotation_id": data["annotation_id"],
|
| 177 |
+
"annotation_label": data["annotation_label"],
|
| 178 |
+
"table_text": data["table_text"]
|
| 179 |
+
}
|