Update ldkp10k.py
Browse files- 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":
|
28 |
-
"train":
|
29 |
-
"valid":
|
30 |
|
31 |
}
|
32 |
|
@@ -49,7 +49,7 @@ class LDKP10k(datasets.GeneratorBasedBuilder):
|
|
49 |
|
50 |
def _info(self):
|
51 |
#print(os.listdir())
|
52 |
-
_URLS['train']
|
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 |
-
"
|
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 |
-
"
|
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 |
-
"
|
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 |
-
|
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 |
+
}
|
|