Upldate lbox_open.py to include three new datasets.
Browse filesAdd `casename_classification_plus`, `statute_classification_plus`, and `summarization_plus` datasets.
Please refer to [our paper](https://arxiv.org/abs/2206.05224) for the detail.
- lbox_open.py +73 -23
lbox_open.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
-
#
|
2 |
-
# Copyright 2022-present LBox Co. Ltd.
|
3 |
-
#
|
|
|
|
|
4 |
import json
|
5 |
|
6 |
import datasets
|
@@ -12,6 +14,13 @@ _CASENAME_CLASSIFICATION_FEATURES = {
|
|
12 |
"facts": datasets.Value("string"),
|
13 |
}
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
_STATUTE_CLASSIFICATION_FEATURES = {
|
16 |
"id": datasets.Value("int64"),
|
17 |
"casetype": datasets.Value("string"),
|
@@ -20,6 +29,14 @@ _STATUTE_CLASSIFICATION_FEATURES = {
|
|
20 |
"facts": datasets.Value("string"),
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
_LJP_CRIMINAL = {
|
24 |
"id": datasets.Value("int64"),
|
25 |
"casetype": datasets.Value("string"),
|
@@ -76,7 +93,13 @@ _LJP_CIVIL = {
|
|
76 |
},
|
77 |
}
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
"id": datasets.Value("int64"),
|
81 |
"summary": datasets.Value("string"),
|
82 |
"precedent": datasets.Value("string"),
|
@@ -92,13 +115,13 @@ class LBoxOpenConfig(datasets.BuilderConfig):
|
|
92 |
"""BuilderConfig for OpenLBox."""
|
93 |
|
94 |
def __init__(
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
):
|
103 |
# Version history:
|
104 |
# 0.1.0: Initial version.
|
@@ -121,7 +144,14 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
121 |
description="",
|
122 |
features=_CASENAME_CLASSIFICATION_FEATURES,
|
123 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/casename_classification/v0.1.2/",
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
citation="",
|
126 |
url="lbox.kr",
|
127 |
),
|
@@ -130,7 +160,14 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
130 |
description="",
|
131 |
features=_STATUTE_CLASSIFICATION_FEATURES,
|
132 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/statute_classification/v0.1.2/",
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
citation="",
|
135 |
url="lbox.kr",
|
136 |
),
|
@@ -153,11 +190,19 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
153 |
LBoxOpenConfig(
|
154 |
name="summarization",
|
155 |
description="",
|
156 |
-
features=
|
157 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/summarization/v0.1.0/",
|
158 |
citation="",
|
159 |
url="lbox.kr",
|
160 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
LBoxOpenConfig(
|
162 |
name="precedent_corpus",
|
163 |
description="",
|
@@ -182,7 +227,7 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
182 |
"train": dl_manager.download_and_extract(
|
183 |
f"{self.config.data_url}case_corpus-150k.jsonl"
|
184 |
)
|
185 |
-
|
186 |
}
|
187 |
|
188 |
return [
|
@@ -195,24 +240,29 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
195 |
)
|
196 |
]
|
197 |
|
198 |
-
elif self.config.name in [
|
|
|
|
|
|
|
|
|
|
|
199 |
dl_dir = {
|
200 |
"train": dl_manager.download_and_extract(
|
201 |
f"{self.config.data_url}train.jsonl"
|
202 |
)
|
203 |
-
|
204 |
"valid": dl_manager.download_and_extract(
|
205 |
f"{self.config.data_url}valid.jsonl"
|
206 |
)
|
207 |
-
|
208 |
"test": dl_manager.download_and_extract(
|
209 |
f"{self.config.data_url}test.jsonl"
|
210 |
)
|
211 |
-
|
212 |
"test2": dl_manager.download_and_extract(
|
213 |
f"{self.config.data_url}test2.jsonl"
|
214 |
)
|
215 |
-
|
216 |
}
|
217 |
|
218 |
return [
|
@@ -250,15 +300,15 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
250 |
"train": dl_manager.download_and_extract(
|
251 |
f"{self.config.data_url}train.jsonl"
|
252 |
)
|
253 |
-
|
254 |
"valid": dl_manager.download_and_extract(
|
255 |
f"{self.config.data_url}valid.jsonl"
|
256 |
)
|
257 |
-
|
258 |
"test": dl_manager.download_and_extract(
|
259 |
f"{self.config.data_url}test.jsonl"
|
260 |
)
|
261 |
-
|
262 |
}
|
263 |
|
264 |
return [
|
|
|
1 |
+
# LBox Open
|
2 |
+
# Copyright (c) 2022-present LBox Co. Ltd.
|
3 |
+
# CC BY-NC-ND 4.0
|
4 |
+
# 2022.10.18, Wonseok: Add casename_classification_plus, statutes_classification_plus, summarization_plus datasets
|
5 |
+
|
6 |
import json
|
7 |
|
8 |
import datasets
|
|
|
14 |
"facts": datasets.Value("string"),
|
15 |
}
|
16 |
|
17 |
+
_CASENAME_CLASSIFICATION_PLUS_FEATURES = {
|
18 |
+
"id": datasets.Value("int64"),
|
19 |
+
"casetype": datasets.Value("string"),
|
20 |
+
"casename": datasets.Value("string"),
|
21 |
+
"facts": datasets.Value("string"),
|
22 |
+
}
|
23 |
+
|
24 |
_STATUTE_CLASSIFICATION_FEATURES = {
|
25 |
"id": datasets.Value("int64"),
|
26 |
"casetype": datasets.Value("string"),
|
|
|
29 |
"facts": datasets.Value("string"),
|
30 |
}
|
31 |
|
32 |
+
_STATUTE_CLASSIFICATION_PLUS_FEATURES = {
|
33 |
+
"id": datasets.Value("int64"),
|
34 |
+
"casetype": datasets.Value("string"),
|
35 |
+
"casename": datasets.Value("string"),
|
36 |
+
"statutes": datasets.features.Sequence(datasets.Value("string")),
|
37 |
+
"facts": datasets.Value("string"),
|
38 |
+
}
|
39 |
+
|
40 |
_LJP_CRIMINAL = {
|
41 |
"id": datasets.Value("int64"),
|
42 |
"casetype": datasets.Value("string"),
|
|
|
93 |
},
|
94 |
}
|
95 |
|
96 |
+
_SUMMARIZATION_FEATURES = {
|
97 |
+
"id": datasets.Value("int64"),
|
98 |
+
"summary": datasets.Value("string"),
|
99 |
+
"precedent": datasets.Value("string"),
|
100 |
+
}
|
101 |
+
|
102 |
+
_SUMMARIZATION_PLUS_FEATURES = {
|
103 |
"id": datasets.Value("int64"),
|
104 |
"summary": datasets.Value("string"),
|
105 |
"precedent": datasets.Value("string"),
|
|
|
115 |
"""BuilderConfig for OpenLBox."""
|
116 |
|
117 |
def __init__(
|
118 |
+
self,
|
119 |
+
features,
|
120 |
+
data_url,
|
121 |
+
citation,
|
122 |
+
url,
|
123 |
+
label_classes=("False", "True"),
|
124 |
+
**kwargs,
|
125 |
):
|
126 |
# Version history:
|
127 |
# 0.1.0: Initial version.
|
|
|
144 |
description="",
|
145 |
features=_CASENAME_CLASSIFICATION_FEATURES,
|
146 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/casename_classification/v0.1.2/",
|
147 |
+
citation="",
|
148 |
+
url="lbox.kr",
|
149 |
+
),
|
150 |
+
LBoxOpenConfig(
|
151 |
+
name="casename_classification_plus",
|
152 |
+
description="",
|
153 |
+
features=_CASENAME_CLASSIFICATION_FEATURES,
|
154 |
+
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/casename_classification/v0.1.2_plus/",
|
155 |
citation="",
|
156 |
url="lbox.kr",
|
157 |
),
|
|
|
160 |
description="",
|
161 |
features=_STATUTE_CLASSIFICATION_FEATURES,
|
162 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/statute_classification/v0.1.2/",
|
163 |
+
citation="",
|
164 |
+
url="lbox.kr",
|
165 |
+
),
|
166 |
+
LBoxOpenConfig(
|
167 |
+
name="statute_classification_plus",
|
168 |
+
description="",
|
169 |
+
features=_STATUTE_CLASSIFICATION_FEATURES,
|
170 |
+
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/statute_classification/v0.1.2_plus/",
|
171 |
citation="",
|
172 |
url="lbox.kr",
|
173 |
),
|
|
|
190 |
LBoxOpenConfig(
|
191 |
name="summarization",
|
192 |
description="",
|
193 |
+
features=_SUMMARIZATION_FEATURES,
|
194 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/summarization/v0.1.0/",
|
195 |
citation="",
|
196 |
url="lbox.kr",
|
197 |
),
|
198 |
+
LBoxOpenConfig(
|
199 |
+
name="summarization_plus",
|
200 |
+
description="",
|
201 |
+
features=_SUMMARIZATION_FEATURES,
|
202 |
+
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/summarization/v0.1.0_plus/",
|
203 |
+
citation="",
|
204 |
+
url="lbox.kr",
|
205 |
+
),
|
206 |
LBoxOpenConfig(
|
207 |
name="precedent_corpus",
|
208 |
description="",
|
|
|
227 |
"train": dl_manager.download_and_extract(
|
228 |
f"{self.config.data_url}case_corpus-150k.jsonl"
|
229 |
)
|
230 |
+
or "",
|
231 |
}
|
232 |
|
233 |
return [
|
|
|
240 |
)
|
241 |
]
|
242 |
|
243 |
+
elif self.config.name in [
|
244 |
+
"casename_classification",
|
245 |
+
"statute_classification",
|
246 |
+
"ljp_criminal",
|
247 |
+
"ljp_civil",
|
248 |
+
]:
|
249 |
dl_dir = {
|
250 |
"train": dl_manager.download_and_extract(
|
251 |
f"{self.config.data_url}train.jsonl"
|
252 |
)
|
253 |
+
or "",
|
254 |
"valid": dl_manager.download_and_extract(
|
255 |
f"{self.config.data_url}valid.jsonl"
|
256 |
)
|
257 |
+
or "",
|
258 |
"test": dl_manager.download_and_extract(
|
259 |
f"{self.config.data_url}test.jsonl"
|
260 |
)
|
261 |
+
or "",
|
262 |
"test2": dl_manager.download_and_extract(
|
263 |
f"{self.config.data_url}test2.jsonl"
|
264 |
)
|
265 |
+
or "",
|
266 |
}
|
267 |
|
268 |
return [
|
|
|
300 |
"train": dl_manager.download_and_extract(
|
301 |
f"{self.config.data_url}train.jsonl"
|
302 |
)
|
303 |
+
or "",
|
304 |
"valid": dl_manager.download_and_extract(
|
305 |
f"{self.config.data_url}valid.jsonl"
|
306 |
)
|
307 |
+
or "",
|
308 |
"test": dl_manager.download_and_extract(
|
309 |
f"{self.config.data_url}test.jsonl"
|
310 |
)
|
311 |
+
or "",
|
312 |
}
|
313 |
|
314 |
return [
|