ad6398 commited on
Commit
3369fdd
1 Parent(s): 1e93b72

Update ldkp3k.py

Browse files
Files changed (1) hide show
  1. ldkp3k.py +20 -19
ldkp3k.py CHANGED
@@ -24,9 +24,9 @@ _LICENSE = ""
24
  # TODO: Add link to the official dataset URLs here
25
 
26
  _URLS = {
27
- "test": "data/test.jsonl",
28
- "train": "train.jsonl",
29
- "valid": "data/valid.jsonl",
30
 
31
  }
32
 
@@ -49,7 +49,7 @@ class LDKP3k(datasets.GeneratorBasedBuilder):
49
 
50
  def _info(self):
51
 
52
- _URLS['train']="data/"+str(self.config.name)+"/train.jsonl"
53
 
54
 
55
  features = datasets.Features(
@@ -83,7 +83,7 @@ class LDKP3k(datasets.GeneratorBasedBuilder):
83
  name=datasets.Split.TRAIN,
84
  # These kwargs will be passed to _generate_examples
85
  gen_kwargs={
86
- "filepath": data_dir['train'],
87
  "split": "train",
88
  },
89
  ),
@@ -91,7 +91,7 @@ class LDKP3k(datasets.GeneratorBasedBuilder):
91
  name=datasets.Split.TEST,
92
  # These kwargs will be passed to _generate_examples
93
  gen_kwargs={
94
- "filepath": data_dir['test'],
95
  "split": "test"
96
  },
97
  ),
@@ -99,22 +99,23 @@ class LDKP3k(datasets.GeneratorBasedBuilder):
99
  name=datasets.Split.VALIDATION,
100
  # These kwargs will be passed to _generate_examples
101
  gen_kwargs={
102
- "filepath": data_dir['valid'],
103
  "split": "valid",
104
  },
105
  ),
106
  ]
107
 
108
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
109
- def _generate_examples(self, filepath, split):
110
- with open(filepath, encoding="utf-8") as f:
111
- for key, row in enumerate(f):
112
- data = json.loads(row)
113
- yield key, {
114
- "id": data['paper_id'],
115
- "sections": data["sections"],
116
- "sec_text": data["sec_text"],
117
- "extractive_keyphrases": data["extractive_keyphrases"],
118
- "abstractive_keyphrases": data["abstractive_keyphrases"],
119
- "sec_bio_tags": data["sec_bio_tags"]
120
- }
 
24
  # TODO: Add link to the official dataset URLs here
25
 
26
  _URLS = {
27
+ "test": ["data/test.jsonl"],
28
+ "train": ["train.jsonl"],
29
+ "valid": ["data/valid.jsonl"],
30
 
31
  }
32
 
49
 
50
  def _info(self):
51
 
52
+ _URLS['train']=[os.path.join('data/'+self.config.name,filename) for filename in os.listdir('data/'+self.config.name) if filename.startswith('train') and filename.endswith('.jsonl')]
53
 
54
 
55
  features = datasets.Features(
83
  name=datasets.Split.TRAIN,
84
  # These kwargs will be passed to _generate_examples
85
  gen_kwargs={
86
+ "filepaths": data_dir['train'],
87
  "split": "train",
88
  },
89
  ),
91
  name=datasets.Split.TEST,
92
  # These kwargs will be passed to _generate_examples
93
  gen_kwargs={
94
+ "filepaths": data_dir['test'],
95
  "split": "test"
96
  },
97
  ),
99
  name=datasets.Split.VALIDATION,
100
  # These kwargs will be passed to _generate_examples
101
  gen_kwargs={
102
+ "filepaths": data_dir['valid'],
103
  "split": "valid",
104
  },
105
  ),
106
  ]
107
 
108
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
109
+ def _generate_examples(self, filepaths, split):
110
+ for filepath in filepaths:
111
+ with open(filepath, encoding="utf-8") as f:
112
+ for key, row in enumerate(f):
113
+ data = json.loads(row)
114
+ yield key, {
115
+ "id": data['paper_id'],
116
+ "sections": data["sections"],
117
+ "sec_text": data["sec_text"],
118
+ "extractive_keyphrases": data["extractive_keyphrases"],
119
+ "abstractive_keyphrases": data["abstractive_keyphrases"],
120
+ "sec_bio_tags": data["sec_bio_tags"]
121
+ }