Update datasets script v0.1 → v0.2
#1
by
wonseok
- opened
- lbox_open.py +164 -16
lbox_open.py
CHANGED
@@ -2,31 +2,88 @@
|
|
2 |
# Copyright 2022-present LBox Co. Ltd.
|
3 |
# Licensed under the CC BY-NC-ND 4.0
|
4 |
import json
|
|
|
5 |
import datasets
|
6 |
|
7 |
_CASENAME_CLASSIFICATION_FEATURES = {
|
8 |
-
"id": datasets.Value("
|
9 |
"casetype": datasets.Value("string"),
|
10 |
"casename": datasets.Value("string"),
|
11 |
"facts": datasets.Value("string"),
|
12 |
}
|
13 |
|
14 |
_STATUTE_CLASSIFICATION_FEATURES = {
|
15 |
-
"id": datasets.Value("
|
16 |
"casetype": datasets.Value("string"),
|
17 |
"casename": datasets.Value("string"),
|
18 |
"statutes": datasets.features.Sequence(datasets.Value("string")),
|
19 |
"facts": datasets.Value("string"),
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
_SUMMARIZATION_CLASSIFICATION_FEATURES = {
|
23 |
-
"id": datasets.Value("
|
24 |
"summary": datasets.Value("string"),
|
25 |
"precedent": datasets.Value("string"),
|
26 |
}
|
27 |
|
28 |
-
|
29 |
-
"id": datasets.Value("
|
30 |
"precedent": datasets.Value("string"),
|
31 |
}
|
32 |
|
@@ -34,10 +91,20 @@ _CASE_CORPUS_FEATURES = {
|
|
34 |
class LBoxOpenConfig(datasets.BuilderConfig):
|
35 |
"""BuilderConfig for OpenLBox."""
|
36 |
|
37 |
-
def __init__(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
# Version history:
|
39 |
# 0.1.0: Initial version.
|
40 |
-
super(LBoxOpenConfig, self).__init__(
|
|
|
|
|
41 |
self.features = features
|
42 |
self.label_classes = label_classes
|
43 |
self.data_url = data_url
|
@@ -47,12 +114,14 @@ class LBoxOpenConfig(datasets.BuilderConfig):
|
|
47 |
|
48 |
class LBoxOpen(datasets.GeneratorBasedBuilder):
|
49 |
"""The Legal AI Benchmark dataset from Korean Legal Cases."""
|
|
|
50 |
BUILDER_CONFIGS = [
|
51 |
LBoxOpenConfig(
|
52 |
name="casename_classification",
|
53 |
description="",
|
54 |
features=_CASENAME_CLASSIFICATION_FEATURES,
|
55 |
-
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/casename_classification/v0.1.
|
|
|
56 |
citation="",
|
57 |
url="lbox.kr",
|
58 |
),
|
@@ -60,7 +129,24 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
60 |
name="statute_classification",
|
61 |
description="",
|
62 |
features=_STATUTE_CLASSIFICATION_FEATURES,
|
63 |
-
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/statute_classification/v0.1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
citation="",
|
65 |
url="lbox.kr",
|
66 |
),
|
@@ -73,9 +159,9 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
73 |
url="lbox.kr",
|
74 |
),
|
75 |
LBoxOpenConfig(
|
76 |
-
name="
|
77 |
description="",
|
78 |
-
features=
|
79 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/case_corpus/v0.1.0/",
|
80 |
citation="",
|
81 |
url="lbox.kr",
|
@@ -91,9 +177,12 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
91 |
)
|
92 |
|
93 |
def _split_generators(self, dl_manager):
|
94 |
-
if self.config.name == "
|
95 |
dl_dir = {
|
96 |
-
"train": dl_manager.download_and_extract(
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
return [
|
@@ -106,11 +195,70 @@ class LBoxOpen(datasets.GeneratorBasedBuilder):
|
|
106 |
)
|
107 |
]
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
else:
|
110 |
dl_dir = {
|
111 |
-
"train": dl_manager.download_and_extract(
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
return [
|
|
|
2 |
# Copyright 2022-present LBox Co. Ltd.
|
3 |
# Licensed under the CC BY-NC-ND 4.0
|
4 |
import json
|
5 |
+
|
6 |
import datasets
|
7 |
|
8 |
_CASENAME_CLASSIFICATION_FEATURES = {
|
9 |
+
"id": datasets.Value("int64"),
|
10 |
"casetype": datasets.Value("string"),
|
11 |
"casename": datasets.Value("string"),
|
12 |
"facts": datasets.Value("string"),
|
13 |
}
|
14 |
|
15 |
_STATUTE_CLASSIFICATION_FEATURES = {
|
16 |
+
"id": datasets.Value("int64"),
|
17 |
"casetype": datasets.Value("string"),
|
18 |
"casename": datasets.Value("string"),
|
19 |
"statutes": datasets.features.Sequence(datasets.Value("string")),
|
20 |
"facts": datasets.Value("string"),
|
21 |
}
|
22 |
|
23 |
+
_LJP_CRIMINAL = {
|
24 |
+
"id": datasets.Value("int64"),
|
25 |
+
"casetype": datasets.Value("string"),
|
26 |
+
"casename": datasets.Value("string"),
|
27 |
+
"facts": datasets.Value("string"),
|
28 |
+
"reason": datasets.Value("string"),
|
29 |
+
"label": {
|
30 |
+
"text": datasets.Value("string"),
|
31 |
+
"fine_lv": datasets.Value("int64"),
|
32 |
+
"imprisonment_with_labor_lv": datasets.Value("int64"),
|
33 |
+
"imprisonment_without_labor_lv": datasets.Value("int64"),
|
34 |
+
},
|
35 |
+
"ruling": {
|
36 |
+
"text": datasets.Value("string"),
|
37 |
+
"parse": {
|
38 |
+
"fine": {
|
39 |
+
"type": datasets.Value("string"),
|
40 |
+
"unit": datasets.Value("string"),
|
41 |
+
"value": datasets.Value("int64"),
|
42 |
+
},
|
43 |
+
"imprisonment": {
|
44 |
+
"type": datasets.Value("string"),
|
45 |
+
"unit": datasets.Value("string"),
|
46 |
+
"value": datasets.Value("int64"),
|
47 |
+
},
|
48 |
+
},
|
49 |
+
},
|
50 |
+
}
|
51 |
+
|
52 |
+
_LJP_CIVIL = {
|
53 |
+
"id": datasets.Value("int64"),
|
54 |
+
"casetype": datasets.Value("string"),
|
55 |
+
"casename": datasets.Value("string"),
|
56 |
+
"facts": datasets.Value("string"),
|
57 |
+
"claim_acceptance_lv": datasets.Value("int64"),
|
58 |
+
"gist_of_claim": {
|
59 |
+
"text": datasets.Value("string"),
|
60 |
+
"money": {
|
61 |
+
"provider": datasets.Value("string"),
|
62 |
+
"taker": datasets.Value("string"),
|
63 |
+
"unit": datasets.Value("string"),
|
64 |
+
"value": datasets.Value("int64"),
|
65 |
+
},
|
66 |
+
},
|
67 |
+
"ruling": {
|
68 |
+
"text": datasets.Value("string"),
|
69 |
+
"money": {
|
70 |
+
"provider": datasets.Value("string"),
|
71 |
+
"taker": datasets.Value("string"),
|
72 |
+
"unit": datasets.Value("string"),
|
73 |
+
"value": datasets.Value("int64"),
|
74 |
+
},
|
75 |
+
"litigation_cost": datasets.Value("float32"),
|
76 |
+
},
|
77 |
+
}
|
78 |
+
|
79 |
_SUMMARIZATION_CLASSIFICATION_FEATURES = {
|
80 |
+
"id": datasets.Value("int64"),
|
81 |
"summary": datasets.Value("string"),
|
82 |
"precedent": datasets.Value("string"),
|
83 |
}
|
84 |
|
85 |
+
_PRECEDENT_CORPUS_FEATURES = {
|
86 |
+
"id": datasets.Value("int64"),
|
87 |
"precedent": datasets.Value("string"),
|
88 |
}
|
89 |
|
|
|
91 |
class LBoxOpenConfig(datasets.BuilderConfig):
|
92 |
"""BuilderConfig for OpenLBox."""
|
93 |
|
94 |
+
def __init__(
|
95 |
+
self,
|
96 |
+
features,
|
97 |
+
data_url,
|
98 |
+
citation,
|
99 |
+
url,
|
100 |
+
label_classes=("False", "True"),
|
101 |
+
**kwargs,
|
102 |
+
):
|
103 |
# Version history:
|
104 |
# 0.1.0: Initial version.
|
105 |
+
super(LBoxOpenConfig, self).__init__(
|
106 |
+
version=datasets.Version("0.2.0"), **kwargs
|
107 |
+
)
|
108 |
self.features = features
|
109 |
self.label_classes = label_classes
|
110 |
self.data_url = data_url
|
|
|
114 |
|
115 |
class LBoxOpen(datasets.GeneratorBasedBuilder):
|
116 |
"""The Legal AI Benchmark dataset from Korean Legal Cases."""
|
117 |
+
|
118 |
BUILDER_CONFIGS = [
|
119 |
LBoxOpenConfig(
|
120 |
name="casename_classification",
|
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 |
+
# data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/casename_classification/v0.1.0/",
|
125 |
citation="",
|
126 |
url="lbox.kr",
|
127 |
),
|
|
|
129 |
name="statute_classification",
|
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 |
+
# data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/statute_classification/v0.1.0/",
|
134 |
+
citation="",
|
135 |
+
url="lbox.kr",
|
136 |
+
),
|
137 |
+
LBoxOpenConfig(
|
138 |
+
name="ljp_criminal",
|
139 |
+
description="",
|
140 |
+
features=_LJP_CRIMINAL,
|
141 |
+
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/judgement_prediction/v0.1.2/criminal/",
|
142 |
+
citation="",
|
143 |
+
url="lbox.kr",
|
144 |
+
),
|
145 |
+
LBoxOpenConfig(
|
146 |
+
name="ljp_civil",
|
147 |
+
description="",
|
148 |
+
features=_LJP_CIVIL,
|
149 |
+
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/judgement_prediction/v0.1.2/civil/",
|
150 |
citation="",
|
151 |
url="lbox.kr",
|
152 |
),
|
|
|
159 |
url="lbox.kr",
|
160 |
),
|
161 |
LBoxOpenConfig(
|
162 |
+
name="precedent_corpus",
|
163 |
description="",
|
164 |
+
features=_PRECEDENT_CORPUS_FEATURES,
|
165 |
data_url="https://lbox-open.s3.ap-northeast-2.amazonaws.com/precedent_benchmark_dataset/case_corpus/v0.1.0/",
|
166 |
citation="",
|
167 |
url="lbox.kr",
|
|
|
177 |
)
|
178 |
|
179 |
def _split_generators(self, dl_manager):
|
180 |
+
if self.config.name == "precedent_corpus":
|
181 |
dl_dir = {
|
182 |
+
"train": dl_manager.download_and_extract(
|
183 |
+
f"{self.config.data_url}case_corpus-150k.jsonl"
|
184 |
+
)
|
185 |
+
or "",
|
186 |
}
|
187 |
|
188 |
return [
|
|
|
195 |
)
|
196 |
]
|
197 |
|
198 |
+
elif self.config.name in ["casename_classification", "statute_classification", "ljp_criminal", "ljp_civil"]:
|
199 |
+
dl_dir = {
|
200 |
+
"train": dl_manager.download_and_extract(
|
201 |
+
f"{self.config.data_url}train.jsonl"
|
202 |
+
)
|
203 |
+
or "",
|
204 |
+
"valid": dl_manager.download_and_extract(
|
205 |
+
f"{self.config.data_url}valid.jsonl"
|
206 |
+
)
|
207 |
+
or "",
|
208 |
+
"test": dl_manager.download_and_extract(
|
209 |
+
f"{self.config.data_url}test.jsonl"
|
210 |
+
)
|
211 |
+
or "",
|
212 |
+
"test2": dl_manager.download_and_extract(
|
213 |
+
f"{self.config.data_url}test2.jsonl"
|
214 |
+
)
|
215 |
+
or "",
|
216 |
+
}
|
217 |
+
|
218 |
+
return [
|
219 |
+
datasets.SplitGenerator(
|
220 |
+
name=datasets.Split.TRAIN,
|
221 |
+
gen_kwargs={
|
222 |
+
"data_file": dl_dir["train"],
|
223 |
+
"split": datasets.Split.TRAIN,
|
224 |
+
},
|
225 |
+
),
|
226 |
+
datasets.SplitGenerator(
|
227 |
+
name=datasets.Split.VALIDATION,
|
228 |
+
gen_kwargs={
|
229 |
+
"data_file": dl_dir["valid"],
|
230 |
+
"split": datasets.Split.VALIDATION,
|
231 |
+
},
|
232 |
+
),
|
233 |
+
datasets.SplitGenerator(
|
234 |
+
name=datasets.Split.TEST,
|
235 |
+
gen_kwargs={
|
236 |
+
"data_file": dl_dir["test"],
|
237 |
+
"split": datasets.Split.TEST,
|
238 |
+
},
|
239 |
+
),
|
240 |
+
datasets.SplitGenerator(
|
241 |
+
name="test2",
|
242 |
+
gen_kwargs={
|
243 |
+
"data_file": dl_dir["test2"],
|
244 |
+
"split": "test2",
|
245 |
+
},
|
246 |
+
),
|
247 |
+
]
|
248 |
else:
|
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 |
}
|
263 |
|
264 |
return [
|