Datasets:

Modalities:
Text
ArXiv:
Libraries:
Datasets
dmahata commited on
Commit
317f555
·
1 Parent(s): 900a98b

Update inspec.py

Browse files
Files changed (1) hide show
  1. inspec.py +29 -5
inspec.py CHANGED
@@ -1,5 +1,4 @@
1
- import json
2
-
3
  import datasets
4
 
5
  # _SPLIT = ['train', 'test', 'valid']
@@ -121,9 +120,34 @@ class Inspec(datasets.GeneratorBasedBuilder):
121
 
122
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
123
  def _generate_examples(self, filepath, split):
124
- with open(filepath, encoding="utf-8") as f:
125
- for key, row in enumerate(f):
126
- data = json.loads(row)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  if self.config.name == "extraction":
128
  # Yields examples as (key, example) tuples
129
  yield key, {
 
1
+ import jsonlines
 
2
  import datasets
3
 
4
  # _SPLIT = ['train', 'test', 'valid']
 
120
 
121
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
122
  def _generate_examples(self, filepath, split):
123
+ # with open(filepath, encoding="utf-8") as f:
124
+ # for key, row in enumerate(f):
125
+ # data = json.loads(row)
126
+ # if self.config.name == "extraction":
127
+ # # Yields examples as (key, example) tuples
128
+ # yield key, {
129
+ # "id": data['paper_id'],
130
+ # "document": data["document"],
131
+ # "doc_bio_tags": data.get("doc_bio_tags")
132
+ # }
133
+ # elif self.config.name == "generation":
134
+ # yield key, {
135
+ # "id": data['paper_id'],
136
+ # "document": data["document"],
137
+ # "extractive_keyphrases": data.get("extractive_keyphrases"),
138
+ # "abstractive_keyphrases": data.get("abstractive_keyphrases")
139
+ # }
140
+ # else:
141
+ # yield key, {
142
+ # "id": data['paper_id'],
143
+ # "document": data["document"],
144
+ # "doc_bio_tags": data.get("doc_bio_tags"),
145
+ # "extractive_keyphrases": data.get("extractive_keyphrases"),
146
+ # "abstractive_keyphrases": data.get("abstractive_keyphrases"),
147
+ # "other_metadata": data["other_metadata"]
148
+ # }
149
+ with jsonlines.open(filepath) as reader:
150
+ for key, data in enumerate(reader):
151
  if self.config.name == "extraction":
152
  # Yields examples as (key, example) tuples
153
  yield key, {