ad6398 commited on
Commit
6e4bb3b
1 Parent(s): 9d332fd

Update ldkp10k.py

Browse files
Files changed (1) hide show
  1. ldkp10k.py +19 -20
ldkp10k.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": ["dummy_path"],
29
- "valid": ["data/valid.jsonl"],
30
 
31
  }
32
 
@@ -49,7 +49,7 @@ class LDKP10k(datasets.GeneratorBasedBuilder):
49
 
50
  def _info(self):
51
  #print(os.listdir())
52
- _URLS['train']="data/"+self.config.name+".zip"
53
 
54
  features = datasets.Features(
55
  {
@@ -83,7 +83,7 @@ class LDKP10k(datasets.GeneratorBasedBuilder):
83
  name=datasets.Split.TRAIN,
84
  # These kwargs will be passed to _generate_examples
85
  gen_kwargs={
86
- "filepaths": [os.path.join(data_dir['train'],filename) for filename in os.listdir(data_dir['train'])],
87
  "split": "train",
88
  },
89
  ),
@@ -91,7 +91,7 @@ class LDKP10k(datasets.GeneratorBasedBuilder):
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,23 +99,22 @@ class LDKP10k(datasets.GeneratorBasedBuilder):
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
- }
 
24
  # TODO: Add link to the official dataset URLs here
25
 
26
  _URLS = {
27
+ "test": "data/test.jsonl",
28
+ "train": "data/train",
29
+ "valid": "data/valid.jsonl",
30
 
31
  }
32
 
 
49
 
50
  def _info(self):
51
  #print(os.listdir())
52
+ _URLS['train']+="_"+self.config.name+".jsonl.zip"
53
 
54
  features = datasets.Features(
55
  {
 
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
  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
  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
+ }