Commit
·
7e48e30
1
Parent(s):
97069c7
Update oagkx.py
Browse files
oagkx.py
CHANGED
@@ -124,30 +124,32 @@ class OAGKx(datasets.GeneratorBasedBuilder):
|
|
124 |
]
|
125 |
|
126 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
127 |
-
def _generate_examples(self,
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
124 |
]
|
125 |
|
126 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
127 |
+
def _generate_examples(self, filepaths, split):
|
128 |
+
for filepath in filepaths:
|
129 |
+
with open(filepath, encoding="utf-8") as f:
|
130 |
+
for key, row in enumerate(f):
|
131 |
+
data = json.loads(row)
|
132 |
+
if self.config.name == "extraction":
|
133 |
+
# Yields examples as (key, example) tuples
|
134 |
+
yield key, {
|
135 |
+
"id": data.get("paper_id"),
|
136 |
+
"document": data["document"],
|
137 |
+
"doc_bio_tags": data.get("doc_bio_tags")
|
138 |
+
}
|
139 |
+
elif self.config.name == "generation":
|
140 |
+
yield key, {
|
141 |
+
"id": data.get("paper_id"),
|
142 |
+
"document": data["document"],
|
143 |
+
"extractive_keyphrases": data.get("extractive_keyphrases"),
|
144 |
+
"abstractive_keyphrases": data.get("abstractive_keyphrases")
|
145 |
+
}
|
146 |
+
else:
|
147 |
+
yield key, {
|
148 |
+
"id": data.get("paper_id"),
|
149 |
+
"document": data["document"],
|
150 |
+
"doc_bio_tags": data.get("doc_bio_tags"),
|
151 |
+
"extractive_keyphrases": data.get("extractive_keyphrases"),
|
152 |
+
"abstractive_keyphrases": data.get("abstractive_keyphrases"),
|
153 |
+
"other_metadata": data["other_metadata"]
|
154 |
+
}
|
155 |
+
|