Update ldkp3k.py
Browse files
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']=
|
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 |
-
"
|
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 |
-
"
|
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 |
-
"
|
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,
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
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 |
+
}
|