Busani
commited on
Commit
•
2d5f16d
1
Parent(s):
1a599bd
Versioning up
Browse files- cosuju.py +18 -11
- train-v1.1.json +0 -0
cosuju.py
CHANGED
@@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function
|
|
6 |
|
7 |
import json
|
8 |
import os
|
|
|
9 |
|
10 |
import datasets
|
11 |
|
@@ -23,13 +24,14 @@ year = {2021}
|
|
23 |
|
24 |
# TODO: Complete description
|
25 |
_DESCRIPTION = """\
|
26 |
-
Court Summaries and Judgements (CoSuJu)
|
27 |
"""
|
28 |
|
29 |
# Redundant but may useful in future.
|
30 |
_URL = "https://frtnx.github.io/cosuju-extractor/dataset/"
|
31 |
_URLS = {
|
32 |
-
'train': _URL + 'train-v1.
|
|
|
33 |
}
|
34 |
|
35 |
|
@@ -45,21 +47,19 @@ class CosujuConfig(datasets.BuilderConfig):
|
|
45 |
|
46 |
|
47 |
class Cosuju(datasets.GeneratorBasedBuilder):
|
48 |
-
"""COSUJU: The Court Summaries and Judgements Dataset. Version 1.
|
49 |
|
50 |
-
VERSION = datasets.Version("1.
|
51 |
|
52 |
# Allows configuration to be chosen at run time
|
53 |
# data = datasets.load_dataset('my_dataset', 'include_no_summary')
|
54 |
# data = datasets.load_dataset('my_dataset', 'exclude_no_summary')
|
55 |
-
|
56 |
-
DEFAULT_CONFIG_NAME = 'exclude_no_summary'
|
57 |
-
|
58 |
BUILDER_CONFIGS = [
|
59 |
datasets.BuilderConfig(name="include_no_summary", version=VERSION, description="Includes rows with no summary documents"),
|
60 |
-
datasets.BuilderConfig(name=
|
61 |
]
|
62 |
|
|
|
63 |
|
64 |
def _info(self):
|
65 |
return datasets.DatasetInfo(
|
@@ -81,7 +81,9 @@ class Cosuju(datasets.GeneratorBasedBuilder):
|
|
81 |
'file_url': datasets.Value('string'),
|
82 |
'file_content': datasets.Value('string')
|
83 |
},
|
84 |
-
|
|
|
|
|
85 |
),
|
86 |
supervised_keys=None,
|
87 |
homepage='https://huggingface.co/datasets/FRTNX/cosuju',
|
@@ -90,8 +92,9 @@ class Cosuju(datasets.GeneratorBasedBuilder):
|
|
90 |
|
91 |
def _split_generators(self, dl_manager):
|
92 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
|
|
93 |
return [
|
94 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={'filepath': downloaded_files['train']})
|
95 |
]
|
96 |
|
97 |
def _generate_examples(self, filepath):
|
@@ -100,10 +103,12 @@ class Cosuju(datasets.GeneratorBasedBuilder):
|
|
100 |
with open(filepath, encoding="utf-8") as f:
|
101 |
cosuju = json.load(f)
|
102 |
for row in cosuju['data']:
|
|
|
103 |
if self.config.name == 'exclude_no_summary':
|
104 |
if not row['summary_document']:
|
105 |
continue
|
106 |
|
|
|
107 |
if type(row['summary_document']) == dict and \
|
108 |
row['summary_document']['file_content'] == '':
|
109 |
continue
|
@@ -114,7 +119,9 @@ class Cosuju(datasets.GeneratorBasedBuilder):
|
|
114 |
'title': row['title'],
|
115 |
'url': row['url'],
|
116 |
'year': row['year'],
|
117 |
-
'update_date': row['update_date']
|
|
|
|
|
118 |
}
|
119 |
|
120 |
# This is to keep things feature compliant
|
|
|
6 |
|
7 |
import json
|
8 |
import os
|
9 |
+
import re
|
10 |
|
11 |
import datasets
|
12 |
|
|
|
24 |
|
25 |
# TODO: Complete description
|
26 |
_DESCRIPTION = """\
|
27 |
+
Court Summaries and Judgements (CoSuJu) Dataset
|
28 |
"""
|
29 |
|
30 |
# Redundant but may useful in future.
|
31 |
_URL = "https://frtnx.github.io/cosuju-extractor/dataset/"
|
32 |
_URLS = {
|
33 |
+
'train': _URL + 'train-v1.1.json',
|
34 |
+
# 'train': _URL + 'mini-train-v1.0.json'
|
35 |
}
|
36 |
|
37 |
|
|
|
47 |
|
48 |
|
49 |
class Cosuju(datasets.GeneratorBasedBuilder):
|
50 |
+
"""COSUJU: The Court Summaries and Judgements Dataset. Version 1.1.0"""
|
51 |
|
52 |
+
VERSION = datasets.Version("1.1.0")
|
53 |
|
54 |
# Allows configuration to be chosen at run time
|
55 |
# data = datasets.load_dataset('my_dataset', 'include_no_summary')
|
56 |
# data = datasets.load_dataset('my_dataset', 'exclude_no_summary')
|
|
|
|
|
|
|
57 |
BUILDER_CONFIGS = [
|
58 |
datasets.BuilderConfig(name="include_no_summary", version=VERSION, description="Includes rows with no summary documents"),
|
59 |
+
datasets.BuilderConfig(name='exclude_no_summary', version=VERSION, description="Excludes rows with no summary documents")
|
60 |
]
|
61 |
|
62 |
+
DEFAULT_CONFIG_NAME = 'exclude_no_summary'
|
63 |
|
64 |
def _info(self):
|
65 |
return datasets.DatasetInfo(
|
|
|
81 |
'file_url': datasets.Value('string'),
|
82 |
'file_content': datasets.Value('string')
|
83 |
},
|
84 |
+
'judgement_paragraphs': [datasets.Value('string')],
|
85 |
+
'max_length_judgement_paras': datasets.Value('int64')
|
86 |
+
}
|
87 |
),
|
88 |
supervised_keys=None,
|
89 |
homepage='https://huggingface.co/datasets/FRTNX/cosuju',
|
|
|
92 |
|
93 |
def _split_generators(self, dl_manager):
|
94 |
downloaded_files = dl_manager.download_and_extract(_URLS)
|
95 |
+
|
96 |
return [
|
97 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={'filepath': downloaded_files['train']})
|
98 |
]
|
99 |
|
100 |
def _generate_examples(self, filepath):
|
|
|
103 |
with open(filepath, encoding="utf-8") as f:
|
104 |
cosuju = json.load(f)
|
105 |
for row in cosuju['data']:
|
106 |
+
# exclude cases with no summaries when configuration demands it
|
107 |
if self.config.name == 'exclude_no_summary':
|
108 |
if not row['summary_document']:
|
109 |
continue
|
110 |
|
111 |
+
# edge case sanitization
|
112 |
if type(row['summary_document']) == dict and \
|
113 |
row['summary_document']['file_content'] == '':
|
114 |
continue
|
|
|
119 |
'title': row['title'],
|
120 |
'url': row['url'],
|
121 |
'year': row['year'],
|
122 |
+
'update_date': row['update_date'],
|
123 |
+
'judgement_paragraphs': row['judgement_paragraphs'],
|
124 |
+
'max_length_judgement_paras': row['max_length_judgement_paras']
|
125 |
}
|
126 |
|
127 |
# This is to keep things feature compliant
|
train-v1.1.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|