Commit
·
cf036bf
1
Parent(s):
72760b7
Upload old_bailey_proceedings.py
Browse files- old_bailey_proceedings.py +16 -15
old_bailey_proceedings.py
CHANGED
@@ -39,9 +39,7 @@ _DATASETNAME = "old_bailey_proceedings"
|
|
39 |
|
40 |
_LICENSE = "Creative Commons Attribution 4.0 International"
|
41 |
|
42 |
-
|
43 |
-
_DATASETNAME: "https://www.dhi.ac.uk/san/data/oldbailey/oldbailey.zip",
|
44 |
-
}
|
45 |
|
46 |
logger = datasets.utils.logging.get_logger(__name__)
|
47 |
|
@@ -73,8 +71,7 @@ class OldBaileyProceedings(datasets.GeneratorBasedBuilder):
|
|
73 |
)
|
74 |
|
75 |
def _split_generators(self, dl_manager):
|
76 |
-
|
77 |
-
data_dir = dl_manager.download_and_extract(urls)
|
78 |
oa_dir = "ordinarysAccounts"
|
79 |
obp_dir = "sessionsPapers"
|
80 |
return [
|
@@ -125,14 +122,17 @@ class OldBaileyProceedings(datasets.GeneratorBasedBuilder):
|
|
125 |
if text_snippet:
|
126 |
text_parts.append(text_snippet)
|
127 |
full_text = " ".join(text_parts)
|
128 |
-
return
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
136 |
except Exception as e:
|
137 |
return -1, repr(e)
|
138 |
|
@@ -141,8 +141,9 @@ class OldBaileyProceedings(datasets.GeneratorBasedBuilder):
|
|
141 |
for file in glob.glob(os.path.join(data_dir, "*.xml")):
|
142 |
status_code, ret_val = self.convert_text_to_features(file, key)
|
143 |
if status_code:
|
144 |
-
logger.
|
145 |
-
|
|
|
146 |
continue
|
147 |
else:
|
148 |
yield ret_val["id"], ret_val
|
|
|
39 |
|
40 |
_LICENSE = "Creative Commons Attribution 4.0 International"
|
41 |
|
42 |
+
_URL = "https://www.dhi.ac.uk/san/data/oldbailey/oldbailey.zip"
|
|
|
|
|
43 |
|
44 |
logger = datasets.utils.logging.get_logger(__name__)
|
45 |
|
|
|
71 |
)
|
72 |
|
73 |
def _split_generators(self, dl_manager):
|
74 |
+
data_dir = dl_manager.download_and_extract(_URL)
|
|
|
75 |
oa_dir = "ordinarysAccounts"
|
76 |
obp_dir = "sessionsPapers"
|
77 |
return [
|
|
|
122 |
if text_snippet:
|
123 |
text_parts.append(text_snippet)
|
124 |
full_text = " ".join(text_parts)
|
125 |
+
return (
|
126 |
+
0,
|
127 |
+
{
|
128 |
+
"id": id,
|
129 |
+
"date": date,
|
130 |
+
"type": key,
|
131 |
+
"places": places,
|
132 |
+
"persons": persons,
|
133 |
+
"text": full_text,
|
134 |
+
},
|
135 |
+
)
|
136 |
except Exception as e:
|
137 |
return -1, repr(e)
|
138 |
|
|
|
141 |
for file in glob.glob(os.path.join(data_dir, "*.xml")):
|
142 |
status_code, ret_val = self.convert_text_to_features(file, key)
|
143 |
if status_code:
|
144 |
+
logger.exception(
|
145 |
+
f"{os.path.basename(file)} could not be parsed properly"
|
146 |
+
)
|
147 |
continue
|
148 |
else:
|
149 |
yield ret_val["id"], ret_val
|